Hello,
I’m trying to figure out how to program a code in which the buy order takes place after an event that happens 3 times in the last 10 days.
The event is X in the following code:
MyRSI = rsi[9](Close)
RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < 30
if RsiMin then
RSIMin1 = MyRSI[1]
Low1 = Low[1]
for I = 3 to 80
if RSIMin[I] then
RSIMin2 = MyRSI[I + 1]
Low2 = Low[I + 1]
x= Low1 < Low2 and RSIMin1 > RSIMin2
endif
break
next
endif
Thanks in advance,
Assaf
There you go:
MyRSI = rsi[9](Close)
RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < 30
ONCE Count = 0
if RsiMin then
RSIMin1 = MyRSI[1]
Low1 = Low[1]
for I = 3 to 80
if RSIMin[I] then
RSIMin2 = MyRSI[I + 1]
Low2 = Low[I + 1]
x= Low1 < Low2 and RSIMin1 > RSIMin2
Count = Count + 1
endif
break
next
endif
check when COUNT reaches 3 and no more than 10 days have elapsed.
Actually I am not sure your code is fine. I fear that BREAK may affect Count in a wrong way.
Try it, but if it doesn’t work, add a better explanation of what it does and what you need.
Thank you. I think you are right about the BREAK thing, This is the corrected version of it:
MyRSI = rsi[9](Close)
RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < 30
ONCE Count = 0
if RsiMin then
RSIMin1 = MyRSI[1]
Low1 = Low[1]
for I = 3 to 80
if RSIMin[I] then
RSIMin2 = MyRSI[I + 1]
Low2 = Low[I + 1]
x= Low1 < Low2 and RSIMin1 > RSIMin2
Count = Count + 1
break
endif
next
endif
Can you please show me how to write a buying order that makes sure that all 3 events occur within 10 days?
Thanks again,
Assaf
There you go:
If summation[8](Count >= 3) Then