Hiltos: The chart then runs for a few minutes and will now create some weird bent MA. T
LastStatic = index | Of course it does. As soon as a new bar forms LastStatic is pointing to the wrong bar.. Store lastTime= Time[LastStatic] and at the start of a new tick reset LastStatic = IbarShift(..., lastTime) |
Oh what a graceful way to handle that! Thank you so much!
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I have programmed an indicator which seems to work at first when placed on a chart but will change it's behavior when running. I know it has something to do with how I'm calculating Limit for the for loop. Maybe I'm missing something obvious...
Here's what I've got: (running on the M1 chart)
Here's the code:
Exhibit A is the indicator working like it should. Exhibit B is where the indicator was placed on the chart. The chart then runs for a few minutes and will now create some weird bent MA. The MA should either stay flat or jump to a new level as in Exhibit A. It's hard to see in the picture, but there's a flat part of the MA that is two bars long at Exhibit C.
How can I make the indicator always act like Exhibit A in the picture?
Thank you for any insight you have.