//////////////////////////////////////////////////////// // Momods_Night_Scalper_V1.3 // // Coded by Momods @ worldwide-invest.org // // March 17, 2013 // //////////////////////////////////////////////////////// // If you make money from this EA // // please make donnation to my paypal Account // // mohddisi@yahoo.com // //////////////////////////////////////////////////////// //V.123 (March 17, 2013) Added second condition for Fractals signal // Added MA Slope filter // Added settings internally extern string EA_Name= "Momods_Night_Scalper_V1.3"; int MAGIC = 44525211; extern bool New_Trade=True; extern string Suffix=""; extern string S0="----------------------"; extern double lot = 0; extern double Risk = 10.0; double TakeProfit = 50; double StopLoss = 40; int Slippage = 3; double Max_Spread = 6.0; string S1="----------------------"; bool Allow_Second_Trade=false; double Distance = 10; double Lot_Factor = 0.5; extern string S2="----------------------"; extern int GMT_Offset = 0; int Open_Hour = 20; int Close_Hour = 23; bool TradeOnFriday = False; int Friday_Hour =15; string S3="----------------------"; bool Use_CCI = true; int CCI_Period = 10; double CCI_Entry = 200; double CCI_Exit = 140; string S4="----------------------"; bool Use_WPR = true; int WPR_Period = 10; double WPR_Entry = 90; double WPR_Exit = 35; string S5="----------------------"; bool Use_Fractals = true; double MidFractalDist = 5; double OppositFractalDist=9; string S6="----------------------"; bool Use_MA1 = False; double MA_Period1 = 75; bool Use_MA2 = False; double MA_Period2 = 19; bool Use_MA2_Slope = False; double MA_Slope = 1; string S7="---------Global Variables---------------"; bool Trade; datetime Last_Time; double Lot; double LastUpFractal,LastDownFractal; double midFractal; int SpreadSampleSize = 10; double Spread[0]; string Session; int Magic; int CCI_Buy_Sig; int CCI_Sell_Sig; int WPR_Buy_Sig; int WPR_Sell_Sig; int MA_Buy_Sig1; int MA_Sell_Sig1; int MA_Buy_Sig2; int MA_Sell_Sig2; int Fractals_Buy_Sig; int Fractals_Sell_Sig; int CCI_Exit_Buy_Sig; int CCI_Exit_Sell_Sig; int WPR_Exit_Buy_Sig; int WPR_Exit_Sell_Sig; int MA_Slope_Buy_Sig; int MA_Slope_Sell_Sig; int init() { Magic=MAGIC; if (Symbol()=="EURCAD"+Suffix) { Magic=55441;Max_Spread=6.0;StopLoss= 40;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=5;OppositFractalDist=10;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="EURGBP"+Suffix) { Magic=55442;Max_Spread=4.0;StopLoss= 40;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=4;OppositFractalDist=7;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="USDCAD"+Suffix) { Magic=55443;Max_Spread=4.0;StopLoss= 40;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=5;OppositFractalDist=9;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="EURCHF"+Suffix) { Magic=55444;Max_Spread=5.0;StopLoss= 40;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=5;OppositFractalDist=9;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="USDCHF"+Suffix) { Magic=55445;Max_Spread=4.0;StopLoss= 40;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=5;OppositFractalDist=9;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="GBPCHF"+Suffix) { Magic=55446;Max_Spread=7.0;StopLoss= 50;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=6;OppositFractalDist=11;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="GBPCAD"+Suffix) { Magic=55447;Max_Spread=8.0;StopLoss= 50;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=7;OppositFractalDist=13;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="EURUSD"+Suffix) { Magic=55448;Max_Spread=3.0;StopLoss= 40;Open_Hour= 20;Close_Hour=23;Use_CCI= false;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=8;WPR_Entry=93;WPR_Exit=45; Use_Fractals=True;MidFractalDist=10;OppositFractalDist=15;Use_MA1=true;MA_Period1=75;Use_MA2=true;MA_Period2=20;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="CADJPY"+Suffix) Magic=55449; if (Symbol()=="GBPJPY"+Suffix) Magic=554410; if (Symbol()=="CADCHF"+Suffix) { Magic=554411;Max_Spread=8.0;StopLoss= 50;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=7;OppositFractalDist=13;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="GBPUSD"+Suffix) { Magic=554412;Max_Spread=4.0;StopLoss= 40;Open_Hour= 20;Close_Hour=23;Use_CCI= True;CCI_Period=10;CCI_Entry=200;CCI_Exit=140;Use_WPR=true;WPR_Period=10;WPR_Entry=90;WPR_Exit=40; Use_Fractals=true;MidFractalDist=5;OppositFractalDist=9;Use_MA1=False;MA_Period1=25;Use_MA2_Slope=False;MA_Slope= 5;} if (Symbol()=="USDJPY"+Suffix) Magic=554413; if (Symbol()=="AUDUSD"+Suffix) Magic=554414; if (Symbol()=="AUDCAD"+Suffix) Magic=554415; if (Symbol()=="AUDJPY"+Suffix) Magic=554416; if (Symbol()=="EURAUD"+Suffix) Magic=554417; if (Symbol()=="GBPAUD"+Suffix) Magic=554418; if (Symbol()=="EURNZD"+Suffix) Magic=554419; if (Symbol()=="GBPNZD"+Suffix) Magic=554420; if (Symbol()=="EURNOK"+Suffix) Magic=554421; if (Symbol()=="EURSEK"+Suffix) Magic=554422; if (Symbol()=="NZDUSD"+Suffix) Magic=554423; if (Symbol()=="NZDJPY"+Suffix) Magic=554424; if (Symbol()=="EURJPY"+Suffix) Magic=554425; if (Symbol()=="AUDCHF"+Suffix) Magic=554426; if (Symbol()=="NZDCHF"+Suffix) Magic=554427; return (0); } int deinit() { return (0); } // EA Start int start() { if (!IsTesting() || !IsOptimization()) Display(); //////////////////// Calculate Average Spread ///////////////////// if (!IsTesting() || !IsOptimization()) Spread(Ask-Bid); ///////////////////////////// Indicator(s) ///////////////////////// double CCI_1 = iCCI(NULL, 0, CCI_Period, PRICE_CLOSE, 0); double WPR_1 = iWPR(NULL, 0, WPR_Period, 0); double MA_1_1 = iMA(NULL,0,MA_Period1,0,MODE_SMMA,PRICE_CLOSE,1); double MA_1_2 = iMA(NULL,0,MA_Period1,0,MODE_SMMA,PRICE_CLOSE,2); double MA_2_1 = iMA(NULL,0,MA_Period2,0,MODE_SMMA,PRICE_CLOSE,1); double MA_2_2 = iMA(NULL,0,MA_Period2,0,MODE_SMMA,PRICE_CLOSE,2); if (MyRealOrdersTotal(Magic)<1) { for(int a=1;a<Bars;a++){ if(iFractals(NULL, 0, MODE_UPPER,a)!=0){ LastUpFractal=iFractals(NULL, 0, MODE_UPPER,a); break; } } for(int s=1;s<Bars;s++){ if(iFractals(NULL, 0, MODE_LOWER,s)!=0){ LastDownFractal=iFractals(NULL, 0, MODE_LOWER,s); break; } } midFractal=(LastUpFractal+LastDownFractal)/2; } //////////////////////////////////// Trade Signals /////////////////////////////////////////////// CCI_Buy_Sig=0; CCI_Sell_Sig=0; WPR_Buy_Sig=0; WPR_Sell_Sig=0; MA_Buy_Sig1=0; MA_Sell_Sig1=0; MA_Buy_Sig2=0; MA_Sell_Sig2=0; MA_Slope_Buy_Sig=0; MA_Slope_Sell_Sig=0; Fractals_Buy_Sig=0; Fractals_Sell_Sig=0; if (!Use_CCI) {CCI_Buy_Sig=1;CCI_Sell_Sig=1;} if (!Use_WPR) {WPR_Buy_Sig=1;WPR_Sell_Sig=1;} if (!Use_MA1) {MA_Buy_Sig1=1; MA_Sell_Sig1=1;} if (!Use_MA2) {MA_Buy_Sig2=1; MA_Sell_Sig2=1;} if (!Use_MA2_Slope) {MA_Slope_Buy_Sig=1; MA_Slope_Sell_Sig=1;} if (!Use_Fractals) {Fractals_Buy_Sig=1; Fractals_Sell_Sig=1;} if (Use_CCI && CCI_1<-CCI_Entry) CCI_Buy_Sig=1; if (Use_CCI && CCI_1>CCI_Entry) CCI_Sell_Sig=1; if (Use_WPR && WPR_1<-WPR_Entry) WPR_Buy_Sig=1; if (Use_WPR && WPR_1>-(100-WPR_Entry)) WPR_Sell_Sig=1; if (Use_MA1 && MA_1_1>MA_1_2) MA_Buy_Sig1=1; if (Use_MA1 && MA_1_1<MA_1_2) MA_Sell_Sig1=1; if (Use_MA2 && MA_2_1>MA_2_2) MA_Buy_Sig2=1; if (Use_MA2 && MA_2_1<MA_2_2) MA_Sell_Sig2=1; if (Use_MA2_Slope && (MA_2_1-MA_2_2)>=MA_Slope*PointValue()) MA_Slope_Buy_Sig=1; if (Use_MA2_Slope && (MA_2_2-MA_2_1)>=MA_Slope*PointValue()) MA_Slope_Sell_Sig=1; if (Use_Fractals && Ask<(midFractal-MidFractalDist*PointValue()) && Ask<(LastUpFractal-OppositFractalDist*PointValue())) Fractals_Buy_Sig=1; if (Use_Fractals && Bid>(midFractal+MidFractalDist*PointValue()) && Bid>(LastDownFractal+OppositFractalDist*PointValue())) Fractals_Sell_Sig=1; if (!Use_CCI && !Use_WPR && !Use_Fractals) {Print("You must use at least one signal (CCI, WPR, or Fractals"); return(0);} //////////////////////////////////// Exit Signals /////////////////////////////////////////////// CCI_Exit_Buy_Sig=0; CCI_Exit_Sell_Sig=0; WPR_Exit_Buy_Sig=0; WPR_Exit_Sell_Sig=0; if (Use_CCI && CCI_1>CCI_Exit) CCI_Exit_Buy_Sig=1; if (Use_CCI && CCI_1<-CCI_Exit) CCI_Exit_Sell_Sig=1; if (Use_WPR && WPR_1>-WPR_Exit) WPR_Exit_Buy_Sig=1; if (Use_WPR && WPR_1<(-100+WPR_Exit)) WPR_Exit_Sell_Sig=1; //////////////////////////////////// Close Trades /////////////////////////////////////////////// for(int k=0; k<OrdersTotal(); k++) { OrderSelect(k, SELECT_BY_POS, MODE_TRADES); if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && (CCI_Exit_Buy_Sig==1 || WPR_Exit_Buy_Sig==1)) { //OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position CloseAll(Magic); } if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic && (CCI_Exit_Sell_Sig==1 || WPR_Exit_Sell_Sig==1)) { //OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position CloseAll(Magic); } } //////////////////////////////////// Trade Timing /////////////////////////////////////////////// Trade = true; if (!TradeOnFriday && DayOfWeek() == 5) Trade = FALSE; if (TradeOnFriday && DayOfWeek() == 5 && TimeHour(TimeCurrent()) > (Friday_Hour+GMT_Offset)) Trade = FALSE; if (Open_Hour+GMT_Offset>=24)Open_Hour=Open_Hour-24; if (Close_Hour+GMT_Offset>=24)Close_Hour=Close_Hour-24; if ((Open_Hour+GMT_Offset) < (Close_Hour+GMT_Offset) && TimeHour(TimeCurrent()) < (Open_Hour+GMT_Offset) || TimeHour(TimeCurrent()) >= (Close_Hour+GMT_Offset)) Trade = FALSE; if ((Open_Hour+GMT_Offset) > (Close_Hour+GMT_Offset) && (TimeHour(TimeCurrent()) < (Open_Hour+GMT_Offset) && TimeHour(TimeCurrent()) >= (Close_Hour+GMT_Offset))) Trade = FALSE; if (Month()==12 && Day()>22) Trade = FALSE; if (Month()==1 && Day()<5) Trade = FALSE; if (Trade && MyRealOrdersTotal(Magic)==0 && Spread()<Max_Spread*PointValue()) Session="Trade Session Open .. Waiting for trades"; if (Trade && MyRealOrdersTotal(Magic)==0 && Spread()>Max_Spread*PointValue()) Session="Trade Session Open .. Spread is High .. Trading Halted"; if (!Trade && MyRealOrdersTotal(Magic)==0) Session="Trade Session Closed"; if (!Trade && MyRealOrdersTotal(Magic)>0) Session="Trade Session Closed .. Waiting to exit trades"; //////////////////////////////////// Open Trade /////////////////////////////////////////////// if (New_Trade && Spread()<Max_Spread*PointValue() && MyRealOrdersTotal(Magic)==0 && Trade && Time[0]!=Last_Time && CCI_Buy_Sig==1 && WPR_Buy_Sig==1 && MA_Buy_Sig1==1 && MA_Buy_Sig2==1&& MA_Slope_Buy_Sig==1 && Fractals_Buy_Sig==1) { Lot=CalculateLots(Risk); int Ticket_1 = OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippage, 0, 0, EA_Name, Magic, 0, Lime); if (Ticket_1>0) { Last_Time=iTime(NULL,0,0); ModifyAll(); } } if (New_Trade && Spread()<Max_Spread*PointValue() && MyRealOrdersTotal(Magic)==0 && Trade && Time[0]!=Last_Time && CCI_Sell_Sig==1 && WPR_Sell_Sig==1 && MA_Sell_Sig1==1 && MA_Sell_Sig2==1&& MA_Slope_Sell_Sig && Fractals_Sell_Sig==1) { Lot=CalculateLots(Risk); int Ticket_2 = OrderSend(Symbol(), OP_SELL, Lot, Bid, Slippage, 0, 0, EA_Name, Magic, 0, Red); if (Ticket_2>0) { Last_Time=iTime(NULL,0,0); ModifyAll(); } } //////////////////////////////////// Second Trade /////////////////////////////////////////////// if (MyRealOrdersTotal(Magic)==1 && Allow_Second_Trade && Time[0]!=Last_Time && LastOpenType()==0 && Ask<=(LastBuyPrice()-Distance*PointValue())) { Lot=CalculateLots(Risk*Lot_Factor); Ticket_1 = OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippage, 0, 0, EA_Name, Magic, 0, Lime); if (Ticket_1>0) { Last_Time=iTime(NULL,0,0); ModifyAll(); } } if (MyRealOrdersTotal(Magic)==1 && Allow_Second_Trade && Time[0]!=Last_Time && LastOpenType()==1 && Bid>=(LastSellPrice()+Distance*PointValue())) { Lot=CalculateLots(Risk*Lot_Factor); Ticket_2 = OrderSend(Symbol(), OP_SELL, Lot, Bid, Slippage, 0, 0, EA_Name, Magic, 0, Red); if (Ticket_2>0) { Last_Time=iTime(NULL,0,0); ModifyAll(); } } return (0); } // EA End ///////////////////////////////////////////////////////////////////////////////////////////////////////////// int MyRealOrdersTotal(int Magic) { int c=0; int total = OrdersTotal(); for (int cnt = 0 ; cnt < total ; cnt++) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && OrderType()<=OP_SELL) { c++; } } return(c); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// double LastSellPrice() { double l_ord_open_price_8=0; int l_ticket_24; double ld_unused_0 = 0; int l_ticket_20 = 0; for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL) { l_ticket_24 = OrderTicket(); if (l_ticket_24 > l_ticket_20) { l_ord_open_price_8 = OrderOpenPrice(); ld_unused_0 = l_ord_open_price_8; l_ticket_20 = l_ticket_24; } } } return (l_ord_open_price_8); } ////////////////////////////////////////////////////////////////////////////////////////////////////////// double LastBuyPrice() { double l_ord_open_price_8=0; int l_ticket_24=0; double ld_unused_0 = 0; int l_ticket_20 = 0; for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUY ) { l_ticket_24 = OrderTicket(); if (l_ticket_24 > l_ticket_20) { l_ord_open_price_8 = OrderOpenPrice(); ld_unused_0 = l_ord_open_price_8; l_ticket_20 = l_ticket_24; } } } return (l_ord_open_price_8); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// int LastOpenType() { int l_ord_type=-1; int l_ticket_24=0; double ld_unused_0 = 0; int l_ticket_20 = 0; for (int l_pos_16 = OrdersTotal() - 1; l_pos_16 >= 0; l_pos_16--) { OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue; if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() <= OP_SELL) { l_ticket_24 = OrderTicket(); if (l_ticket_24 > l_ticket_20) { l_ord_type = OrderType(); ld_unused_0 = l_ord_type; l_ticket_20 = l_ticket_24; } } } return (l_ord_type); } //////////////////////////////////////////////////////////////////////////////////////////////////////// int CloseAll(int Magic) { for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderCloseTime()==0) { if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue); if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red); } } return(0); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// double CalculateLots(double RISK) { int Lot_Dec; double l_minlot_0 = MarketInfo(Symbol(), MODE_MINLOT); double l_maxlot_8 = MarketInfo(Symbol(), MODE_MAXLOT); double ld_ret_16 = 0.0; if (MarketInfo(Symbol(), MODE_MINLOT) < 1.0) Lot_Dec = 1; if (MarketInfo(Symbol(), MODE_MINLOT) < 0.1) Lot_Dec = 2; if (MarketInfo(Symbol(), MODE_MINLOT) < 0.01) Lot_Dec = 3; if (MarketInfo(Symbol(), MODE_MINLOT) < 0.001) Lot_Dec = 4; if (MarketInfo(Symbol(), MODE_MINLOT) < 0.0001) Lot_Dec = 5; if (lot > 0.0) {ld_ret_16 = lot;return (ld_ret_16);} if (ld_ret_16 == 0.0) { ld_ret_16=NormalizeDouble(AccountBalance() / 100000.0 * RISK, Lot_Dec); if (ld_ret_16 < l_minlot_0) ld_ret_16 = l_minlot_0; if (ld_ret_16 > l_maxlot_8) ld_ret_16 = l_maxlot_8; return (ld_ret_16); } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// double PointValue() { if (MarketInfo(Symbol(), MODE_DIGITS) == 5.0 || MarketInfo(Symbol(), MODE_DIGITS) == 3.0) return (10.0 * Point); return (Point); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void ModifyAll() { for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic ) { if (OrderStopLoss()==0) { if((OrderType()==OP_BUY)) OrderModify(OrderTicket(),OrderOpenPrice(),ND(OrderOpenPrice()-PointValue()*StopLoss), ND(OrderOpenPrice()+TakeProfit*PointValue()),0,Green); if((OrderType()==OP_SELL)) OrderModify(OrderTicket(),OrderOpenPrice(),ND(OrderOpenPrice()+PointValue()*StopLoss), ND(OrderOpenPrice()-TakeProfit*PointValue()),0,Red); } } } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// double Spread(double AddValue=0) { double LastValue; static double ArrayTotal=0; if (AddValue == 0 && SpreadSampleSize <= 0) return(Ask-Bid); if (AddValue == 0 && ArrayTotal == 0) return(Ask-Bid); if (AddValue == 0 ) return(ArrayTotal/ArraySize(Spread)); ArrayTotal = ArrayTotal + AddValue; ArraySetAsSeries(Spread, true); if (ArraySize(Spread) == SpreadSampleSize) { LastValue = Spread[0]; ArrayTotal = ArrayTotal - LastValue; ArraySetAsSeries(Spread, false); ArrayResize(Spread, ArraySize(Spread)-1 ); ArraySetAsSeries(Spread, true); ArrayResize(Spread, ArraySize(Spread)+1 ); } else ArrayResize(Spread, ArraySize(Spread)+1 ); // Print("ArraySize = ",ArraySize(lSpread)," AddedNo. = ",AddValue); ArraySetAsSeries(Spread, false); Spread[0] = AddValue; return(NormalizeDouble(ArrayTotal/ArraySize(Spread), Digits)); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// double ND(double Price) { double ND_Price=0; ND_Price = NormalizeDouble(Price,Digits); return(ND_Price); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Display() { Comment( "\n*=====================*", "\n "+EA_Name, "\n*=====================*", "\n "+Session, "\n*=====================*", "\n Broker Time = ", Hour()+" : "+Minute(), "\n Start Hour = "+DoubleToStr(Open_Hour,2), "\n End Hour = "+DoubleToStr(Close_Hour,2), "\n", "\n Magig Number = "+Magic, "\n Maximum Spread = "+DoubleToStr(Max_Spread,1), "\n Average Spread = "+DoubleToStr(Spread()/PointValue(),1), "\n Lot size = " +DoubleToStr(CalculateLots(Risk),2), "\n Stop Loss = "+DoubleToStr(StopLoss,0), "\n*=====================*", "\n B A L A N C E = " + DoubleToStr(AccountBalance(),2), "\n E Q U I T Y = " + DoubleToStr(AccountEquity(),2), "\n*=====================*" ); }
Комментарии к исходному коду форекс советника Momods_Night_Scalper_V1_3_Basic.mq4
В целях безопасности и борьбы со спамом в тексте комментариев запрещено размещать html-теги и ссылки. Благодарим за понимание.