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

Partenariat BACKTESTING Avec ce Robot..

  • arka3579

    Bonjour ;
    L'objectif est de faire le Point ensemble pour définir 1 seul marché et son unité de temps unique avec ce Robot.
    Plus de gens participeront aux BackTest avec leur broker, plus le résultat final sera valable.

    Avantage certain pour vous ? Ce Robot est déjà a vous ! (Cadeau)


    Condition 1 : 500 € de capital pour tout le monde.
    Condition 2 : Ne rien changer sur le robot (réglages)
    Condition 3 : Trouver le marché le plus performant chez vous et préciser son unité de temps.
    Condition 4 : Partager votre meilleur résultat (tout simplement)

    Voici le Robot : Si vous savez pas compiler, je vous l envoie par eMail (Venir me voir en privé)

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ input int Magic = 1; extern int ATR_Period = 24; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; input double Lots = 35; extern string __2 = "|||||||||| SL/TP & TRAILING STOP ||||||||||"; extern double TP_ATR = 789 ; extern double SL_ATR = 2.7; extern double TS_ATR = 2.7; //------------------ double slb,tpb,sls,tps,pt; double last_profit, last_lot; int last_tip; int last_bar = 0; // My TrailingStop void Trailingstop() { for(int i=OrdersTotal()-1; i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) if(OrderMagicNumber()==Magic) if(OrderType()==OP_BUY) { if(Ask-OrderOpenPrice()>+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) if(OrderStopLoss()<Ask-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) int TBM=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR,OrderTakeProfit(),0,clrNONE); } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Bid>-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) if(OrderStopLoss()>Bid+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) int TSM=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR,OrderTakeProfit(),0,clrNONE); } } } //| Calculate open positions int CalculateCurrentOrders(string symbol) { int buys=0,sells=0; //--- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++; } } //--- return orders volume if(buys>0) return(buys); else return(-sells); } //| Check for open order conditions void CheckForOpen() { int res; if(Volume[0]>1) return; if(SL_ATR==0)slb=0;else slb=Close[0]-iATR(NULL,PERIOD_CURRENT,17,0)*SL_ATR; if(SL_ATR==0)sls=0;else sls=Close[0]+iATR(NULL,PERIOD_CURRENT,17,0)*SL_ATR; if(TP_ATR==0)tpb=0;else tpb=Close[0]+iATR(NULL,PERIOD_CURRENT,17,0)*TP_ATR; if(TP_ATR==0)tps=0;else tps=Close[0]-iATR(NULL,PERIOD_CURRENT,17,0)*TP_ATR; double ssA=iIchimoku(NULL, 0,9,26,52, MODE_SENKOUSPANA,0); double ssB=iIchimoku(NULL, 0,9,26,52, MODE_SENKOUSPANB,0); double rhigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, 23,1+1)); double rlow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, 23, 1+1)); // Candle value double CLOSE = iClose(Symbol(),0, 1); double HIGH = iHigh(Symbol(),0, 1); double LOW = iLow(Symbol(),0, 1); //--- SELL conditions if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1)<iBands(NULL,PERIOD_CURRENT,128,1,0,PRICE_OPEN,MODE_LOWER,1)) if(((CLOSE < rlow && 1 > 0) || (LOW < rlow))) if(Open[1]<ssA && Open[1]<ssB) { res=OrderSend(Symbol(),OP_SELL,(AccountEquity() * 0.001 /Lots),Bid,3,sls,tps,"Sell",Magic,0,Red); return; } //--- BUY conditions if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1)>iBands(NULL,PERIOD_CURRENT,128,1,0,PRICE_OPEN,MODE_UPPER,1)) if(((CLOSE > rhigh && 1 > 0) || (HIGH > rhigh))) if(Open[1]>ssA && Open[1]>ssB) { res=OrderSend(Symbol(),OP_BUY,(AccountEquity() * 0.001 /Lots),Ask,3,slb,tpb,"Buy",Magic,0,Blue); return; } } //| OnTick function void OnTick() { //--- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; //--- calculate open orders by current symbol if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); else Trailingstop(); }


    Merci pour votre participation ! Ensemble..
    GAGNONS !

    Yo' (aRka)
  • arka3579

    Si vous participer, un p'tit mot, ou juste un Ok.. Pour motiver les troupes !
  • arka3579

    Pas de graph M1 tant que je j'y pense. C 'est pas rentable.
    Je vous invite a vous concentrer sur le M5 - M15 - M30 - H4
  • arka3579

    Voici mon rapport. Vous pouvez partir de cette base sur vos test. (Prix d'ouverture seulement)

    Ces résultats représentent des courbes assez régulières et haussières (d'une)
    Si plusieurs courbes sont propre alors je sélectionne par le facteur de profit.

    INDICE MIS EN TEST :
    CAC40 - US500 - US100 - JP225 - RUSS2K - HONGKONG - ESP35 - DOW.J - DAX40

    Meilleur M5 : JP225 (Nikkei)
    Meilleur M15 : JP225 (Nikkei)
    Meilleur M30 : DAX40 (Allemagne)
    Meilleur H1 : DAX40 (Allemagne)
    Meilleur H4 : US500 (Sp500)

    MATIERE MIS EN TEST :
    BRENT & Gold

    Meilleur M15 : BRENT
    Meilleur H1 : GOLD
    Meilleur H4 : BRENT

    FOREX MIS EN TEST :
    EUR/USD - GBP/USD - GBP/JPY - USD/CAD

    Meilleur M30 : GBP/JPY
    Meilleur H1 : USD/CAD
  • arka3579

    A tester également :
    Systeme GRID; Ouverture par BreakOut facon Turtle + Bollinger Bands.

    Code
    //+------------------------------------------------------------------+ //| aRka3579 / By WidiPramana | //+------------------------------------------------------------------+ #property copyright "23 JANV 2021" input string IndicatorName="My EA HEDGE/GRID%"; enum ENUM_HOUR { h00=00, //00:00 h01=01, //01:00 h02=02, //02:00 h03=03, //03:00 h04=04, //04:00 h05=05, //05:00 h06=06, //06:00 h07=07, //07:00 h08=08, //08:00 h09=09, //08:00 h10=10, //10:00 h11=11, //11:00 h12=12, //12:00 h13=13, //13:00 h14=14, //14:00 h15=15, //15:00 h16=16, //16:00 h17=17, //17:00 h18=18, //18:00 h19=19, //19:00 h20=20, //20:00 h21=21, //21:00 h22=22, //22:00 h23=23, //23:00 }; //+-----------+ extern bool Power_ON = true; extern int Magic = 1; extern int ATR_Period = 24; extern string MM = "|||||||||| MONEY MANAGEMENT ||||||||||"; input double Lots = 24; extern int Martingale_X = 2; extern bool TakeProfit_ON = true; extern double TP_ATR = 222; extern double SL_ATR = 4.4; extern bool TrailingStop_ = true; extern double TS_ATR = 2.2 ; extern string DC = "|||||||||| DONCHIAN ||||||||||"; extern int Bk = 13; extern string BOL = "|||||||||| BOLLINGER-B ||||||||||"; input int BB_period = 75; input double BB_deviation = 0.2; extern string DT = "|||||||||| DAY Settings ||||||||||"; extern bool Monday = true; extern bool Tuesday = true; extern bool Wednesday = true; extern bool Thursday = true; extern bool Friday = true; extern bool Sunday = false; extern string TIME_setting = "|||||||||| TIME Settings ||||||||||"; extern bool UseTimer = false; // Use start & end times in Hours input ENUM_HOUR StartHour = h06; // Start operation hour input ENUM_HOUR EndHour = h22; // Last operation hour input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; extern int MaxLots = 5; extern string Info1 = "|| LOT 39 = Soft ||"; extern string Info2 = "|| MARTINGALE 1 = Off ||"; extern string Info3 = "|| TP_ATR 999 = Off ||"; //Variables GLOBALS datetime CurrentTime; int ras,wt,wk,ticketb,tickets,last_tip,OrderOpRetry=5; double slb,tpb,sls,tps,pt,last_profit, last_lot, profitnow,profit; bool clear; //Day Global bool DaytoTrade(){ bool daytotrade = false; if(DayOfWeek() == 0 && Sunday) daytotrade = true; if(DayOfWeek() == 1 && Monday) daytotrade = true; if(DayOfWeek() == 2 && Tuesday) daytotrade = true; if(DayOfWeek() == 3 && Wednesday) daytotrade = true; if(DayOfWeek() == 4 && Thursday) daytotrade = true; if(DayOfWeek() == 5 && Friday) daytotrade = true; return(daytotrade);} //on/off TRADING bool EAon(){ bool eaon = false; if(Power_ON) eaon = true; return(eaon);} bool TakeP(){ bool takeP = false; if(DayOfWeek() == 5 && TakeProfit_ON) takeP = true; return(takeP);} //+-----------+ int start() { // Martingale (1 = Off) double Lot = (AccountEquity() * 0.001 /Lots); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot = (AccountEquity() * 0.001 /Lots); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot = Martingale_X*last_lot; if( last_profit > 0 ) Lot = (AccountEquity() * 0.001 /Lots); string ls_01 = " Levier: " + AccountLeverage() + "\n" + "\n" + " Heure du Server: " + TimeToStr(TimeCurrent(), TIME_SECONDS) + "\n" + " Heure Locale: " + TimeToStr(TimeLocal(), TIME_SECONDS) + "\n"; string ls_02 = "-------------------------------------\n"+"\n"; int Spread; Spread=SymbolInfoInteger(Symbol(),SYMBOL_SPREAD); string ls_03 = (StringFormat(" Spread = %d", Spread)); string ls_04 = "\n" + "\n"; string ls_05 = "-------------------------------------\n"; string profitstr = DoubleToStr(profitnow,2); string ls_06 = "\n" + "\n"; string ls_07 = " Solde : " + AccountBalance() + "\n"; string ls_08 = " Equity : " + AccountEquity() + "\n"; string ls_09 = " Profits : " + AccountProfit() + "\n"; Comment( ls_01 + ls_02 + ls_03 + ls_04 + ls_05 + ls_06 + ls_07 + ls_08 + ls_09 ); // Trading HOURS if(UseTimer == true) { CurrentTime = TimeLocal(); int GetWeekday = TimeDayOfWeek(CurrentTime); int GetHour = TimeHour(CurrentTime); int GetMinute = TimeMinute(CurrentTime); if(GetHour >= StartHour && GetHour <= EndHour && GetWeekday <6) { bool TradeAllowed = true; } else TradeAllowed = false; } else TradeAllowed = true; //+-----------+ if(Volume[0]>1) return; if(TrailingStop_)dtrailing(); // SL & TP if(SL_ATR==0)slb=0;else slb=Close[0]-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*SL_ATR; if(SL_ATR==0)sls=0;else sls=Close[0]+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*SL_ATR; if(TP_ATR==0)tpb=0;else tpb=Close[0]+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TP_ATR; if(TP_ATR==0)tps=0;else tps=Close[0]-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TP_ATR; // List DOUBLE double rhigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, Bk,1+1)); double rlow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, Bk, 1+1)); // Candle value double CLOSE = iClose(Symbol(),0, 1); double HIGH = iHigh(Symbol(),0, 1); double LOW = iLow(Symbol(),0, 1); int res; //--- SELL conditions if(((CLOSE < rlow && 1 > 0) || (LOW < rlow))) if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) < iBands(NULL,PERIOD_CURRENT,BB_period,BB_deviation,0,PRICE_OPEN,MODE_LOWER,1)) { if(totalorder(0) < MaxLots && EAon() && DaytoTrade() && TakeP() && TradeAllowed == true) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); return; } //--- BUY conditions if(((CLOSE > rhigh && 1 > 0) || (HIGH > rhigh))) if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) > iBands(NULL,PERIOD_CURRENT,BB_period,BB_deviation,0,PRICE_OPEN,MODE_UPPER,1)) { if(totalorder(0) < MaxLots && EAon() && DaytoTrade() && TakeP() && TradeAllowed == true) res=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); return; } } //+-----------+ int totalorder(int tipe) { int total=0; for(int i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=tipe) continue; total++; } return(total); } //+-----------+ void dtrailing() { int i,r;double tpn; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; tpn=OrderTakeProfit(); if(OrderType()==OP_BUY) { if(Bid-OrderOpenPrice()>iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) { if((OrderStopLoss()<Bid-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR,OrderTakeProfit(),0,Green); } } } if(OrderType()==OP_SELL) { if((OrderOpenPrice()-Ask)>(iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR)) { if(OrderStopLoss()>(Ask+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR,OrderTakeProfit(),0,Red); } } } } } //+-----------+ void closeall() { for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; if(OrderType()>1) ras=OrderDelete(OrderTicket()); else { if(OrderType()==0) ras=OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE); else ras=OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE); } } } //+----------+ // Martingale //+----------+ double last_history_profit() { double cpte_profit = 0; //int Magik_No = -1; if( OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) ) { if( OrderMagicNumber() == Magic ) { last_profit = OrderProfit(); last_lot = OrderLots(); last_tip = OrderType(); } } return(0); }
  • Mikiburger

    Bonjour Yohan,
    j'ai rapidement testé le deuxième robot mais je n'arrive as à quelque chose de rentable.
  • arka3579 — en réponse à Mikiburger dans son message #125698

    A voir si c est une question de réglages ou le système dans son global qui est mauvais.
    Je pense que le choix du STEP Du trailling stop est très important, selon le marché.
    L ouverture Bk facon Turtle + Bollinger B me parait etre intéressent malgré tout, comme duo d'ouverture.
    Enfin j ai pu constaté que dans ce systeme trop de lignes (maxlot) tuait le système.
    Et cerise sur le gâteau avec ou sans Martingale ?! Tel est la question !
  • Haithemfx06

    arka3579, le 24/01/2022 dit :
    A voir si c est une question de réglages ou le système dans son global qui est mauvais. Je pense que le choix du STEP Du trailling stop est très important, selon le marché. L ouverture Bk facon Turtle + Bollinger B me parait etre intéressent malgré tout, comme duo d'ouverture. Enfin j ai pu constaté que dans ce systeme trop de lignes (maxlot) tuait le système. Et cerise sur le gâteau avec ou sans Martingale ?! Tel est la question !


    trader en Grid c'est plus du money management que réglage du Robot
    il faut équilibrer entre profit et gestion du risque
  • arka3579 — en réponse à Haithemfx06 dans son message #125700

    Merci pour ces infos complémentaires.
  • cohenhugo21 — en réponse à arka3579 dans son message #125696

    une simple question a tu backtesté ce robot
  • arka3579 — en réponse à cohenhugo21 dans son message #125789

    Je test tjrs au minimum sur le CAC40 en M15. Mais avec les données du broker.
    Donc oui.
    Je rappel que je ne propose pas de rabot qui génère du capital.
    Je propose des lignes de code pour vous aider a faire comme moi, évoluer, avancer, composer votre E.A.
  • lefeuvr3

    Programme très interressant sur lequel il faut se pencher.
    En rajoutant #property strict ,qui a mon humble avis doit faire parti de tout programme quelques Warnings et Erreurs apparaissent .
    Je pense les avoir corriges.
    La base me semble excellente ... il faudrait simplifier un peu et revoir legerement la strategie...Felicitations pour ce travail

    Code
    //+------------------------------------------------------------------+ //| Arka3579.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| aRka3579 / By WidiPramana | //+------------------------------------------------------------------+ #property copyright "23 JANV 2021" #property strict #property version "2.00" input string IndicatorName="My EA HEDGE/GRID%"; enum ENUM_HOUR { h00=00, //00:00 h01=01, //01:00 h02=02, //02:00 h03=03, //03:00 h04=04, //04:00 h05=05, //05:00 h06=06, //06:00 h07=07, //07:00 h08=08, //08:00 h09=09, //08:00 h10=10, //10:00 h11=11, //11:00 h12=12, //12:00 h13=13, //13:00 h14=14, //14:00 h15=15, //15:00 h16=16, //16:00 h17=17, //17:00 h18=18, //18:00 h19=19, //19:00 h20=20, //20:00 h21=21, //21:00 h22=22, //22:00 h23=23, //23:00 }; //+-----------+ extern bool TradeAllowed=true; extern bool Power_ON = true; extern int Magic = 1; extern int ATR_Period = 24; extern string MM = "|||||||||| MONEY MANAGEMENT ||||||||||"; input double Lots = 24; extern int Martingale_X = 2; extern bool TakeProfit_ON = true; extern double TP_ATR = 222; extern double SL_ATR = 4.4; extern bool TrailingStop_ = true; extern double TS_ATR = 2.2 ; extern string DC = "|||||||||| DONCHIAN ||||||||||"; extern int Bk = 13; extern string BOL = "|||||||||| BOLLINGER-B ||||||||||"; input int BB_period = 75; input double BB_deviation = 0.2; extern string DT = "|||||||||| DAY Settings ||||||||||"; extern bool Monday = true; extern bool Tuesday = true; extern bool Wednesday = true; extern bool Thursday = true; extern bool Friday = true; extern bool Sunday = false; extern string TIME_setting = "|||||||||| TIME Settings ||||||||||"; extern bool UseTimer = false; // Use start & end times in Hours input ENUM_HOUR StartHour = h06; // Start operation hour input ENUM_HOUR EndHour = h22; // Last operation hour input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; extern int MaxLots = 5; extern string Info1 = "|| LOT 39 = Soft ||"; extern string Info2 = "|| MARTINGALE 1 = Off ||"; extern string Info3 = "|| TP_ATR 999 = Off ||"; //Variables GLOBALS datetime CurrentTime; int ras,wt,wk,ticketb,tickets,last_tip,OrderOpRetry=5; double slb,tpb,sls,tps,pt,last_profit, last_lot, profitnow,profit; bool clear; //Day Global bool DaytoTrade(){ bool daytotrade = false; if(DayOfWeek() == 0 && Sunday) daytotrade = true; if(DayOfWeek() == 1 && Monday) daytotrade = true; if(DayOfWeek() == 2 && Tuesday) daytotrade = true; if(DayOfWeek() == 3 && Wednesday) daytotrade = true; if(DayOfWeek() == 4 && Thursday) daytotrade = true; if(DayOfWeek() == 5 && Friday) daytotrade = true; return(daytotrade);} //on/off TRADING bool EAon(){ bool eaon = false; if(Power_ON) eaon = true; return(eaon);} bool TakeP(){ bool takeP = false; if(DayOfWeek() == 5 && TakeProfit_ON) takeP = true; return(takeP);} //+-----------+ int start() { // Martingale (1 = Off) double Lot = (AccountEquity() * 0.001 /Lots); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot = (AccountEquity() * 0.001 /Lots); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot = Martingale_X*last_lot; if( last_profit > 0 ) Lot = (AccountEquity() * 0.001 /Lots); string ls_01 =StringConcatenate ( " Levier: " , AccountLeverage(), "\n", "\n" , " Heure du Server: " , TimeToStr(TimeCurrent(), TIME_SECONDS) , "\n" , " Heure Locale: " , TimeToStr(TimeLocal(), TIME_SECONDS) , "\n"); string ls_02 = "-------------------------------------\n"+"\n"; int Spread; Spread=(int)SymbolInfoInteger(Symbol(),SYMBOL_SPREAD); string ls_03 = (StringFormat(" Spread = %d", Spread)); string ls_04 = "\n" + "\n"; string ls_05 = "-------------------------------------\n"; string profitstr = DoubleToStr(profitnow,2); string ls_06 = "\n" + "\n"; string ls_07 =StringConcatenate (" Solde : " , AccountBalance() , "\n"); string ls_08 =StringConcatenate( " Equity : " , AccountEquity() , "\n"); string ls_09 = StringConcatenate(" Profits : " , AccountProfit() , "\n"); Comment( ls_01 + ls_02 + ls_03 + ls_04 + ls_05 + ls_06 + ls_07 + ls_08 + ls_09 ); // Trading HOURS if(UseTimer == true) { CurrentTime = TimeLocal(); int GetWeekday = TimeDayOfWeek(CurrentTime); int GetHour = TimeHour(CurrentTime); int GetMinute = TimeMinute(CurrentTime); if(GetHour >= StartHour && GetHour <= EndHour && GetWeekday <6) { TradeAllowed = true; } else TradeAllowed = false; } else TradeAllowed = true; //+-----------+ if(Volume[0]>1) if(TrailingStop_)dtrailing(); // SL & TP if(SL_ATR==0)slb=0;else slb=Close[0]-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*SL_ATR; if(SL_ATR==0)sls=0;else sls=Close[0]+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*SL_ATR; if(TP_ATR==0)tpb=0;else tpb=Close[0]+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TP_ATR; if(TP_ATR==0)tps=0;else tps=Close[0]-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TP_ATR; // List DOUBLE double rhigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, Bk,1+1)); double rlow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, Bk, 1+1)); // Candle value double CLOSE = iClose(Symbol(),0, 1); double HIGH = iHigh(Symbol(),0, 1); double LOW = iLow(Symbol(),0, 1); int res; //--- SELL conditions if(((CLOSE < rlow && 1 > 0) || (LOW < rlow))) if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) < iBands(NULL,PERIOD_CURRENT,BB_period,BB_deviation,0,PRICE_OPEN,MODE_LOWER,1)) { if(totalorder(0) < MaxLots && EAon() && DaytoTrade() && TakeP() && TradeAllowed == true) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } //--- BUY conditions if(((CLOSE > rhigh && 1 > 0) || (HIGH > rhigh))) if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) > iBands(NULL,PERIOD_CURRENT,BB_period,BB_deviation,0,PRICE_OPEN,MODE_UPPER,1)) { if(totalorder(0) < MaxLots && EAon() && DaytoTrade() && TakeP() && TradeAllowed == true) res=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } return(0); } //+-----------+ int totalorder(int tipe) { int total=0; for(int i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic || OrderType()!=tipe) continue; total++; } return(total); } //+-----------+ void dtrailing() { int i,r;double tpn; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; tpn=OrderTakeProfit(); if(OrderType()==OP_BUY) { if(Bid-OrderOpenPrice()>iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) { if((OrderStopLoss()<Bid-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR,OrderTakeProfit(),0,Green); } } } if(OrderType()==OP_SELL) { if((OrderOpenPrice()-Ask)>(iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR)) { if(OrderStopLoss()>(Ask+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR) || (OrderStopLoss()==0)) { if(tpn) r=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+iATR(NULL,PERIOD_CURRENT,ATR_Period,0)*TS_ATR,OrderTakeProfit(),0,Red); } } } } } //+-----------+ void closeall() { for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; if(OrderType()>1) ras=OrderDelete(OrderTicket()); else { if(OrderType()==0) ras=OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE); else ras=OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE); } } } //+----------+ // Martingale //+----------+ double last_history_profit() { double cpte_profit = 0; //int Magik_No = -1; if( OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY) ) { if( OrderMagicNumber() == Magic ) { last_profit = OrderProfit(); last_lot = OrderLots(); last_tip = OrderType(); } } return(0); }
    Modifié le 2022-02-20 13:52:01 par lefeuvr3
  • arka3579 — en réponse à lefeuvr3 dans son message #125851

    Merci pour l'amélioration.