I'm trying to write a code that will color all the bars that meet the following conditions:
1. their closing price is above 20-period Moving Average
AND
2. they close above Highest High price from given period (say 20 days)
This is my current code:
hp1 = highest(high, 20) //HH from given period
myMA = sma(close, 20) //my moving average to plot
plot(myMA)
myCond = close > hp1 and close > myMA
barcolor(myCond? yellow: na) //if condition is met
The code seems to be logical, but doesn't work. Any suggestions?