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

Mon tout 1er EA ! Présentation ..

  • arka3579 — en réponse à arka3579 dans son message #125656

    Voila ! Avec un peu de retard :

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ #property copyright "13 JANV 2021" #property version "1.00" string NAME = "My EA - % eLitePRO DOUBLE_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 }; //--- Inputs extern bool POWER_ON = true; extern string ___ = "||||||||||||||||||"; input int Magic = 1; extern int ATR_Period = 24; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; input double Lots = 25; extern double Martingale_X = 3.0; extern string _ = ""; extern string __1 = "|||||||||| SETTINGS ||||||||||"; extern string __2 = ""; extern bool TakeProfit_ON = true; extern double TP_ATR = 7.77 ; extern bool StopLoss_ON = true; extern double SL_ATR = 6.66; extern bool TrailingStep_ON = true; extern double TS_ATR = 2.7; extern string __3 = ""; extern string __4 = "|||||||||| BOLLINGER-B & M.A. ||||||||||"; extern string MA_info = "0 = sma, 1 = ema, 2 = smma, 3 = lwma"; extern string ____ = ""; input int BB_period = 120; input double BB_deviation = 1.11; extern string __5 = ""; extern string HL = "|||||||||| HIGH - LOW Settings ||||||||||"; extern int NbreBar = 3; extern int NbreBar2 = 9; extern string __15 = "||||||||||||||||||||||| TERMINAL Comments ||||||||||||||||||||||||||||||"; input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; extern string __16 = ""; extern string __17 = "|||||||||| 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 __18 = ""; 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 extern string __19 = ""; extern string INFO = "||||||||||||||||||||||| 0.01 MicroLot pour 250€ de capital ||||||||||||||||||||||||||||||"; //+------------------------------------------------------------------+ bool EAon(){ bool eaon = false; if(POWER_ON) eaon = true; return(eaon);} double slb,tpb,sls,tps,pt; int last_bar = 0; double last_profit, last_lot; int last_tip; static int ATR_TF; datetime CurrentTime; double pips2dbl, pips2point, pipValue, profit, profitnow; bool clear; 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 Trail(){ bool trailing = false; if(DayOfWeek() == 5 && TrailingStep_ON) trailing = true; return(trailing);} bool TakeP(){ bool takeP = false; if(DayOfWeek() == 5 && TakeProfit_ON) takeP = true; return(takeP);} bool StopL(){ bool stopL = false; if(DayOfWeek() == 5 && StopLoss_ON) stopL = true; return(stopL);} //+------------------------------------------------------------------+ //| My TrailingStop | //+------------------------------------------------------------------+ void Trailingstop() { for(int i=OrdersTotal()-1; i>=0;i--) { if (Trail() ) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol()) if(OrderMagicNumber()==Magic) if(OrderType()==OP_BUY) { if(Bid-OrderOpenPrice()>iATR(NULL,PERIOD_CURRENT,17,0)*TS_ATR) if(OrderStopLoss()<Bid-iATR(NULL,PERIOD_CURRENT,17,0)*TS_ATR) int TBM=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-iATR(NULL,PERIOD_CURRENT,17,0)*TS_ATR,OrderTakeProfit(),0,clrNONE); } else if(OrderType()==OP_SELL) { if(OrderOpenPrice()-Ask>-iATR(NULL,PERIOD_CURRENT,17,0)*TS_ATR) if(OrderStopLoss()>Ask+iATR(NULL,PERIOD_CURRENT,17,0)*TS_ATR) int TSM=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+iATR(NULL,PERIOD_CURRENT,17,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() { //+------------------------------------------------------------------+ // Martingale (double Martingale) //+------------------------------------------------------------------+ 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); //--- 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; // 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; //--- 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; 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; //--- get Moving Average //--- SELL conditions 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(Ask<Low[NbreBar]&& TradeAllowed == true) if(Ask<Low[NbreBar2]) if (DaytoTrade() ) if (EAon() ) { res=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,sls,tps,Sell_Com,Magic,0,Red); return; } //--- BUY conditions 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(Bid>High[NbreBar]&& TradeAllowed == true) if(Bid>High[NbreBar2]) if (DaytoTrade() ) if (EAon() ) { 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 Trailingstop(); } //+------------------------------------------------------------------+ //| init //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| Start function | //+------------------------------------------------------------------+ int start() { return(0); } //+------------------------------------------------------------------+ //| ATR | //+------------------------------------------------------------------+ double ATR(string SYMBOL) { double ATR = iATR(SYMBOL,ATR_TF,ATR_Period,1); return(ATR); } //+------------------------------------------------------------------+ // 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); }
  • arka3579

    Version HEDGING.
    Nouveauté :
    Ouverture Lot Buy et Sell personnalisable indépendemment.
    Idem pour le Coef Multiplicateur de la Martingale.
    Système d'ouverture amélioré.

    Code
    #property copyright "05 MAI 2022" extern string Name_EA = "MyEA - Hedge Perfect 888"; extern bool POWER_ON = true; input int Magic = 1; extern string MM = "|||||||||| MONEY MANAGEMENT Risk ||||||||||"; input double Lot_B = 0.01; extern double Martingale_XB = 1.75; input double Lot_S = 0.01; extern double Martingale_XS = 1.33; extern double Booster = 2.0; extern int Max_order = 5; extern bool Tp_in_Money = true; extern double TP_in_money = 5; 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; extern int Start_Hour = 0; extern int End_Hour = 24; input string Buy_Com = __FILE__; input string Sell_Com = __FILE__; //Variabel Global datetime CurrentTime; bool EAon(){ bool eaon = false; if(POWER_ON) eaon = true; return(eaon);} int last_bar = 0; int last_tip; bool clear; double pips2dbl, pips2point, pipValue, profit; double HL1; double HL2; int OrderOpRetry=5; double slb,tpb,sls,tps,pt; int ras,wt,wk,ticketb,tickets; double last_profit, last_lot, 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);} //+------------------------------------------------------------------+ int init() { //---- if(Digits==3 || Digits==5) pt=10*Point; else pt=Point; //---- return(0); } //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ int start() { // Martingale BUY double LotB = (AccountEquity() * Lot_B /(Booster*100)); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) LotB = (AccountEquity() * Lot_B /(Booster*100)); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) LotB = Martingale_XB*last_lot; if( last_profit > 0 ) LotB = (AccountEquity() * Lot_B /(Booster*100)); // Martingale SELL double LotS = (AccountEquity() * Lot_S /(Booster*100)); if( OrdersTotal() == 0 && OrdersHistoryTotal() == 0) LotS = (AccountEquity() * Lot_S /(Booster*100)); else if( OrdersTotal() == 0&& OrdersHistoryTotal() > 0 ) last_history_profit(); if( last_profit < 0 ) LotS = Martingale_XS*last_lot; if( last_profit > 0 ) LotS = (AccountEquity() * Lot_S /(Booster*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 ); if(Tp_in_Money && TP_in_money<=money()) closeall(); int res; //--- go trading only for first tiks of new bar if(Volume[0]>1) double rhigh = iHigh(Symbol(),Period(),iHighest(Symbol(), Period(), MODE_HIGH, 5,1+1)); double rlow = iLow(Symbol(),Period(),iLowest(Symbol(), Period(), MODE_LOW, 5, 1+1)); double ihigh0 = (iHigh ( Symbol (), PERIOD_CURRENT , iHighest ( Symbol (), PERIOD_CURRENT , MODE_HIGH, 5 , 0 ))); double ihigh1=(iHigh ( Symbol (), PERIOD_CURRENT , iHighest ( Symbol (), PERIOD_CURRENT , MODE_HIGH, 5 , 1 ))) ; double ilow0=(iLow ( Symbol (), PERIOD_CURRENT , iLowest ( Symbol (), PERIOD_CURRENT , MODE_LOW, 5 , 0 ))); double ilow1=(iLow ( Symbol (), PERIOD_CURRENT , iLowest ( Symbol (), PERIOD_CURRENT , MODE_LOW, 5 , 1 ))); double CLOSE = iClose(Symbol(),0, 1); double HIGH = iHigh(Symbol(),0, 1); double LOW = iLow(Symbol(),0, 1); double CCI = iCCI(NULL,PERIOD_CURRENT,11,PRICE_TYPICAL,0); double HL1 = (ihigh0 - ilow0); double HL2 = ((ihigh1) - (ilow1)); //--- SELL conditions if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1)<iBands(NULL,PERIOD_CURRENT,200,0,0,PRICE_OPEN,MODE_LOWER,1)) if((CLOSE < rlow && 1 > 0) || (LOW < rlow)) if ((CCI <= -100) && (CCI > -125)) if ((HL1)<(HL2)) if(totalorder(0)<Max_order) if (EAon() ) if (DaytoTrade() ) if(Hour_trade()==1) { res=OrderSend(Symbol(),OP_SELL,LotS,Bid,3,sls,tps,Sell_Com,Magic,0,Red); if(res>0) wt=Time[0]; } //--- BUY conditions if(iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1)>iBands(NULL,PERIOD_CURRENT,200,0,0,PRICE_OPEN,MODE_UPPER,1)) if((CLOSE > rhigh && 1 > 0) || (HIGH > rhigh)) if ((CCI >= 100) && (CCI < 125)) if ((HL1)<(HL2)) if(totalorder(0)<Max_order) if (EAon() ) if (DaytoTrade() ) if(Hour_trade()==1) { res=OrderSend(Symbol(),OP_BUY,LotB,Ask,3,slb,tpb,Buy_Com,Magic,0,Blue); if(res>0) wt=Time[0]; } 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 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); } } } //+------------------------------------------------------------------+ double money() { double dp=0; int i; for(i=0; i<OrdersTotal(); i++) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; dp+=OrderProfit(); } return(dp); } // 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); } //+------------------------------------------------------------------+ 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

    Let's Go !
    A vous de jouer.. (On se tient au courant)

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ input string IndicatorName="MyEA_%R & ML"; extern int Magic = 1; extern bool BUY_ON = true; extern bool SELL_ON = true; extern bool TRAIL_ON = true; extern bool _MFI = FALSE; extern bool _BK_Turtle = FALSE; extern bool _MA = FALSE; extern bool _MA2 = 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 bool _HAMM = FALSE; extern bool _VOLUM = FALSE; extern bool _PIVOT = FALSE; extern bool _ATR = 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.1; extern double TS_ATR = 2; extern double SL_ATR = 2.2; extern double TP_ATR = 999; extern string _ = "|||||||||||||||||||"; sinput ENUM_TIMEFRAMES TF_Pivot = PERIOD_M5;// Timeframe extern double CCI_Period = 14; extern double cciMin = -150; extern double cciMax = 150; extern double ATR_Multiplier = 2; //ATR Multiplier extern int ATR_Period = 10; extern double Coef_Volum = 2; //(4 = 25%) extern int Periode_Volum = 20; extern int MFI_Period = 14; extern int RSI_Period = 14; //rsi period extern int Kp = 20; extern int Dp = 5; extern int Sl = 10; 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 input int MA_Mode2 = 0; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma extern int MA_Open = 20; extern int MA_Open2 = 200; extern int BK_Turtle = 10; extern bool StrictEntry = true; extern int ADX_Period = 50; extern int ADX_Th = 25; input int BB_period = 20; input double BB_deviation = 2.25; 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 EAon_Buy(){ bool eaon = false; if(BUY_ON) eaon = true; return(eaon);} bool EAon_Sell(){ bool eaon = false; if(SELL_ON) eaon = true; return(eaon);} 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);} bool _MA2_(){ bool _Ma2 = false; if(_MA2) _Ma2 = true; return(_Ma2);} bool _HAMM_(){ bool _Hamm = false; if(_HAMM) _Hamm = true; return(_Hamm);} bool _VOLUM_(){ bool _Vol = false; if(_VOLUM) _Vol = true; return(_Vol);} bool _PIV_(){ bool _Piv = false; if(_PIVOT) _Piv = true; return(_Piv);} bool _ATR_(){ bool _atr = false; if(_ATR) _atr = true; return(_atr);} //+------------------------------------------------------------------+ //| 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 (EAon_Sell() ) if (EAon_Buy() ) 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); double k = (High [1] - Low [1]) /3; double h = (Low [1] - High [1]) /3; double atr = iATR(NULL,PERIOD_CURRENT,ATR_Period,0); double UpTrend = (High[1] + Low[1]) / 2 - (ATR_Multiplier * atr); double DownTrend = (High[1] + Low[1]) / 2 + (ATR_Multiplier * atr); 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((((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,BB_deviation,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); } { if((iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL,PERIOD_CURRENT,MA_Open2,0,MA_Mode2,PRICE_CLOSE,1)) && (_MA2_())) 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] < (High [1] +2*h)) && (Close [1] < (High [1] +2*h)) && (_HAMM_())) 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 ((Volume[1] > Volume[Periode_Volum]/Coef_Volum) && (_VOLUM_())) 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 ((Bid <= Pivot) && (_PIV_())) 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] < DownTrend) && (_ATR_())) 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,BB_deviation,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); } { if((iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL,PERIOD_CURRENT,MA_Open2,0,MA_Mode2,PRICE_CLOSE,1)) && (_MA2_())) 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] > (Low [1] +2*k))&& (Close [1] > (Low [1] +2*k)) && (_HAMM_())) 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 ((Volume[1] > Volume[Periode_Volum]/Coef_Volum) && (_VOLUM_())) 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 ((Ask >= Pivot) && (_PIV_())) 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] > UpTrend) && (_ATR_())) 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

    Mise a jour BUG Only Buy et Only Sell.
    Elargissement de la liste de fonctions : Engulfing, sur achat /sur vente, WPR, DeMarker .. ...

    Code
    //+------------------------------------------------------------------+ //| aRka3579 | //+------------------------------------------------------------------+ extern int Magic = 1; extern bool BUY_ON = true; extern bool SELL_ON = true; extern bool TRAIL_ON = true; input string IndicatorName="MyEA_%R & ML"; extern bool _ATR = FALSE; extern bool _ADX = FALSE; extern bool _BK_Turtle = FALSE; extern bool _BB = FALSE; extern bool _CCI = FALSE; extern bool _DeMARKER = FALSE; extern bool _DeMARKERsurAV = FALSE; extern bool _ENGULF = FALSE; extern bool _HAMM = FALSE; extern bool _HEIK_ASHI = FALSE; extern bool _MA = FALSE; extern bool _MA2 = FALSE; extern bool _MFI = FALSE; extern bool _MFIsurAV = FALSE; extern bool _PIVOT = FALSE; extern bool _RSI = FALSE; extern bool _RSIsurAV = FALSE; extern bool _STOCH = FALSE; extern bool _STOCHsurAV = FALSE; extern bool _TKS = FALSE; extern bool _VOLUM = FALSE; extern bool _WPR = 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.1; extern double TS_ATR = 1.1; extern double SL_ATR = 1.1; extern double TP_ATR = 999; sinput ENUM_TIMEFRAMES TF_Pivot = PERIOD_M5; extern double CCI_Period = 14; extern double cciMin = -150; extern double cciMax = 150; extern double ATR_Multiplier = 2; extern int ATR_Period = 10; extern double Coef_Volum = 2; //(4 = 25%) extern int Periode_Volum = 20; extern int DeMark_period = 14; extern double DeMark_Upper = 0.70; extern double DeMark_Lower = 0.30; extern int MFI_Period = 14; extern int MFI_Up = 80; extern int MFI_Dn = 20; extern int RSI_Period = 14; extern int RSI_Up = 80; extern int RSI_Dn = 20; extern int WPR_Period = 14; extern int WPR_Up = -20; extern int WPR_Dn = -80; extern int Kp = 20; extern int Dp = 5; extern int Sl = 10; input int STOCK_Mode = 0; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma extern int ST_Up = 80; extern int ST_Dn = 20; input int MA_Mode = 0; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma input int MA_Mode2 = 0; // 0 = sma, 1 = ema, 2 = smma, 3 = lwma extern int MA_Open = 20; extern int MA_Open2 = 200; extern int BK_Turtle = 10; extern bool StrictEntry = true; extern int ADX_Period = 23; extern int ADX_Th = 23; input int BB_period = 20; input double BB_deviation = 2.25; 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 EAon_Buy(){ bool eaon = false; if(BUY_ON) eaon = true; return(eaon);} bool EAon_Sell(){ bool eaon = false; if(SELL_ON) eaon = true; return(eaon);} 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(_STOCH) _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);} bool _MA2_(){ bool _Ma2 = false; if(_MA2) _Ma2 = true; return(_Ma2);} bool _HAMM_(){ bool _Hamm = false; if(_HAMM) _Hamm = true; return(_Hamm);} bool _VOLUM_(){ bool _Vol = false; if(_VOLUM) _Vol = true; return(_Vol);} bool _PIV_(){ bool _Piv = false; if(_PIVOT) _Piv = true; return(_Piv);} bool _ATR_(){ bool _atr = false; if(_ATR) _atr = true; return(_atr);} bool _RSIsurAV_(){ bool _Rsi2 = false; if(_RSIsurAV) _Rsi2 = true; return(_Rsi2);} bool _MFIsurAV_(){ bool _Mfi2 = false; if(_MFIsurAV) _Mfi2 = true; return(_Mfi2);} bool _STOCHsurAV_(){ bool _Stock = false; if(_STOCHsurAV) _Stock = true; return(_Stock);} bool _WPR_(){ bool _Wpr = false; if(_WPR) _Wpr = true; return(_Wpr);} bool _HEIKIN_(){ bool _Heikin = false; if(_WPR) _Heikin = true; return(_Heikin);} bool _ENGULF_(){ bool _Engul = false; if(_ENGULF) _Engul = true; return(_Engul);} bool _DEMARKER_(){ bool _DeM = false; if(_DeMARKER) _DeM = true; return(_DeM);} bool _DEMARKERsurAV_(){ bool _DeM2 = false; if(_DeMARKERsurAV) _DeM2 = true; return(_DeM2);} //+------------------------------------------------------------------+ //| 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 haLowHigh_1 = iCustom(Symbol(),PERIOD_CURRENT,"Heiken Ashi",Red,White,Red,White,0,1); double haOpen_1 = iCustom(Symbol(),PERIOD_CURRENT,"Heiken Ashi",Red,White,Red,White,2,1); double haClose_1 = iCustom(Symbol(),PERIOD_CURRENT,"Heiken Ashi",Red,White,Red,White,3,1); double haLowHigh_0 = iCustom(Symbol(),PERIOD_CURRENT,"Heiken Ashi",Red,White,Red,White,0,0); double haOpen_0 = iCustom(Symbol(),PERIOD_CURRENT,"Heiken Ashi",Red,White,Red,White,2,0); double haClose_0 = iCustom(Symbol(),PERIOD_CURRENT,"Heiken Ashi",Red,White,Red,White,3,0); 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 op1 = iOpen(Symbol(),PERIOD_CURRENT,1); double cl1 = iClose(Symbol(),PERIOD_CURRENT,1); double op2 = iOpen (Symbol(),PERIOD_CURRENT,2); double cl2 = iClose(Symbol(),PERIOD_CURRENT,2); 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); double k = (High [1] - Low [1]) /3; double h = (Low [1] - High [1]) /3; double atr = iATR(NULL,PERIOD_CURRENT,ATR_Period,0); double UpTrend = (High[1] + Low[1]) / 2 - (ATR_Multiplier * atr); double DownTrend = (High[1] + Low[1]) / 2 + (ATR_Multiplier * atr); 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); int i = 0; //--- SELL conditions { if (EAon_Sell() ) 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 (EAon_Sell() ) 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 (EAon_Sell() ) 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 (EAon_Sell() ) 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)) && (_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 (EAon_Sell() ) 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 (EAon_Sell() ) 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 (EAon_Sell() ) if (((iADX(NULL,0,23,PRICE_HIGH,MODE_MAIN,0)> 23) && iADX(NULL,0,23,PRICE_HIGH,MODE_MINUSDI,0)>iADX(NULL,0,23,PRICE_HIGH,MODE_PLUSDI,0)) && (_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 (EAon_Sell() ) 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 (EAon_Sell() ) 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); } { if (EAon_Sell() ) if((iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) < iMA(NULL,PERIOD_CURRENT,MA_Open2,0,MA_Mode2,PRICE_CLOSE,1)) && (_MA2_())) 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 (EAon_Sell() ) if ((Open [1] < (High [1] +2*h)) && (Close [1] < (High [1] +2*h)) && (_HAMM_())) 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 (EAon_Sell() ) if ((Volume[1] > Volume[Periode_Volum]/Coef_Volum) && (_VOLUM_())) 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 (EAon_Sell() ) if ((Bid <= Pivot) && (_PIV_())) 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 (EAon_Sell() ) if ((Open [1] < DownTrend) && (_ATR_())) 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 (EAon_Sell() ) if (((iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0) > RSI_Up) && (iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0 < 100))) && (_RSIsurAV_())) 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 (EAon_Sell() ) if (((iMFI(NULL,0,MFI_Period,0) > MFI_Up) && (iMFI(NULL,0,MFI_Period,0 < 100))) && (_MFIsurAV_())) 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 (EAon_Sell() ) if((iStochastic(NULL,0,Kp,Dp,Sl,STOCK_Mode,0,MODE_MAIN,0) > ST_Up ) && (_STOCHsurAV_())) 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 (EAon_Sell() ) if((iWPR(NULL,0,WPR_Period,i+1) < WPR_Dn)&&(iWPR(NULL,0,WPR_Period,i) > WPR_Dn) && (_WPR_())) 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 (EAon_Sell() ) if((haClose_0<haOpen_0 && haOpen_0==haLowHigh_0) && (haClose_1<haOpen_1 && haOpen_1!=haLowHigh_1) && (_HEIKIN_())) 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 (EAon_Sell() ) if ((op2<cl2 && op1>cl1 && op2>cl1) && (_ENGULF_())) 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 (EAon_Sell() ) if((iDeMarker(NULL,PERIOD_CURRENT,DeMark_period,0) < DeMark_Lower) && (_DEMARKER_())) 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 (EAon_Sell() ) if((iDeMarker(NULL,PERIOD_CURRENT,DeMark_period,0) > DeMark_Upper) && (_DEMARKERsurAV_())) 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 (EAon_Buy() ) 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 (EAon_Buy() ) 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 (EAon_Buy() ) 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 (EAon_Buy() ) 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)) && (_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 (EAon_Buy() ) 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 (EAon_Buy() ) 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 (EAon_Buy() ) if (((iADX(NULL,0,23,PRICE_HIGH,MODE_MAIN,0)> 23) && iADX(NULL,0,23,PRICE_HIGH,MODE_PLUSDI,0)>iADX(NULL,0,23,PRICE_HIGH,MODE_MINUSDI,0)) && (_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 (EAon_Buy() ) 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 (EAon_Buy() ) 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); } { if (EAon_Buy() ) if((iMA(NULL,PERIOD_CURRENT,1,0,MODE_SMA,PRICE_CLOSE,1) > iMA(NULL,PERIOD_CURRENT,MA_Open2,0,MA_Mode2,PRICE_CLOSE,1)) && (_MA2_())) 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 (EAon_Buy() ) if ((Open [1] > (Low [1] +2*k))&& (Close [1] > (Low [1] +2*k)) && (_HAMM_())) 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 (EAon_Buy() ) if ((Volume[1] > Volume[Periode_Volum]/Coef_Volum) && (_VOLUM_())) 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 ((Ask >= Pivot) && (_PIV_())) 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 (EAon_Buy() ) if ((Open [1] > UpTrend) && (_ATR_())) 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 (EAon_Buy() ) if (((iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0) < RSI_Dn) && (iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0 > 0))) && (_RSIsurAV_())) 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 (EAon_Buy() ) if (((iMFI(NULL,0,MFI_Period,0) < MFI_Dn) && (iMFI(NULL,0,MFI_Period,0 > 0))) && (_MFIsurAV_())) 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 (EAon_Buy() ) if((iStochastic(NULL,0,Kp,Dp,Sl,STOCK_Mode,0,MODE_MAIN,0) < ST_Dn ) && (_STOCHsurAV_())) 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 (EAon_Buy() ) if((iWPR(NULL,0,WPR_Period,i) > WPR_Up) && (iWPR(NULL,0,WPR_Period,i+1) < WPR_Up) && (_WPR_())) 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 (EAon_Buy() ) if((haClose_0>haOpen_0 && haOpen_0==haLowHigh_0) && (haClose_1>haOpen_1 && haOpen_1!=haLowHigh_1) && (_HEIKIN_())) 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 (EAon_Buy() ) if((op2>cl2 && op1<cl1 && op2<cl1) && (_ENGULF_())) 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 (EAon_Buy() ) if((iDeMarker(NULL,PERIOD_CURRENT,DeMark_period,0) > DeMark_Upper) && (_DEMARKER_())) 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 (EAon_Buy() ) if((iDeMarker(NULL,PERIOD_CURRENT,DeMark_period,0) < DeMark_Lower) && (_DEMARKERsurAV_())) 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); }
Page 2