//-------------------------------------------------------------------------
// Code principal : ALgo + dax m1
//-------------------------------------------------------------------------
// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
ONCE TK = 9.0
ONCE BE = 13.0
ONCE c = 14.0
ONCE l = 3.0
SET STOP %LOSS 0.5
timeEnterBefore = time >= 083000
timeEnterAfter = time <= 170000
startBreakeven = BE //how much pips/points in gain to activate the breakeven function?
PointsToKeep = TK //how much pips/points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
//exit long order on red candle (if breakeven is set)
if longonmarket and close<open and breakevenLevel>0 then
sell at market
endif
//exit short order on green candle (if breakeven is set)
if shortonmarket and close>open and breakevenLevel>0 then
exitshort at market
endif
// Conditions pour ouvrir une position acheteuse
indicator1 = ExponentialAverage[c](close)
indicator2 = Average[l](close)
c1 = (indicator1 CROSSES OVER indicator2)
indicator3 = RSI[5](close)
c2 = (indicator3 > 50)
indicator4 = MACD[5,8,9](close)
c3 = (indicator4 > 0)
IF c1 AND c2 AND c3 THEN
BUY 1 SHARES AT MARKET
ENDIF
// Conditions pour ouvrir une position en vente à découvert
indicator6 = ExponentialAverage[c](close)
indicator7 = Average[l](close)
c5 = (indicator6 CROSSES UNDER indicator7)
indicator8 = RSI[5](close)
c6 = (indicator8 < 50)
indicator9 = MACD[5,8,9](close)
c7 = (indicator9 < 0)
IF c5 AND c6 AND c7 THEN
SELLSHORT 1 SHARES AT MARKET
ENDIF
//reset the breakevenLevel when no trade are on market
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(1)>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
ENDIF
// --- end of BUY SIDE ---
// --- SELL SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF SHORTONMARKET AND tradeprice(1)-close>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
EXITSHORT AT breakevenLevel STOP
ENDIF
// --- end of SELL SIDE ---