Hi everyone
I have a small question about screener optimization, I want to use this code, so I need only the last 20 bar, so I use the IF condition with BarIndex > 1000 (because on the screener I saw he use the last 1024 bar)
the question is : about the variable (MM10 & MM20) I have to declare them inside the condition or outside? Does it change anything about the optimization?
MM10 = Average[10](Close)
MM20 = Average[20](Close)
C1 = MM10 Crosses Over MM20
IF BarIndex > 1000 Then
For x = 0 To 5 Do
IF C1[x] Then
test = 1
Y = x
Break
ELSE
test = 0
ENDIF
Next
ENDIF
SCREENER[test](Y AS "N")
Best Reguards
I tried this indicator and it seems to be working fine as is, without moving the two SMAs inside IF..ENDIF:
MM10 = Average[10](Close)
MM20 = Average[20](Close)
C1 = MM10 Crosses Over MM20
y = 0
IF BarIndex > 1000 Then
For x = 0 To 5 Do
IF C1[x] Then
test = 1
Y = x
Break
ELSE
test = 0
ENDIF
Next
ENDIF
RETURN Y//Test
tks you @robertogozzi, so it doesn’t matter where I declare them
Right, provided these lines are always in this same order:
MM10 = Average[10](Close)
MM20 = Average[20](Close)
C1 = MM10 Crosses Over MM20