DEFPARAM CUMULATEORDERS = FALSE
DEFPARAM FLATBEFORE = 080000
DEFPARAM FLATAFTER = 171500
ONCE NbBarLimit = 111
plushaut = HIGHEST[2](high)
plusbas = LOWEST[2](low)
IF TIME = 081000 THEN
MyCanal = (plushaut-plusbas)<(25*pipsize)
MylimitBuy = plushaut+1*pipsize
Mylimitsell = plusbas-1*pipsize
countbuy = 0
countsell = 0
lastindex = 0
MyIndex = barindex
ENDIF
IF Barindex >= Myindex + NbBarLimit THEN
MyLimitbuy = 0
MyLimitsell = 0
ENDIF
// Conditions pour ouvrir une position acheteuse
IF MylimitBuy AND Mycanal> 0 AND countbuy<1 THEN
BUY 1 contract AT MylimitBuy STOP
ENDIF
IF LOngonmarket and tradeindex<>lastindex then
countbuy = countbuy + 1
lastindex = tradeindex
endif
// Conditions pour ouvrir une position vendeuse
IF MylimitSell AND Mycanal > 0 THEN
SELLSHORT 1 contract AT Mylimitsell STOP
ENDIF
IF SHORTONMARKET AND TRADEINDEX<> lastindex then
countsell = countsell + 1
lastindex= barindex
endif
//STOP AND PROFIT
SET STOP LOSS SL
SET target PROFIT TP