I try to create a loop that will check the existence of a condition for a certain length of time.
In this case, the short average is above the long average for the last 16 days.
(Indicating an upward trend)
At the moment there are at least two technical problems that I can not find a solution to,
I would be very happy if anyone could explain or suggest a way to solve the problem.
1. As you will see in the code, at the moment he can check the existence of the condition only in one candle (16 candles back)
But he does not do that either – I checked and I get the wrong results.
2. The second problem – I can not find a way to stop the loop if the program found one day when the condition is not met. (I’ve tried teaching BREAK in some variations, but without success)
The “a” variable should be incremented each time you find that your SMA>LMA condition is true, to get the days quantity of this condition to be valid in the past.
SMA and LMA variables should also been compared in the loop iteration, not at their actual values:
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue