DEFPARAM CUMULATEORDERS = FALSE
TIMEFRAME(1 hour)
MAFastH1 = HullAverage[5](close)
MASlowH1 = HullAverage[13](close)
TIMEFRAME(DEFAULT)
MAFastM5 = HullAverage[8](close)
MASlowM5 = HullAverage[21](close)
StoK = Stochastic[8,3](close)
StoD = Stochasticd[8,3,5](close)
////////////
long=0
short=0
if stok>50 and stok<stok[1] and stok<stod and MAFastM5<MASlowM5 and MAFastH1<MASlowH1 then
short=-1
endif
if stok<50 and stok>stok[1] and stok>stod and MAFastM5>MASlowM5 and MAFastH1>MASlowH1 then
long=+1
endif
// Conditions pour ouvrir une position acheteuse
IF NOT LongOnMarket AND long=+1 THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
// Conditions pour fermer une position acheteuse
If LongOnMarket AND (short=-1 or (stok[1]<stok and stok[1]<stok[2])) THEN
SELL AT MARKET
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Conditions pour ouvrir une position en vente à découvert
IF NOT ShortOnMarket AND short=-1 THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
// Conditions pour fermer une position en vente à découvert
IF ShortOnMarket AND (long=+1 or (stok[1]>stok and stok[1]>stok[2])) THEN
EXITSHORT AT MARKET
BUY 1 CONTRACTS AT MARKET
ENDIF
// Stops et objectifs : entrez vos stops et vos objectifs ici
SET STOP %LOSS 1
///2 BREAKEAVEN///////////
once breakeaven = 1//1 on - 0 off
startBreakeven = 35 //how much pips/points in gain to activate the breakeven function?
PointsToKeep = 5 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
///2///////////////////////////////////////////////
//reset the breakevenLevel when no trade are on market
if breakeaven>0 then
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
// --- BUY SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF LONGONMARKET AND close-tradeprice>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice+PointsToKeep*pipsize
ENDIF
//plce the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
ENDIF
// --- end of BUY SIDE ---
IF SHORTONMARKET AND tradeprice-close>startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice-PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
EXITSHORT AT breakevenLevel STOP
ENDIF
endif
GRAPHONPRICE breakevenLevel coloured(0,0,255,255)