I have tried doing this with for loops and if statements and cannot get my variable "HH" to populate. The error it is throwing is it gets to line 23 and says HH is Undeclared which means it is not going into these if statements and setting a value. Any help is appreciated. What I am trying to do is find the high of the last 3 bars not including the current bar. I was using
HH = highest(high,4)
However this included the current bar which I cant have.
study("My Script")
LL = lowest(low,2)
HH1 = high[1]
HH2 = high[2]
HH3 = high[3]
if (HH1 > HH2)
HH = HH1
else if (HH1 > HH3)
HH = HH1
else if (HH2 > HH3)
HH = HH2
else
HH = HH3
buy = (crossover(close[0],HH)) ? close[0]:close[0]*.99
sell = (crossunder(close[0],LL)) ? close[0]:close[0]*.99
plot(sell,color=color.red)
plot(buy,color=color.yellow)
plot(price,color=color.black)
plot(HH,color=color.green)
alertcondition(crossover(close[0],HH), title="BUY")
alertcondition(crossunder(close[0],LL), title="SELL")
Aucun commentaire:
Enregistrer un commentaire