So this script does so far what it should - it plots higher highs as blue bars on the chart:
//@version=4
study("Strat3", overlay=true)
// get user input
rsiLength = input(title="RSI Length", type=input.integer, defval=14)
rsiOB = input(title="RSI OB", type=input.float, defval=70.0)
rsiOS = input(title="RSI OS", type=input.float, defval=30.0)
// get rsi value
rsi = rsi(close, rsiLength)
//detect higher highs and higher lows, or lower lows and lower highs
HH = ((high>=high[1] and low>low[1]) or (high>high[1] and low>=low[1]))
LL = ((high<high[1] and low<=low[1]) or (high<=high[1] and low<low[1]))
//ConsHH/LL input
ConsHH = input(5, title="Consecutive HH's")
ConsLL = input(5, title="Consecutive LL's")
barcolor(HH ? color.blue: na)
So it clearly recognises the declared identifier "HH"
My aim is to have an HH and LL count, so eventually I can put this into a system to go long after 2 HH's for instance.
However when I add the following in my steps to create the HH/LL count:
HH = ((high>=high[1] and low>low[1]) or (high>high[1] and low>=low[1])) ?nz(HH[1])+1:0
LL = ((high<high[1] and low<=low[1]) or (high<=high[1] and low<low[1])) ?nz(LL[1])+1:0
HHCount = HH - valuewhen(HH < HH[1], HH , 1 )
LLCount = LL - valuewhen(LL < LL[1], LL , 1 )
I am getting the "underclared Identifier 'HH' and 'LL' on Lines 16, 17, 18. 19 and even now on line 61 where I set the bar color.
I am most confused and have tried many things - can anyone please give some insight into where I'm going wrong? It would be much appreciated!
Thanks
Dandy