Rejoindre la communauté
banner_forum
Devenez membre de la plus grande
communauté francophone sur le Forex
Partagez, échangez et apprenez en gagnant des crédits sur votre compte de trading

Comment éviter une consolidation en prog.. mql4 ?

  • arka3579

    Bonsoir.
    Je cherche un indicateur ou combo de 2 indicateurs.. a voir..
    Bref ; Une solution en programmation "mt4" qui me permettrait d'éviter l 'ouverture de position en zone de consolidation.
    Un filtre 100% trend en clair.

    Voir image.
    Réponse ici ou privé.
    Merci par avance pour vos lumières.

    Je demande pas qu 'on écrive les lignes de codes..
    Je demande le nom d 'un indicateur permettant d'éviter l'ouverture de positions en périodes de ranges/consolidations.

    aRka.
    arka3579 a joint une image
    comment-eviter-une-consolidation-en-prog-mql4-13745
  • Mikiburger

    ichimoku ?
  • arka3579 — en réponse à Mikiburger dans son message #125637

    Le Twist permet de savoir a l'avance qu un range se prépare oui.
    Mais en programmation mql4 ? on combinerai cela comment ?
  • Mikiburger

    Bloquer le robot après un twist pour un certain temps ou jusqu'au feu vert d'un autre signal ?
  • arka3579 — en réponse à Mikiburger dans son message #125639

    Ca m'a traversé l esprit, j aime l'idée.
    Si envisageable, alors j aurai bien imaginé effectivement, un arrêt du EA si Twist présent.
    Et bloquer pendant X bougies suivante.
    (Il suffirait de faire la moyenne d'une consolidation après Twist sur le marché concerné)

    cela dit j suis incapable décrire ces lignes, "on va oublier".

    Je vais cherché ^^
  • arka3579

    Je recherche des lignes de codes pour ouverture de position facon TURTLE (BreakOut) pour mon EXPERT ADVISOR.
    Merci pour vos liens ou code proposés.
  • arka3579

    Voici le code d un indicateur comme je recherchais.

    Code
    //+------------------------------------------------------------------+ //| TheClassicTurtleTrader.mq4 //| Copyright © Pointzero-indicator.com //+------------------------------------------------------------------+ #property copyright "Copyright © Pointzero-indicator.com" #property link "http://www.pointzero-indicator.com" //---- indicator settings #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 DodgerBlue #property indicator_color2 Red #property indicator_color3 DodgerBlue #property indicator_color4 Red #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 3 #property indicator_width4 3 #property indicator_style1 STYLE_DOT #property indicator_style2 STYLE_DOT //---- constants to know if we are in or out of the market #define IN_THE_MARKET 0 #define OUT_OF_MARKET 1 //---- indicator parameters extern int TradePeriod = 20; // Donchian channel period for trading signals extern int StopPeriod = 10; // Donchian channel period for exit signals extern bool StrictEntry = false; // Apply strict entry parameters like the Turtles did extern bool StrictExit = false; // Apply strict exit parameters like the Turtles did extern bool StrictStop = false; // Apply strict stop-loss like the turtled did extern bool Greedy = false; // Do not exit a trade unless it is in profit or the SL is hit extern bool EvaluateStoploss = true; // Check if we have been stopped out and show future signals extern int ATRPeriod = 20; // ATRPeriod to set the stop-loss extern double ATRStopNumber = 2; // N.Factor to calculate the stop-loss extern bool DisplayAlerts = false; // You know... //---- indicator buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double LongInfo[]; double ShortInfo[]; double TrendDirection[]; //---- alerts static datetime TimeStamp; static int AlertCount = 1; //---- internal double long_price; double short_price; double long_stop; double short_stop; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { // Three more buffers to store long/short trading info and trend IndicatorBuffers(7); // Drawing settings SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0, 233); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1, 234); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,159); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,159); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); // Name and labels IndicatorShortName("The Classic Turtle Trader ("+ TradePeriod +"-"+ StopPeriod +")"); SetIndexLabel(0,"Buy breakout "+ TradePeriod); SetIndexLabel(1,"Sell breakout "+ TradePeriod); SetIndexLabel(2,"Exit longs "+ StopPeriod); SetIndexLabel(3,"Exit shorts "+ StopPeriod); // Buffers SetIndexBuffer(0,ExtMapBuffer1); SetIndexBuffer(1,ExtMapBuffer2); SetIndexBuffer(2,ExtMapBuffer3); SetIndexBuffer(3,ExtMapBuffer4); SetIndexBuffer(4,LongInfo); SetIndexBuffer(5,ShortInfo); SetIndexBuffer(6,TrendDirection); Comment("Copyright © http://www.pointzero-indicator.com"); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { // More vars here too... int start = 0; int limit; int counted_bars = IndicatorCounted(); // check for possible errors if(counted_bars < 0) return(-1); // Only check these limit = Bars - 1 - counted_bars; if(counted_bars==0) limit-=1+1; // Check the signal foreach bar for(int i = limit; i >= start; i--) { // Highs and lows double rhigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, TradePeriod,i+1)); double rlow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, TradePeriod, i+1)); double shigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, StopPeriod,i+1)); double slow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, StopPeriod, i+1)); // Candle value double CLOSE = iClose(Symbol(),0, i); double HIGH = iHigh(Symbol(),0, i); double LOW = iLow(Symbol(),0, i); // Stop-losses if we traded here double ATRv = iATR(Symbol(), 0, ATRPeriod, i) * ATRStopNumber; double ATRup = CLOSE + ATRv; double ATRlow = CLOSE - ATRv; // Respect old trend LongInfo[i] = LongInfo[i+1]; ShortInfo[i] = ShortInfo[i+1]; TrendDirection[i] = TrendDirection[i+1]; // It might be recalculating bar zero ExtMapBuffer1[i] = EMPTY_VALUE; ExtMapBuffer2[i] = EMPTY_VALUE; ExtMapBuffer3[i] = EMPTY_VALUE; ExtMapBuffer4[i] = EMPTY_VALUE; // // 1) Check for exits // // Exit longs taking into account strict exits and the greedy mode // Loose mode only applies after the bar has closed if(((CLOSE < slow && i > 0) && (CLOSE > long_price || Greedy == false)) || (LOW < slow && StrictExit == true && (LOW > long_price || Greedy == false)) && LongInfo[i] == IN_THE_MARKET) { LongInfo[i] = OUT_OF_MARKET; ExtMapBuffer3[i] = LOW; } // Exit shorts taking into account strict exits and the greedy mode // Loose mode only applies after the bar has closed if(((CLOSE > shigh && i > 0) && (CLOSE < short_price || Greedy == false)) || (HIGH > shigh && StrictExit == true && (HIGH < short_price || Greedy == false)) && ShortInfo[i] == IN_THE_MARKET) { ShortInfo[i] = OUT_OF_MARKET; ExtMapBuffer4[i] = HIGH; } // // 2) Check for stoploss hits // // Exit longs taking into account strict stoploss // Loose mode only applies after the bar has closed if(((CLOSE < long_stop && i > 0) || (LOW < long_stop && StrictStop == true)) && LongInfo[i] == IN_THE_MARKET && EvaluateStoploss == true) { LongInfo[i] = OUT_OF_MARKET; ExtMapBuffer3[i] = LOW; } // Exit shorts taking into account strict stoploss // Loose mode only applies after the bar has closed if(((CLOSE > short_stop && i > 0) || (HIGH > short_stop && StrictStop == true)) && ShortInfo[i] == IN_THE_MARKET && EvaluateStoploss == true) { ShortInfo[i] = OUT_OF_MARKET; ExtMapBuffer4[i] = HIGH; } // // 3) Check for entries // // Enter long trade taking into account strict entries // Loose mode only applies after the bar has closed if(((CLOSE > rhigh && i > 0) || (HIGH > rhigh && StrictEntry == true)) && LongInfo[i] == OUT_OF_MARKET) { TrendDirection[i] = OP_BUY; LongInfo[i] = IN_THE_MARKET; ExtMapBuffer1[i] = LOW; long_stop = ATRlow; long_price = CLOSE; } // Enter short trade taking into account strict entries if(((CLOSE < rlow && i > 0) || (LOW < rlow && StrictEntry == true)) && ShortInfo[i] == OUT_OF_MARKET) { TrendDirection[i] = OP_SELL; ShortInfo[i] = IN_THE_MARKET; ExtMapBuffer2[i] = HIGH; short_stop = ATRup; short_price = CLOSE; } } // Alerts if(TimeStamp != Time[0] && DisplayAlerts == true) { // Exit signals if(LongInfo[1] == OUT_OF_MARKET && LongInfo[2] == IN_THE_MARKET && AlertCount == 0) { Alert("[Classic Turtle Trader "+ TradePeriod +"-"+ StopPeriod +"]["+ Symbol() +"] Close longs"); } else if (ShortInfo[1] == OUT_OF_MARKET && ShortInfo[2] == IN_THE_MARKET && AlertCount == 0) { Alert("[Classic Turtle Trader "+ TradePeriod +"-"+ StopPeriod +"]["+ Symbol() +"] Close shorts"); } // Enter signals if(LongInfo[1] == IN_THE_MARKET && LongInfo[2] == OUT_OF_MARKET && AlertCount == 0) { Alert("[Classic Turtle Trader "+ TradePeriod +"-"+ StopPeriod +"]["+ Symbol() +"] BUY"); } else if (ShortInfo[1] == IN_THE_MARKET && ShortInfo[2] == OUT_OF_MARKET && AlertCount == 0) { Alert("[Classic Turtle Trader "+ TradePeriod +"-"+ StopPeriod +"]["+ Symbol() +"] SELL"); } TimeStamp = Time[0]; AlertCount = 0; } // Bye Bye return(0); }
  • ProgTrading

    Bonjour,

    1ere solution: à partir du moment où une seule ligne ichimoku est plate, le prix est en range. Voici un simple code qui renverra "hausse" si le prix accélère car les lignes ichimoku sont orientées à la hausse, ou "baisse" si les lignes baissent ou "nul" si on est en range:
    Code
    //Détection d'une accélération ichimoku string IchimokuAcceleration(string symbole, int temps, int shift) { double tenkan = iIchimoku(symbole,temps,9,26,52,MODE_TENKANSEN,shift); double kijun = iIchimoku(symbole,temps,9,26,52,MODE_KIJUNSEN,shift); double ssa = iIchimoku(symbole,temps,9,26,52,MODE_SENKOUSPANA,shift-26); double ssb = iIchimoku(symbole,temps,9,26,52,MODE_SENKOUSPANB,shift-26); double tenkan1 = iIchimoku(symbole,temps,9,26,52,MODE_TENKANSEN,shift+1); double kijun1 = iIchimoku(symbole,temps,9,26,52,MODE_KIJUNSEN,shift+1); double ssa1 = iIchimoku(symbole,temps,9,26,52,MODE_SENKOUSPANA,shift-26+1); double ssb1 = iIchimoku(symbole,temps,9,26,52,MODE_SENKOUSPANB,shift-26+1); if ((tenkan > tenkan1) && (kijun > kijun1) && (ssa > ssa1) && (ssb > ssb1)) { return "hausse"; } else if ((tenkan < tenkan1) && (kijun < kijun1) && (ssa < ssa1) && (ssb < ssb1)) { return "baisse"; } else { return "nul"; } }
    donc pour ton cas si ça renvoie "nul" t'es en range. Tu peux l'utiliser sur des TimeFrames supérieurs pour ajuster ta stratégie.

    2nde solution: Détecter un range à l'aide de iHighest et iLowest en appliquant un pourcentage et en comparant à x périodes en arrière.
    Modifié le 2022-01-15 14:44:32 par ProgTrading
  • arka3579 — en réponse à ProgTrading dans son message #125665

    Merci pour ces kkes lignes de code, je vais regarder cela.
  • arka3579 — en réponse à ProgTrading dans son message #125665

    Concernant la 2nd solution pouvez vous me proposer une ligne de code mettant en avant l histoire du pourcentage.
    Remerciement.
  • ProgTrading

    bonjour, www.progtrading.fr