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

Le P'tit Dernier E.A.

  • arka3579

    Mon dernier né.
    System BK Kumo + H.L. System.

    Reste a affiné les réglages éventuellement pour des résultats plus efficaces.

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ //--- Inputs input string IndicatorName="MyEA%_Scalper_KUMO_Bk"; 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 bool EXIT_System_ON = false; input int Magic = 1; extern int ATR_Period = 17; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; input double Lots = 0.1; extern double Martingale_X = 2.0; extern string BP = "|||||||||| BASKET Profit ||||||||||"; extern bool UseProfitToClose = true; extern double ProfitToClose = 7.77; extern bool UseLossToClose = false; extern double LossToClose = 6.66; extern bool AllSymbols = false; extern bool PendingOrders = false; extern string DC = "|||||||||| DONCHIAN ||||||||||"; extern int Bk = 11; extern string KUMO = "|||||||||| ICHIMOKU ||||||||||"; extern int Tenkan = 9; extern int Kijun = 26; extern int Senkou = 52; extern string SL = "|||||||||| STOP LOSS ||||||||||"; extern double SL_ATR = 2.7; input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; extern string TIME_setting = "|||||||||| TIME Settings ||||||||||"; extern bool UseTimer = false; // Use start & end times in Hours input ENUM_HOUR StartHour = h13; // Start operation hour input ENUM_HOUR EndHour = h15; // Last operation hour extern string DAY_setting = "|||||||||| DAY Settings ||||||||||"; extern bool Monday = true; extern bool Tuesday = true; extern bool Wednesday = true; extern bool Thursday = false; extern bool Friday = true; extern bool Sunday = false; //+------------------------------------------------------------------+ datetime CurrentTime; bool EAon(){ bool eaon = false; if(POWER_ON) eaon = true; return(eaon);} double slb,tpb,sls,tps,pt; double last_profit, last_lot; int last_tip; bool clear; double pips2dbl, pips2point, pipValue, profit, profitnow; 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);} bool Exit(){ bool exit = false; if(EXIT_System_ON) exit = true; return(exit);} //+------------------------------------------------------------------+ //| Check for close order conditions | //+------------------------------------------------------------------+ void CheckForClose() { //--- go trading only for first tiks of new bar if(Volume[0]>1) return; double ssA = iIchimoku(NULL, 0,Tenkan,Kijun,Senkou, MODE_SENKOUSPANA,0); double ssB = iIchimoku(NULL, 0,Tenkan,Kijun,Senkou, MODE_SENKOUSPANB,0); //--- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderMagicNumber()!=Magic || OrderSymbol()!=Symbol()) continue; //--- check order type if(OrderType()==OP_BUY) { if (Open[1]<ssA && Open[1]<ssB) if (Exit() ) { if(!OrderClose(OrderTicket(),OrderLots(),Bid,3,White)) Print("OrderClose error ",GetLastError()); } break; } if(OrderType()==OP_SELL) { if (Open[1]>ssA && Open[1]>ssB) if (Exit() ) { if(!OrderClose(OrderTicket(),OrderLots(),Ask,3,White)) Print("OrderClose error ",GetLastError()); } break; } } } //+------------------------------------------------------------------+ //| 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() { // Martingale double Lot = (AccountEquity() * Lots /1000); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot = (AccountEquity() * Lots /1000); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot = Martingale_X*last_lot; if( last_profit > 0 ) Lot = (AccountEquity() * Lots /1000); 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); //--- Output values in three lines 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; int res; //--- go trading only for first tiks of new bar 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; //--- get Moving Average double ssA = iIchimoku(NULL, 0,Tenkan,Kijun,Senkou, MODE_SENKOUSPANA,0); double ssB = iIchimoku(NULL, 0,Tenkan,Kijun,Senkou, MODE_SENKOUSPANB,0); 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); //--- SELL conditions if (Open[1]<ssA && Open[1]<ssB) if((CLOSE < rlow && 1 > 0) || (LOW < rlow) && TradeAllowed == true) if (EAon() ) if (DaytoTrade() ) { 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) && TradeAllowed == true) if (Open[1]>ssA && Open[1]>ssB) if (EAon() ) if (DaytoTrade() ) { res=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,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 CheckForClose(); //--- Basket Profit/Lost profit = ProfitCheck(); if(UseProfitToClose) { if(profit>(AccountBalance() * ProfitToClose/100)) { if(AllSymbols) { if(PendingOrders) if(!CloseDeleteAll()) clear=false; if(!PendingOrders) if(!CloseDeleteAllNonPending()) clear=false; } if(!AllSymbols) { if(PendingOrders) if(!CloseDeleteAllCurrent()) clear=false; if(!PendingOrders) if(!CloseDeleteAllCurrentNonPending()) clear=false; } } } if(UseLossToClose) { if(profit<-(AccountBalance() * LossToClose/100)) { if(AllSymbols) { if(PendingOrders) if(!CloseDeleteAll()) clear=false; if(!PendingOrders) if(!CloseDeleteAllNonPending()) clear=false; } if(!AllSymbols) { if(PendingOrders) if(!CloseDeleteAllCurrent()) clear=false; if(!PendingOrders) if(!CloseDeleteAllCurrentNonPending()) clear=false; } } } } //////////////////////////////////////////////////////////////////////////////////////////////////////// bool CloseDeleteAll() { int total = OrdersTotal(); for (int cnt = total-1 ; cnt >=0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) { switch(OrderType()) { case OP_BUY : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Blue)) return(false); }break; case OP_SELL : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Red)) return(false); }break; } if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT) if(!OrderDelete(OrderTicket())) { Print("Error deleting " + OrderType() + " order : ",GetLastError()); return (false); } } } return (true); } //////////////////////////////////////////////////////////////////////////////////////////////////////// // delete all on current chart bool CloseDeleteAllCurrent() { int total = OrdersTotal(); for (int cnt = total-1 ; cnt >=0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) { if(OrderSymbol()==Symbol()) { switch(OrderType()) { case OP_BUY : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Blue)) return(false); }break; case OP_SELL : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Red)) return(false); }break; } if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT) if(!OrderDelete(OrderTicket())) { return (false); } } } } return (true); } //////////////////////////////////////////////////////////////////////////////////////////////////////// // left pending orders bool CloseDeleteAllNonPending() { int total = OrdersTotal(); for (int cnt = total-1 ; cnt >=0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) { switch(OrderType()) { case OP_BUY : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Blue)) return(false); }break; case OP_SELL : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Red)) return(false); }break; } } } return (true); } //////////////////////////////////////////////////////////////////////////////////////////////////////// // delete all on current chart left pending bool CloseDeleteAllCurrentNonPending() { int total = OrdersTotal(); for (int cnt = total-1 ; cnt >=0 ; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) { if(OrderSymbol()==Symbol()) { switch(OrderType()) { case OP_BUY : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Blue)) return(false); }break; case OP_SELL : { if(!OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Red)) return(false); }break; } } } } return (true); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// double ProfitCheck() { double profit=0; int total = OrdersTotal(); for (int cnt = total-1 ; cnt >=0 ; cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(AllSymbols) profit+=OrderProfit(); else if(OrderSymbol()==Symbol()) profit+=OrderProfit(); } return(profit); } //+------------------------------------------------------------------+ // 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); } //+------------------------------------------------------------------+ //| ATR | //+------------------------------------------------------------------+ double ATR(string SYMBOL) { double ATR = iATR(SYMBOL,0,ATR_Period,1); return(ATR); }
  • Mikiburger

    Bonjour Yohan,

    Ca ne fonctionne pas vraiment.
    J'ai surtout des messages d'erreur quand j'essaye de backtester.
    Peux tu m'en dire plus sur ce robot ? Principe, ce qu'il reste à débugger, ...
  • arka3579

    EUR-USD / C.T.

    Code
    #property copyright "07 MAI 2022" #property strict extern bool POWER_ON = true; extern int Magic = 1; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; input double Lots = 0.01; extern double Booster = 1.1; // extern double Martingale_X = 1.1; extern string PARAM = "|||||||||| PARAMETRES ||||||||||"; extern int BK = 11; extern int MFI_Period = 11; extern int cciMAX = 111; extern int cciMIN = -111; extern string TD = "|||||||||| TIME & DAY ||||||||||"; 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 int Start_Hour = 1; extern int End_Hour = 11; extern string COM = "|||||||||| COMMENTAIRES ||||||||||"; input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; //DOUBLE / BOOL / STRING bool EAon(){ bool eaon = false; if(POWER_ON) eaon = true; return(eaon);} 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);} datetime CurrentTime; double profit = 0; double globalprofit = 0; bool openonnewcandle = true; double totalprofit; bool SELLallowed=false; bool BUYallowed=false; string stoptrading="0"; string error; int LotDigits = 2; int cciperiod=11; int EspPips= 2,EspOrders= 5,Esp_= 17; double High0,High1,Low0,Low1,profitnow,HL0,HL1; double cci = iCCI(Symbol(), 0,11, PRICE_TYPICAL, 0); //+------------------------------------------------------------------+ void OnTick() { 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); //--- Output values in three lines 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 ); int ticketBuyOrder = GetTicketOfLatestBuyOrder(); int ticketSellOrder = GetTicketOfLatestSellOrder(); int res; // ENTRY CCI + MFI { if(SELLallowed && (cci < -100 && cci > cciMIN)) if((iMFI(NULL,0,MFI_Period,0) < 48) && (iMFI(NULL,0,MFI_Period,0) > 30)) { SELLallowed = false; } if(BUYallowed && (cci > 100 && cci > cciMAX)) if((iMFI(NULL,0,MFI_Period,0) > 52) && (iMFI(NULL,0,MFI_Period,0) < 70)) { BUYallowed = false; } if (cci < 100 && cci > -100) { BUYallowed = true; SELLallowed = true; } } // OPEN BUY if (ticketBuyOrder == 0) if(Hour_trade()==1) if (DaytoTrade() ) if (EAon() ) { if (GlobalVariableGet(stoptrading)==0) if ((HL0)<(HL1)) { res = OrderSend (Symbol(),OP_BUY, (AccountEquity() * Lots /(Booster*100)) , Ask , 3, 0, 0, Buy_Com, Magic, 0, Blue); if (res >= 0) {}}} if ( ticketBuyOrder != 0) { { if ( OrderSelect(ticketBuyOrder, SELECT_BY_TICKET)) { double orderLots = OrderLots(); double orderPrice = OrderOpenPrice(); int buyOrderCount = GetB_S_OrderCount(); double NextMartingale_X = NormalizeDouble(orderLots * Martingale_X, LotDigits); if( Ask <= orderPrice - EspPips * Point() && buyOrderCount < EspOrders) { double lots= (Martingale_X > 0) ? NextMartingale_X : (AccountEquity() * Lots /(Booster*100)); res = OrderSend (Symbol(), OP_BUY, (AccountEquity() * Lots /(Booster*100)), Ask, 3, 0, 0, Buy_Com, Magic, 0, Blue); } else if( Ask <= orderPrice - Esp_ * Point() && buyOrderCount <= (EspOrders + Esp_-1) && buyOrderCount >= EspOrders) { double lots= (Martingale_X > 0) ? NextMartingale_X : (AccountEquity() * Lots /(Booster*100)); res = OrderSend (Symbol(), OP_BUY, (AccountEquity() * Lots /(Booster*100)), Ask, 3, 0, 0, Buy_Com, Magic, 0, Blue); }}}} // OPEN SELL if (ticketSellOrder == 0) if(Hour_trade()==1) if (DaytoTrade() ) if (EAon() ) { // SELL order if ( GlobalVariableGet(stoptrading) == 0 ) High0 = (iHigh ( Symbol (), PERIOD_CURRENT , iHighest ( Symbol (), PERIOD_CURRENT , MODE_HIGH, BK , 0 ))); High1=(iHigh ( Symbol (), PERIOD_CURRENT , iHighest ( Symbol (), PERIOD_CURRENT , MODE_HIGH, BK , 1 ))) ; Low0=(iLow ( Symbol (), PERIOD_CURRENT , iLowest ( Symbol (), PERIOD_CURRENT , MODE_LOW, BK , 0 ))); Low1=(iLow ( Symbol (), PERIOD_CURRENT , iLowest ( Symbol (), PERIOD_CURRENT , MODE_LOW, BK , 1 ))); HL0 = (High0 - Low0); HL1 = ((High1) - (Low1)); if ((HL0)<(HL1)) { res = OrderSend (Symbol(), OP_SELL, (AccountEquity() * Lots /(Booster*100)), Bid, 3, 0, 0, Sell_Com, Magic, 0, Red); if (res >= 0) { }}} // SELL order if ( ticketSellOrder != 0) { { if ( OrderSelect(ticketSellOrder, SELECT_BY_TICKET)) { double orderLots = OrderLots(); double orderPrice = OrderOpenPrice(); int sellOrderCount = GetB_S_OrderCount(); double NextMartingale_X = NormalizeDouble(orderLots * Martingale_X, LotDigits); if( Bid >= orderPrice + EspPips * Point() && GetB_S_OrderCount() < EspOrders) { double lots= (Martingale_X > 0) ? NextMartingale_X : (AccountEquity() * Lots /(Booster*100)); res = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, 0, 0, Sell_Com, Magic, 0, Red); } else if( Bid >= orderPrice + Esp_ * Point() && sellOrderCount <= (EspOrders + Esp_ - 1) && sellOrderCount >= EspOrders) { double lots= (Martingale_X > 0) ? NextMartingale_X : (AccountEquity() * Lots /(Booster*100)); res = OrderSend(Symbol(), OP_SELL, lots, Bid, 3, 0, 0, Sell_Com, Magic, 0, Red); } } } } // CALCUL PROFIT & LOSS of ALL double profitBuyOrders = 0; double profitSellOrders = 0; for(int k=OrdersTotal()-1; k >=0; k--) { if ( OrderSelect(k, SELECT_BY_POS)) { if (Symbol() == OrderSymbol()) { if (OrderType()==OP_BUY && OrderMagicNumber() == Magic) { profitBuyOrders = profitBuyOrders + OrderProfit() + OrderSwap() + OrderCommission(); } if (OrderType()==OP_SELL && OrderMagicNumber() == Magic) { profitSellOrders = profitSellOrders + OrderProfit() + OrderSwap() + OrderCommission(); } } } } // close all buy orders (for this pair) when total profit of buy orders > profit if ((profit > 0 && profitBuyOrders >= profit)) { CloseAllBuyOrders(); } // close all sell orders (for this pair) when total profit of sell orders > profit if ((profit > 0 && profitSellOrders >= profit)) { CloseAllSellOrders(); } // close all orders when total profit on this pair > pairglobalprofit if ((AccountEquity() * 0.01 /8)> 0 && (profitBuyOrders + profitSellOrders) >= (AccountEquity() * 0.01 /8)) { CloseAllSellOrders(); CloseAllBuyOrders(); } } //+------------------------------------------------------------------+ int GetB_S_OrderCount() { 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); } //+------------------------------------------------------------------+ int GetTicketOfLatestBuyOrder() { double maxLots=0; int orderTicketNr=0; for (int l=OrdersTotal() - 1; l >= 0; l--) { if ( OrderSelect(l,SELECT_BY_POS)) { if( OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { return OrderTicket(); } } } return 0; } //+------------------------------------------------------------------+ int GetTicketOfLatestSellOrder() { double maxLots=0; int orderTicketNr=0; for (int l=OrdersTotal() - 1; l >= 0; l--) { if ( OrderSelect(l, SELECT_BY_POS) ) { if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { return OrderTicket(); } } } return 0; } //+------------------------------------------------------------------+ void CloseAllBuyOrders() { for (int m=OrdersTotal(); m>=0; m--) { if ( OrderSelect(m, SELECT_BY_POS)) { if(OrderType() == OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { RefreshRates(); bool success = OrderClose(OrderTicket(), OrderLots(), Bid, 0, Blue); } } } } //+------------------------------------------------------------------+ void CloseAllSellOrders() { for (int h=OrdersTotal();h>=0;h--) { if ( OrderSelect(h,SELECT_BY_POS) ) { if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { RefreshRates(); bool success =OrderClose(OrderTicket(), OrderLots(), Ask, 0, Red); } } } } //+------------------------------------------------------------------+ int Hour_trade() { bool trade=false; if(Start_Hour>End_Hour) { if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true; } else if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true; return (trade); }
  • arka3579 — en réponse à arka3579 dans son message #126985

    N.B. Fonctionne pas !
  • arka3579

    Nouveauté dans celui-ci :
    Ouverture des postion par MicroLot ou Pourcentage Risk
    Mode turbo si les 2 sont activé.

    Condition d'ouverture avec :
    Moving Average + Bk Turtle + Money Flow Index + Bollinger B

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ input int Magic = 1; input string IndicatorName="MyEA_%R & ML ProScalp"; extern bool POWER_ON = true; extern bool TRAIL_ON = true; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; extern double Martingale_X = 1.33; extern bool MICLOT_ON = false; input double MicLot = 0.01; extern bool PERCENT_RISK_ON = True; extern double Risk = 0.2; extern double TS_ATR = 1.7; extern double SL_ATR = 6.6; extern int MFI_Period = 33; input int MA_Mode1 = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma extern double MA_Filter1 = 17; input int BB_period = 141; input double BB_deviation = 0.9; extern int BK_Turtle = 5; extern bool StrictEntry = true; extern string DAY_setting = "|||||||||| 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; input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; extern int Start_Hour = 0; extern int End_Hour = 24; //+------------------------------------------------------------------+ 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);} datetime CurrentTime; int OrderOpRetry=5; bool EAon(){ bool eaon = false; if(POWER_ON) eaon = true; return(eaon);} double slb,tpb,sls,tps,pt; double last_profit, last_lot; int last_tip; bool clear; double pips2dbl, pips2point, pipValue, profit, profitnow; bool Trail(){ bool trail = false; if(TRAIL_ON) trail = true; return(trail);} bool PERrisk(){ bool PerRisk = false; if(PERCENT_RISK_ON) PerRisk = true; return(PerRisk);} bool MICRlot(){ bool MicroLot = false; if(MICLOT_ON) MicroLot = true; return(MicroLot);} //+------------------------------------------------------------------+ //| My TrailingStop | //+------------------------------------------------------------------+ void Trailingstop() { double MyPoint = (iATR(NULL,PERIOD_CURRENT,14,0)*TS_ATR) ; 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(Bid-OrderOpenPrice()>MyPoint) if(OrderStopLoss()<Bid-MyPoint) int TBM=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(MyPoint),OrderTakeProfit(),0,clrNONE); } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>MyPoint) if(OrderStopLoss()>Ask+MyPoint) int TSM=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(MyPoint),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() { // Martingale MicroLot double Lot2 = MicLot; if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot2 = MicLot; else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot2 = Martingale_X*last_lot; if( last_profit > 0 ) Lot2 = MicLot; // Martingale %R double Lot = (AccountEquity()/100*(Risk/100)); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot = (AccountEquity()/100*(Risk/100)); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot = Martingale_X*last_lot; if( last_profit > 0 ) Lot = (AccountEquity()/100*(Risk/100)); 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); //--- Output values in three lines 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 ); //+-------- int res; //--- go trading only for first tiks of new bar if(Volume[0]>1) return; if(SL_ATR==0)slb=0;else slb=Close[0]-iATR(NULL,PERIOD_CURRENT,14,0)*SL_ATR; if(SL_ATR==0)sls=0;else sls=Close[0]+iATR(NULL,PERIOD_CURRENT,14,0)*SL_ATR; //--- get Moving Average double rhigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, BK_Turtle,1+1)); double rlow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, BK_Turtle, 1+1)); 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) < iMA(NULL,PERIOD_CURRENT,MA_Filter1,0,MA_Mode1,PRICE_CLOSE,1)) if(((CLOSE < rlow && 1 > 0) || (LOW < rlow)) && StrictEntry == true) if(iMFI(NULL,0,MFI_Period,0) < 48) if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1)<iBands(NULL,PERIOD_CURRENT,BB_period,0.9,0,PRICE_OPEN,MODE_LOWER,1)) if (EAon() ) if(Hour_trade()==1) if (DaytoTrade() ) { if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } //--- BUY conditions if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL,PERIOD_CURRENT,MA_Filter1,0,MA_Mode1,PRICE_CLOSE,1)) if(((CLOSE > rhigh && 1 > 0) || (HIGH > rhigh)) && StrictEntry == true) if(iMFI(NULL,0,MFI_Period,0) > 52) if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1)>iBands(NULL,PERIOD_CURRENT,BB_period,0.9,0,PRICE_OPEN,MODE_UPPER,1)) if (EAon() ) if(Hour_trade()==1) if (DaytoTrade() ) { if (PERrisk()) res=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); return; } } //+------------------------------------------------------------------+ //| OnTick function | //+------------------------------------------------------------------+ void OnTick() { //--- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); else Trailingstop(); } //+------------------------------------------------------------------+ // 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); } //+------------------------------------------------------------------+ //| ATR | //+------------------------------------------------------------------+ double ATR(string SYMBOL) { double ATR = iATR(SYMBOL,0,14,1); return(ATR); } //+------------------------------------------------------------------+ int Hour_trade() { bool trade=false; if(Start_Hour>End_Hour) { if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true; } else if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true; return (trade); }

    Résultat a vérifier sur BackTest Sérieux.
    Bon W.End tout le monde.

    aRka.
  • arka3579

    Systeme d'ouverture aux choix avec fonction ON/OFF.
    Combiné a votre gout et cherché la meilleur combinaison avec les meilleurs réglages.

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ extern int Magic = 1; extern bool TRAIL_ON = true; input string IndicatorName="MyEA_%R & ML"; extern bool _MFI = FALSE; extern bool _BK_Turtle = FALSE; extern bool _MA = FALSE; extern bool _STOCK = FALSE; extern bool _BB = FALSE; extern bool _CCI = FALSE; extern bool _TKS = FALSE; extern bool _ADX = FALSE; extern bool _RSI = FALSE; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; extern double Martingale_X = 1.33; extern bool MICLOT_ON = false; input double MicLot = 0.01; extern bool PERCENT_RISK_ON = True; extern double Risk = 0.2; extern double TS_ATR = 2.7; extern double SL_ATR = 7.7; extern double CCI_Period = 22; extern double cciMin = -125; extern double cciMax = 125; extern int MFI_Period = 33; extern int RSI_Period = 17; //rsi period extern int Kp = 61; extern int Dp = 4; extern int Sl = 16; input int STOCK_Mode = 0; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma input int MA_Mode = 0; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma extern int MA_Open = 17; extern int BK_Turtle = 7; extern bool StrictEntry = true; extern int ADX_Period = 50; extern int ADX_Th = 25; input int BB_period = 141; input double BB_deviation = 0.9; extern int Tenkan = 9; extern int Kijun = 26; extern int Senkou = 52; extern int TKS = 5; input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; extern int Start_Hour = 0; extern int End_Hour = 24; //+------------------------------------------------------------------+ datetime CurrentTime; int OrderOpRetry=5; double slb,tpb,sls,tps,pt; double last_profit, last_lot; int last_tip; bool clear; double pips2dbl, pips2point, pipValue, profit, profitnow; bool Trail(){ bool trail = false; if(TRAIL_ON) trail = true; return(trail);} bool PERrisk(){ bool PerRisk = false; if(PERCENT_RISK_ON) PerRisk = true; return(PerRisk);} bool MICRlot(){ bool MicroLot = false; if(MICLOT_ON) MicroLot = true; return(MicroLot);} bool _CCI_(){ bool _CCi = false; if(_CCI) _CCi = true; return(_CCi);} bool _ADX_(){ bool _ADx = false; if(_ADX) _ADx = true; return(_ADx);} bool _RSI_(){ bool _RSi = false; if(_RSI) _RSi = true; return(_RSi);} bool _TKS_(){ bool _Tks = false; if(_TKS) _Tks = true; return(_Tks);} bool _MFI_(){ bool _MFi = false; if(_MFI) _MFi = true; return(_MFi);} bool _BK_(){ bool _Bk = false; if(_BK_Turtle) _Bk = true; return(_Bk);} bool _STOCK_(){ bool _Stock = false; if(_STOCK) _Stock = true; return(_Stock);} bool _BB_(){ bool _Bb = false; if(_BB) _Bb = true; return(_Bb);} bool _MA_(){ bool _Ma = false; if(_MA) _Ma = true; return(_Ma);} //+------------------------------------------------------------------+ //| My TrailingStop | //+------------------------------------------------------------------+ void Trailingstop() { if (Trail()) double MyPoint = (iATR(NULL,PERIOD_CURRENT,14,0)*TS_ATR) ; 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(Bid-OrderOpenPrice()>MyPoint) if(OrderStopLoss()<Bid-MyPoint) int TBM=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(MyPoint),OrderTakeProfit(),0,clrNONE); } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>MyPoint) if(OrderStopLoss()>Ask+MyPoint) int TSM=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(MyPoint),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() { // Martingale MicroLot double Lot2 = MicLot; if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot2 = MicLot; else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot2 = Martingale_X*last_lot; if( last_profit > 0 ) Lot2 = MicLot; // Martingale %R double Lot = (AccountEquity()/100*(Risk/100)); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot = (AccountEquity()/100*(Risk/100)); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot = Martingale_X*last_lot; if( last_profit > 0 ) Lot = (AccountEquity()/100*(Risk/100)); 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); //--- Output values in three lines 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 ); //+-------- int res, res2; //--- go trading only for first tiks of new bar if(Volume[0]>1) return; if(SL_ATR==0)slb=0;else slb=Close[0]-iATR(NULL,PERIOD_CURRENT,14,0)*SL_ATR; if(SL_ATR==0)sls=0;else sls=Close[0]+iATR(NULL,PERIOD_CURRENT,14,0)*SL_ATR; if(Hour_trade()==1) double rhigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, BK_Turtle,1+1)); double rlow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, BK_Turtle, 1+1)); double CLOSE = iClose(Symbol(),0, 1); double HIGH = iHigh(Symbol(),0, 1); double LOW = iLow(Symbol(),0, 1); double ssA = iIchimoku(NULL, 0,TKS,TKS,TKS, MODE_SENKOUSPANA,0); double ssB = iIchimoku(NULL, 0,TKS,TKS,TKS, MODE_SENKOUSPANB,0); double CCI = iCCI(NULL,PERIOD_CURRENT,CCI_Period,PRICE_TYPICAL,0); //--- SELL conditions { if((((CLOSE < rlow && 1 > 0) || (LOW < rlow)) && StrictEntry == true) && (_BK_())) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } { if((iMFI(NULL,0,MFI_Period,0) < 48) && (_MFI_())) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } { if((iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL,PERIOD_CURRENT,MA_Open,0,MA_Mode,PRICE_CLOSE,1)) && (_MA_())) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } { if((iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) < iBands(NULL,PERIOD_CURRENT,BB_period,0.9,0,PRICE_OPEN,MODE_LOWER,1)) && (_BB_())) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } { if((iStochastic(NULL,0,Kp,Dp,Sl,STOCK_Mode,0,MODE_MAIN,0)<iStochastic(NULL,0,Kp,Dp,Sl,STOCK_Mode,0,MODE_SIGNAL,0)) && (_STOCK_())) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } { if ((CCI <= -100) && (CCI > cciMin) && (_CCI_() )) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } { if ((iADX(Symbol(),PERIOD_CURRENT,ADX_Period,PRICE_CLOSE,MODE_MAIN,0) > ADX_Th) && (_ADX_())) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } { if (((iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0) < 45) && (iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0 >= 30))) && (_RSI_())) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } { if(((Open[1] < ssA && Open[1] < ssB)) && (_TKS_())) if (PERrisk()) res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if (MICRlot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,Sell_Com,Magic,0,Red); } //--- BUY conditions { if((((CLOSE > rhigh && 1 > 0) || (HIGH > rhigh)) && StrictEntry == true) && (_BK_())) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } { if((iMFI(NULL,0,MFI_Period,0) > 52) && (_MFI_())) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } { if((iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL,PERIOD_CURRENT,MA_Open,0,MA_Mode,PRICE_CLOSE,1)) && (_MA_())) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } { if((iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1)>iBands(NULL,PERIOD_CURRENT,BB_period,0.9,0,PRICE_OPEN,MODE_UPPER,1)) && (_BB_())) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } { if((iStochastic(NULL,0,Kp,Dp,Sl,STOCK_Mode,0,MODE_MAIN,0)>iStochastic(NULL,0,Kp,Dp,Sl,STOCK_Mode,0,MODE_SIGNAL,0)) && (_STOCK_())) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } { if ((CCI >= 100) && (CCI > cciMax) && (_CCI_() )) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } { if ((iADX(Symbol(),PERIOD_CURRENT,ADX_Period,PRICE_CLOSE,MODE_MAIN,0) > ADX_Th) && (_ADX_())) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } { if (((iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0) > 55) && (iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0 <= 70))) && (_RSI_())) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } { if(((Open[1] > ssA && Open[1] > ssB)) && (_TKS_())) if (PERrisk()) res2=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if (MICRlot()) res2=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); } } //+------------------------------------------------------------------+ //| OnTick function | //+------------------------------------------------------------------+ void OnTick() { //--- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); else Trailingstop(); } //+------------------------------------------------------------------+ // 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); } //+------------------------------------------------------------------+ //| ATR | //+------------------------------------------------------------------+ double ATR(string SYMBOL) { double ATR = iATR(SYMBOL,0,14,1); return(ATR); } //+------------------------------------------------------------------+ int Hour_trade() { bool trade=false; if(Start_Hour>End_Hour) { if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true; } else if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true; return (trade); }
  • arka3579

    Scalper mis a l'essai sur M1
    13h21 (441€)

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ //--- Inputs input string IndicatorName="MyEA_%R - Le Scalper 2022"; extern bool POWER_ON = true; extern bool TRAIL_ON = true; input int Magic = 1; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; extern bool MICLOT_ON = true; extern double MicLot = 0.01; extern bool P_RISK_ON = true; extern double Risk = 0.2; extern double Martingale_X = 1.33; extern double TS_ATR = 1.7; extern double SL_ATR = 1.1; extern double TP_ATR = 77.7; input int MA_Mode = 1; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma extern int MA_Open = 17; extern int BB_Filter = 141; input double BB_Dev = 0.25; sinput ENUM_TIMEFRAMES TF_Pivot = PERIOD_M5;// Timeframe extern int Kp = 31; extern int Dp = 4; extern int Sl = 13; extern int Start_Hour = 0; extern int End_Hour = 24; extern bool Monday = true; extern bool Tuesday = true; extern bool Wednesday = true; extern bool Thursday = true; extern bool Friday = true; extern bool Sunday = false; //+------------------------------------------------------------------+ 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);} int OrderOpRetry=5; bool EAon(){ bool eaon = false; if(POWER_ON) eaon = true; return(eaon);} double slb,tpb,sls,tps,pt; double last_profit, last_lot; int last_tip; bool clear; double pips2dbl, pips2point, pipValue, profit, profitnow; bool Trail(){ bool trail = false; if(TRAIL_ON) trail = true; return(trail);} bool MICLot(){ bool micL = false; if(MICLOT_ON) micL = true; return(micL);} bool PercentR(){ bool PersR = false; if(P_RISK_ON) PersR = true; return(PersR);} //+------------------------------------------------------------------+ //| My TrailingStop | //+------------------------------------------------------------------+ void Trailingstop() { if (Trail()) double MyPoint = (iATR(NULL,PERIOD_CURRENT,14,0)*TS_ATR) ; 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(Bid-OrderOpenPrice()>MyPoint) if(OrderStopLoss()<Bid-MyPoint) int TBM=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(MyPoint),OrderTakeProfit(),0,clrNONE); } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>MyPoint) if(OrderStopLoss()>Ask+MyPoint) int TSM=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(MyPoint),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() { // Martingale %R double Lot1 = (AccountEquity()/100*Risk/100); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot1 = (AccountEquity()/100*Risk/100); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot1 = Martingale_X*last_lot; if( last_profit > 0 ) Lot1 = (AccountEquity()/100*Risk/100); // Martingale MicLot double Lot2 = MicLot; if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) Lot2 = MicLot; else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) Lot2 = Martingale_X*last_lot; if( last_profit > 0 ) Lot2 = MicLot; string ls_01 = " Levier: " + AccountLeverage() + "\n" + "\n" + " Heure du Server: " + TimeToStr(TimeCurrent(), TIME_SECONDS) + "\n"; string ls_02 = "-------------------------------------\n"+"\n"; string ls_07 = " Solde : " + AccountBalance() + "\n"; string ls_08 = " Equity : " + AccountEquity() + "\n"; string ls_09 = " Account Profits : " + AccountProfit() + "\n"; string ls_10 = " Symbol : " + Symbol() + " " + OrderProfit() + "\n"; Comment( ls_01 + ls_02 + ls_07 + ls_08 + ls_09 + ls_10 ); int res; //--- go trading only for first tiks of new bar if(Volume[0]>1) return; if(SL_ATR==0)slb=0;else slb=Close[0]-iATR(NULL,PERIOD_CURRENT,14,0)*SL_ATR; if(SL_ATR==0)sls=0;else sls=Close[0]+iATR(NULL,PERIOD_CURRENT,14,0)*SL_ATR; if(TP_ATR==0)tpb=0;else tpb=Close[0]+iATR(NULL,PERIOD_CURRENT,14,0)*TP_ATR; if(TP_ATR==0)tps=0;else tps=Close[0]-iATR(NULL,PERIOD_CURRENT,14,0)*TP_ATR; double orderPrice = OrderOpenPrice(); double Pivot = (((iHigh ( Symbol (), TF_Pivot , iHighest ( Symbol (), TF_Pivot , MODE_HIGH, 1 , 1 ))) + (iLow ( Symbol (), TF_Pivot , iLowest ( Symbol (), TF_Pivot , MODE_LOW, 1 , 1 ))) + Open[0]*2) / 4); //--- SELL conditions if (iMA(NULL,PERIOD_CURRENT,1,0,MA_Mode,PRICE_CLOSE,1) < iMA(NULL,PERIOD_CURRENT,MA_Open,0,MA_Mode,PRICE_CLOSE,1)) if (Bid <= Pivot) if (iStochastic(NULL,0,Kp,Dp,Sl,1,0,MODE_MAIN,0) < iStochastic(NULL,0,Kp,Dp,Sl,1,0,MODE_SIGNAL,0)) if (iMA(NULL,PERIOD_CURRENT,1,0,MODE_EMA,PRICE_CLOSE,1 < iBands(NULL,PERIOD_CURRENT,BB_Filter,BB_Dev,0,PRICE_OPEN,MODE_LOWER,1))) if (EAon() ) if(Hour_trade()==1) if (DaytoTrade() ) { if (PercentR()) res=OrderSend(Symbol(),OP_SELL,Lot1,Bid,3,sls,tps,"Open_Sell_LeScalper"+Magic,Magic,0,Red); if (MICLot()) res=OrderSend(Symbol(),OP_SELL,Lot2,Bid,3,sls,tps,"Open_Sell_LeScalper"+Magic,Magic,0,Red); return; } //--- BUY conditions if (iMA(NULL,PERIOD_CURRENT,1,0,MA_Mode,PRICE_CLOSE,1) > iMA(NULL,PERIOD_CURRENT,MA_Open,0,MA_Mode,PRICE_CLOSE,1)) if (Ask >= Pivot) if (iStochastic(NULL,0,Kp,Dp,Sl,1,0,MODE_MAIN,0) > iStochastic(NULL,0,Kp,Dp,Sl,1,0,MODE_SIGNAL,0)) if (iMA(NULL,PERIOD_CURRENT,1,0,MODE_EMA,PRICE_CLOSE,1 > iBands(NULL,PERIOD_CURRENT,BB_Filter,BB_Dev,0,PRICE_OPEN,MODE_UPPER,1))) if (EAon() ) if(Hour_trade()==1) if (DaytoTrade() ) { if (PercentR()) res=OrderSend(Symbol(),OP_BUY,Lot1,Ask,3,slb,tpb,"Open_Buy_LeScalper"+Magic,Magic,0,Blue); if (MICLot()) res=OrderSend(Symbol(),OP_BUY,Lot2,Ask,3,slb,tpb,"Open_Buy_LeScalper"+Magic,Magic,0,Blue); return; } } //+------------------------------------------------------------------+ // GetBuyOrderCount() // returns the number of open buy orders //+------------------------------------------------------------------+ int GetBuyOrderCount() { int count=0; for (int k = OrdersTotal();k >=0 ;k--) { if (OrderSelect(k, SELECT_BY_POS)) { if (OrderType()==OP_BUY && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { count=count+1; } } } return count; } //+------------------------------------------------------------------+ // GetSellOrderCount() // returns the number of open sell orders //+------------------------------------------------------------------+ int GetSellOrderCount() { int count=0; // find all open orders of today for (int k = OrdersTotal(); k >=0 ;k--) { if (OrderSelect(k, SELECT_BY_POS)) { if (OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { count=count+1; } } } return count; } //+------------------------------------------------------------------+ //| OnTick function | //+------------------------------------------------------------------+ void OnTick() { //--- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); else Trailingstop(); } //+------------------------------------------------------------------+ // 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); } //+------------------------------------------------------------------+ //| ATR | //+------------------------------------------------------------------+ double ATR(string SYMBOL) { double ATR = iATR(SYMBOL,0,14,1); return(ATR); } //+------------------------------------------------------------------+ int Hour_trade() { bool trade=false; if(Start_Hour>End_Hour) { if(Hour()>=Start_Hour || Hour()<End_Hour) trade=true; } else if(Hour()>=Start_Hour && Hour()<End_Hour) trade=true; return (trade); }

    Je vous redis ca, Pour le Test en compte démo.