i want to compare each successive two candles as follows :
get green arrow when the highest price of candle is bigger than the highest of previous candle
get yellow arrow when the lowest price of candle is lower than the lowest price of previous candle
get purple arrow when both lowest and highest price of candle is smaller than previous candle's lowest and highest price
get red candle when both lowest and highest price of candle is bigger than previous candle's lowest and highest price
i did it ,but this script is giving me errors on the conditions (makes the green purple and so on) , and i don't know why !
//@version=5
indicator("Arrows Based on Price Movement", overlay=true)
prevHigh = request.security(syminfo.tickerid, "D", high[1])
prevLow = request.security(syminfo.tickerid, "D", low[1])
currentHigh = high
currentLow = low
isGreenArrow = currentHigh > prevHigh and currentLow > prevLow
isYellowArrow = currentLow < prevLow and currentHigh < prevHigh
isPurpleArrow = currentHigh <= prevHigh and currentLow >= prevLow
isRedArrow = currentHigh > prevHigh and currentLow < prevLow
arrowColor = isGreenArrow ? color.green : isYellowArrow ? color.yellow : isPurpleArrow ? color.purple : color.red
plotarrow(series=isGreenArrow ? low - (currentHigh - prevHigh) * 0.2 : na, title="Green Arrow", colorup=arrowColor, colordown=arrowColor, offset=-1)
plotarrow(series=isYellowArrow ? low - (prevLow - currentLow) * 0.2 : na, title="Yellow Arrow", colorup=arrowColor, colordown=arrowColor, offset=-1)
plotarrow(series=isPurpleArrow ? low - ((currentHigh + currentLow) / 2 - (prevHigh + prevLow) / 2) * 0.2 : na, title="Purple Arrow", colorup=arrowColor, colordown=arrowColor, offset=-1)
plotarrow(series=isRedArrow ? low - (currentHigh - currentLow) * 0.2 : na, title="Red Arrow", colorup=arrowColor, colordown=arrowColor, offset=-1)