I've found this forum and the onenote file to be a huge help while learning thinkscript over the last few months.
So far I've been able to do almost everything I want in thinkscript. However I'm running into a problem on longer studies/plots where it will start to repaint and kill the signal.
I believe fold is the answer to this but I can't get my head wrapped around it. I've done very very limited programming before TOS so I'm not familiar with loop functions and that might be the problem.
if I had a good example of it doing a similar function I'm sure I could modify it to my uses.
Here's the code I'm using currently.
L1 plots an arrow below the fractal bottom that closes below the 20ma and 50ma
L1C draws a horizontal line from the close of the fractal.
Currently it draws the line but as soon as there is another bottom fractal it starts to repaint.
I would like to have it not plot L1 if the fractals are higher than the previous one and only plot a new L1 once the fractal closes below the L1C horizontal line or the previous fractal.
If price closes above the 50ma then it resets.
So basically it needs to look to see if the current L1/L1C is active.
I've tried other combos of if statements and trying to trick it by referencing plots instead of defs and it either partially works or breaks the whole study.
If there's another way besides fold I'd be open to that as well.
So far I've been able to do almost everything I want in thinkscript. However I'm running into a problem on longer studies/plots where it will start to repaint and kill the signal.
I believe fold is the answer to this but I can't get my head wrapped around it. I've done very very limited programming before TOS so I'm not familiar with loop functions and that might be the problem.
if I had a good example of it doing a similar function I'm sure I could modify it to my uses.
Here's the code I'm using currently.
L1 = bottomfractal and close < fastma and close < slowma;
L1C = if L1 then close[1] else if L1C[1] then L1C[1] else double.nan;
L1 plots an arrow below the fractal bottom that closes below the 20ma and 50ma
L1C draws a horizontal line from the close of the fractal.
Currently it draws the line but as soon as there is another bottom fractal it starts to repaint.
I would like to have it not plot L1 if the fractals are higher than the previous one and only plot a new L1 once the fractal closes below the L1C horizontal line or the previous fractal.
If price closes above the 50ma then it resets.
So basically it needs to look to see if the current L1/L1C is active.
I've tried other combos of if statements and trying to trick it by referencing plots instead of defs and it either partially works or breaks the whole study.
If there's another way besides fold I'd be open to that as well.