I need to iterate through the chart from right to left and for each fractal (defined as two left and two right bar's lows are all >= this current bar's low), I want to make sure I only look at monotonically decreasing fractals and skip the ones that goes back up.
I have the leftOffset and RightOffset that defines where I start and stop this iteration. So I can do
fold index = RightOffset to leftOffset
If the fractals I encounter during fold is 70, 62, 66, 65, 60, 50., I want to skip that 66 and 65 fractal because they are both higher than 62.
If I write this in Java, it would be really simple. I could just have a variable called highWaterMark, and init to 70, and every time I see a fractal lower than highWaterMark, I know I should not skip it and I will lower highWaterMark to that value.
The problem with thinkscript is that if I def a variable, I cannot change its value once it is assigned. so I would not be able to do this efficiently. Could you give any suggestions?
I have the leftOffset and RightOffset that defines where I start and stop this iteration. So I can do
fold index = RightOffset to leftOffset
If the fractals I encounter during fold is 70, 62, 66, 65, 60, 50., I want to skip that 66 and 65 fractal because they are both higher than 62.
If I write this in Java, it would be really simple. I could just have a variable called highWaterMark, and init to 70, and every time I see a fractal lower than highWaterMark, I know I should not skip it and I will lower highWaterMark to that value.
The problem with thinkscript is that if I def a variable, I cannot change its value once it is assigned. so I would not be able to do this efficiently. Could you give any suggestions?