// ACCUMULATION D'ORDRE et PRE CHARGEMENT du Bot------------------------------------------------------------
DEFPARAM CumulateOrders = false
DEFPARAM Preloadbars = 3000
// STRATEGY PROFITS-----------------------------------------------------------------------------------------
IF init=not onmarket THEN
step=0
init=1
ENDIF
SL = 138
TP = 185
UNDERLAYING = 100
REINV = 1
LotDeBase = 1
// INDICATEUR-----------------------------------------------------------------------------------------------
condbuy = Volume > 700 and volume[1] < volume and time > 153000 and time < 210000 and open < close and average[75](close) > average[30](close)
// POSITION ------------------------------------------------------------------------------------------------
IF CONDbuy THEN
buy LotDeBase contract at market
ENDIF
// TRAILING STOP CONDITION----------------------------------------------------------------------------------
TGL0 = 65
IF not onmarket THEN
MAXPRICE = 0
PRICEXIT = 0
ENDIF
IF longonmarket THEN
MAXPRICE = MAX(MAXPRICE,close)
IF MAXPRICE - tradeprice(1) >= TGL0 * pointsize THEN
PRICEXIT = MAXPRICE - TGL0 * pointsize
ENDIF
ENDIF
IF onmarket and PRICEXIT>0 THEN
SELL at PRICEXIT STOP
ENDIF
// STOP LOSS CONDITION--------------------------------------------------------------------------------------
IF not onmarket THEN
sloss = 0
ELSIF longonmarket THEN
sloss = tradeprice(1) - ((tradeprice(1) * SL) / underlaying) * pointsize
ELSIF shortonmarket THEN
sloss = tradeprice(1) + ((tradeprice(1) * SL) / underlaying) * pointsize
ENDIF
SET STOP pLOSS SL
IF not onmarket THEN
ptarget = 0
ELSIF longonmarket THEN
ptarget = tradeprice(1) + ((tradeprice(1) * TP) / underlaying) * pointsize
ELSIF shortonmarket THEN
ptarget = tradeprice(1) - ((tradeprice(1) * TP) / underlaying) * pointsize
ENDIF
SET TARGET pPROFIT TP
// BREAKEVEN------------------------------------------------------------------------------------------------
startBreakeven0 = 28
PointsToKeep0 = 7
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
// BE FOR LONG---------------------------------------------------------------------------------------------
IF longonmarket and close - tradeprice(1) >= StartBreakeven0 * pipsize THEN
BreakevenLevel = tradeprice(1) + PointsToKeep0 * pipsize
ENDIF
IF breakevenLevel>0 THEN
sell AT breakevenLevel STOP
ENDIF
if longonmarket and close - tradeprice(1) >= 50*pipsize and step = 0 Then
step = 1
endif
IF step = 1 THEN
sell 0.1 contracts at market
step = 2
endif
// END------------------------------------------------------------------------------------------------------