Bonsoir Ivan, merci. Malgré votre aide je n y parviens pas. pouvez vous aider encore ? Voici la stratégie en question :
//STRATEGIE CALL BOTTOM est une strategie d achat avec crosses under. TF strategie 5 min. TF indicateur 4h
DEFPARAM CumulateOrders = False // Une seule position à la fois
//TIMEFRAME(default) doit etre un TF4H
// Variables pour récupérer les 20 niveaux “clé” renvoyés par l’indicateur
Top1 = 0
Top2 = 0
Top3 = 0
Top4 = 0
Top5 = 0
Top6 = 0
Top7 = 0
Top8 = 0
Top9 = 0
Top10 = 0
Top11 = 0
Top12 = 0
Top13 = 0
Top14 = 0
Top15 = 0
Top16 = 0
Top17 = 0
Top18 = 0
Top19 = 0
Top20 = 0
TopCount = 0 // Nombre total de niveaux renvoyés par l’indicateur
// Appel de l’indicateur pour récupérer les niveaux “TOP”
Top1, Top2, Top3, Top4, Top5, Top6, Top7, Top8, Top9, Top10,Top11, Top12, Top13, Top14, Top15, Top16, Top17, Top18, Top19, Top20, TopCount = CALL “call BOTTOM”
//Doit etre en TF5min
// Vérification des croisements sous les niveaux “TOP”
IF TopCount > 0 THEN
// Parcours des 20 niveaux “TOP” pour détecter un croisement
IF close CROSSES UNDER Top1 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top2 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top3 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top4 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top5 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top6 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top7 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top8 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top9 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top10 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top11 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top12 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top13 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top14 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top15 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top16 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top17 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top18 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top19 THEN
buy 1 CONTRACT AT MARKET
ELSIF close CROSSES UNDER Top20 THEN
buy 1 CONTRACT AT MARKET
endif
endif
TIMEFRAME(default)
// Take Profit Logic with Trailing Stop and Two Partial Closures
SET TARGET pPROFIT 100
partialTakeProfit = 50 * pipsize // First TP level for partial closure
securedProfitAfterTP = 25 * pipsize // Second TP level to secure minimal profit
trailingstart = 55 // Trailing stop starts at 55 pips of profit
trailingstep =35 // Trailing stop moves by 35 pips increments
// Reset stoploss and partial closure indicators
IF NOT ONMARKET THEN
newSL = 0
isPartialProfitTaken = 0 // Indicator for first partial closure
entryPrice = 0 // Initial entry price
MAXPRICE = 0 // Reset maximum price reached
ENDIF
// Manage long positions
IF LONGONMARKET THEN
// Record initial entry price when position is opened
IF entryPrice = 0 THEN
entryPrice = tradeprice(1)
ENDIF
// Track maximum price reached since entry
MAXPRICE = MAX(MAXPRICE, close)
// First partial closure at 50 pips
IF isPartialProfitTaken = 0 AND close – entryPrice >= partialTakeProfit THEN
SELL 0.5 CONTRACT AT MARKET // Sell 0.5 contract
isPartialProfitTaken = 1 // Mark that the first partial closure has been taken
ENDIF
// Second partial closure to secure +2.5 pips profit
IF isPartialProfitTaken = 1 AND close <= entryPrice + securedProfitAfterTP THEN
SELL AT MARKET // Close remaining position at +2.5 pips profit
isPartialProfitTaken = 0 // Reset the indicator
ENDIF
// Trailing stop logic
// Start trailing stop at trailingstart pips of profit
IF newSL = 0 AND close – entryPrice >= trailingstart * pipsize THEN
newSL = entryPrice + trailingstep * pipsize // Set initial trailing stop level
ENDIF
// Move trailing stop up by trailingstep every time the price reaches a new profit level
IF newSL > 0 AND close – newSL >= trailingstep * pipsize THEN
newSL = newSL + trailingstep * pipsize
ENDIF
ENDIF
// Stop order to exit long position if trailing stop is hit
IF newSL > 0 THEN
SELL AT newSL STOP
ENDIF
//************************************************************************