Hi, I have written the program below for ProScreener:
Condition1 = Volume > 1000000
Period = 30
Condition2 = Close/Close[Period] > 1
HighestNegativePercentageDifference = 0
FOR i = Period DOWNTO 1 DO
FOR j = i DOWNTO 1 DO
IF Close[i] > Close[j-1] THEN
Percentage = (1-(Close[j-1]/Close[i]))*100
IF Percentage > HighestNegativePercentageDifference THEN
HighestNegativePercentageDifference = Percentage
ENDIF
ENDIF
NEXT
NEXT
PercentIncreaseOverPeriod = Close/Close[Period]
Ratio = PercentIncreaseOverPeriod/HighestNegativePercentageDifference
SCREENER[Condition1 AND Condition2](Ratio AS "Ratio")
I attached a screenshot of the error that appears. Could someone please assist me and let me know what am I doing wrong?
Thank you.
Nested FOR/NEXT loops are a nightmare for the proscreener engine to correctly compute. That’s why you get this error window, even if your code is looking ok.
You’ll have to find a solution with a SUMMATION of boolean conditions results for your second nested FOR/NEXT loop between line 8 to 15.