@SleepyZ , my brain continues to not want to understand how folds work. I hate to ask for more help from you but I was wondering if you might be able to add comments to different parts of the code describing what each line of the fold means? I want to add more prior highs but I'm not sure how to do it. Every time I add code, it doesn't change the fold the way I expect which means Im still not fundamentally understanding how a fold works. As always, any help you can lend would be just awesome!!
part of the code from post #2
input period = 100;
def lasthigh = if IsNaN(close[-1]) and !IsNaN(close) then high else Double.NaN;
def Data = fold i = 0 to period
#..on each bar on chart
#..data will be set = to the final result of the fold loop.
#..i counts from 0 to (period-1) , 0 to 99
with price = Double.NaN
#..with, specifies a temporary variable, price.
#..if it is set = to a value, that will be the starting value.
#..If a value is omitted, then the default value is 0
while IsNaN(price)
#..isnan() is true when price is not a valid number.
#..as long as IsNaN(price) is true, stay in loop and evaluate the do line
do
if GetValue(high, -i) > HighestAll(lasthigh)
then GetValue(high, -i)
else Data[1];
#..
#..check if a future high value is greater than the highest value of lasthigh
#..
#..GetValue(high, -i)
#..getvalue is used in fold loops, to read values from a variable, based on an offset. above , as the loop i counts through 0-99, those numbers are used as offsets . equivelants, high[0] , high[-1], high[-2], high[-3], ... since the offset is negative, it is reading values from future bars.
#..