I am learning some PineScript
in my free time and I find it really diificult to work with. I am basically trying to recreate a complicated indicator I wrote in C#
and I am struggling with simple things.
Ommiting the complicated stuff, lets say I want to draw arrows when MACD behaves like in the following picture:
This is my current attempt, it is basically supposed to check if we are at a peak, find histogram high, find below zero columns, then above zero columns and check if they contain a higher histogram value then the current one:
[macdLine, signalLine, hist] = macd(close, 12, 26, 9)
float ind = na
if hist[2] > 0 and hist[1] < hist[2] and hist < hist[1] and hist[3] < hist[2]
bool maxHistFound = false
bool lowerFound = false
bool upperFound = false
bool candidateFound = false
float maxHist = hist[2]
for i = 1 to 1000
if not maxHistFound
if hist[i] < 0
maxHistFound := true
else
if hist[i] > maxHist
maxHist := hist[i]
if not lowerFound
if hist[i] < 0
lowerFound := true
if not upperFound
if hist[i] > 0
upperFound := true
if maxHistFound and lowerFound and upperFound
if hist[i] > 0 and hist[i + 1] <= hist[i] and hist[i - 1] <= hist[i]
if hist[i] > maxHist // and macdLine[i] > 0 and signalLine[i] > 0 and hist[i] > 0.10
candidateFound := true
maxHist := hist[i]
if hist[i] < 0
if candidateFound
ind := -1
break
alertcondition(ind == -1, title='Short', message='Short')
plotarrow(ind, colorup=#008000, colordown=#FF3030, transp=0, minheight=50, maxheight=50)
It shows the signal even if the signal is not preceeded with what I described.
The main problem is that I could probably fix it myself but I don't know how to properly debug in this language and I try to do it by plotting everything but plotting to debug things is riddiculus, unfortunately in my ignorance I can't find a better solution. I could probably easily find out whats going on if I knew how to stop at breakpoint in PineScript
.