Hi all, I was wondering, I’ve always only seen fold statements increment some counter after repeatedly evaluating a condition over x length.
I’m looking to store the hl2 of candles whose volume exceeds the average 50 period volume, and to repaint the current candle if it closes above any of those candles in that array (and previous candle closed below).
Can a fold statement be used to iterate over my array of hl2 of candles whose volume exceeds the average 50 period volume, and repaint if it closes above any of those candles?
I’ve tried something like:
I’m looking to store the hl2 of candles whose volume exceeds the average 50 period volume, and to repaint the current candle if it closes above any of those candles in that array (and previous candle closed below).
Can a fold statement be used to iterate over my array of hl2 of candles whose volume exceeds the average 50 period volume, and repaint if it closes above any of those candles?
I’ve tried something like:
Code:
def HL2Array = if (newDay) then 0 else if (marketHours and volume > average(volume,50)) then hl2 else 0;
plot NextClose = fold i = 1 to 195 with price = Double.NaN while IsNaN(price) do if (GetValue(close, 1, 0) < HL2Array[i] and GetValue(close, 0, 0) > HL2Array[i]) then getValue(close, 0, 0) else Double.NaN;
AssignPriceColor(if !isNaN(NextClose) then Color.MAGENTA else Color.CURRENT);
Last edited: