DEFPARAM CumulateOrders = True
timeframe(default)
S1 = 23000
S2 = 21000
Res1 = 28000
c1 = (close <= S1)
o1 = (open >= S2)
IF c1 AND o1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
closeCon1 = (close >= Res1)
IF closeCon1 THEN
SELL AT MARKET
ENDIF
Dear All,
I’m trying a very simple code and I’m running in a little trouble.
I’d like to open the orders in the code just once a month while other positions are still open in previous months preventing the code to open multiple positions in the same month.
Your advice would be much appreciated.
Thank you
Try this (not tested):
DEFPARAM CumulateOrders = True
timeframe(default)
S1 = 23000
S2 = 21000
Res1 = 28000
If Month <> Month[1] then
m1 = 1
Endif
c1 = (close <= S1)
o1 = (open >= S2)
IF c1 AND o1 and m1 THEN
BUY 1 CONTRACT AT MARKET
m1 = 0
ENDIF
closeCon1 = (close >= Res1)
IF closeCon1 THEN
SELL AT MARKET
ENDIF
Roberto,
it worked beautifully
Thank you very much for your help.
Renzo