//+------------------------------------------------------------------+ //| Your_Lucky_EURGBP_v1e.mq4 | //| Copyright © 2008, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "rahman_DGBeta (_rdb_)" #property link "abdulrahman_maros@yahoo.com" //====================================================================================================================================================== //salam salut saya untuk semua mql coder... //selain versi EURGBP ini masih banyak versi lain yang siap kami share kepada teman-teman semua... //mohon kiranya jika anda menggunakan script ini... jangan menghapus baris permintaan donasi... salam coder... semoga sukses... //====================================================================================================================================================== extern string Expert_Name = "Your_Lucky_v1e"; extern bool CloseAll_NOW = false; extern double TargetEquity = 5000000; extern int OpenHour = 20; extern int CloseHour = 4; extern bool LotsOptimized = true; extern int Risk = 50; extern double Lots = 0.1; extern double MaxLots = 100; extern int TP = 6; extern int SLA = 22; extern int SLB = 32; extern int Range_OP = 5; extern int Slippage = 2; extern double MaxSpread = 4; //extern int FractalRange = 320; //extern int ATR_Level = 150; extern int OPFromFractal = 7; extern bool Time_Opened_Protection = TRUE; extern bool Hidden_TP = TRUE; extern bool Hidden_SL = TRUE; //====================================================================================================================================================== extern int MaxTrades = 5; extern int MaxTradePerBar = 2; extern int MaxTradePerPosition = 3; extern int IMA_PERIOD = 11; extern int MA_AngleZero_PERIOD = 14; extern int LimitTime_1 = 60; extern int LimitTime_2 = 140; extern int LimitTime_3 = 170; extern int LimitTime_4 = 200; extern int LimitTime_5 = 240; extern int pips_1 = 3; //3; extern int pips_2 = 2; //2; extern int pips_3 = 0; //0; extern int pips_4 = 1; //1; extern int pips_5 = 4; //4; extern string created_by = "_rdb_ : 11 Desember 2008"; extern string Need_Donation = "Abdul Rahman"; extern string PayPal = "abdulrahman_maros@yahoo.com"; extern string Bank_Wire = "BCA : 7990026640"; extern string LibertyReserve = "U7067895"; //====================================================================================================================================================== int TradePerBar = 0; double Last_BUY_OpenPrice = 0; double Last_SELL_OpenPrice = 0; int MinuteToStop = 55; int Magic = 11111; int BarCount = -1; bool next_buy = true; bool next_sell = true; double LastUpFractal,LastDownFractal,TimeOfLastDownFractal,TimeOfLastUpFractal,LowRange,HighRange,PrevRange; double LastUpFractal_M30,LastDownFractal_M30,LastUpFractal_H1,LastDownFractal_H1,TimeOfLastDownFractal_H1,TimeOfLastUpFractal_H1; int FractalEnvelope=0,FractalEnvelope_H1=0,FractalEnvelope_M30=0; double midFractal=0,Fractal_SL_B1=0,Fractal_SL_S1=0; int CurrentATR,CurrentATR_H1; double mylotsi; int LotsDigit,lotsdigit; double tp, sl; double myPoint; //====================================================================================================================================================== int init() { myPoint = SetPoint(); if(1==2 || 3==4 && 5==6) return (0); if(7==8 || 9==10 && 11==12) return (0); return(0); } //====================================================================================================================================================== int start() { //====================================================================================================================================================== double MD = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2); if (MD==0.01) lotsdigit=2; else if (MD==0.10) lotsdigit=1; else lotsdigit=0; LotsDigit=lotsdigit; //====================================================================================================================================================== if(CloseAll_NOW==true) { CloseAll(); return(0); } //====================================================================================================================================================== //Close with Equity if(TargetEquity>0 && AccountEquity() >= TargetEquity) { ForceCloseAll(); return(0); } //====================================================================================================================================================== int BUY_OpenPosition = 0; int SELL_OpenPosition = 0; int TOTAL_OpenPosition = 0; int Ticket = -1; int cnt = 0; for (cnt = 0; cnt < OrdersTotal(); cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderCloseTime()==0) { TOTAL_OpenPosition++; if (OrderType() == OP_BUY) { BUY_OpenPosition++; Last_BUY_OpenPrice = OrderOpenPrice(); } if (OrderType() == OP_SELL) { SELL_OpenPosition++; Last_SELL_OpenPrice = OrderOpenPrice(); } } } //====================================================================================================================================================== for(int a=1;a<Bars;a++){ if(iFractals(NULL, PERIOD_M15, MODE_UPPER,a)!=0){ LastUpFractal=iFractals(NULL, PERIOD_M15, MODE_UPPER,a); TimeOfLastUpFractal=Time[a]; break; }//end if }//end for for(int s=1;s<Bars;s++){ if(iFractals(NULL, PERIOD_M15, MODE_LOWER,s)!=0){ LastDownFractal=iFractals(NULL, PERIOD_M15, MODE_LOWER,s); TimeOfLastDownFractal=Time[s]; break; }//end if }//end for for(int v=1;v<Bars;v++){ if(iFractals(NULL, PERIOD_H1, MODE_UPPER,v)!=0){ LastUpFractal_H1=iFractals(NULL, PERIOD_H1, MODE_UPPER,v); TimeOfLastUpFractal_H1=Time[v]; break; }//end if }//end for for(int w=1;w<Bars;w++){ if(iFractals(NULL, PERIOD_H1, MODE_LOWER,w)!=0){ LastDownFractal_H1=iFractals(NULL, PERIOD_H1, MODE_LOWER,w); TimeOfLastDownFractal_H1=Time[s]; break; }//end if }//end for //ObjectDelete("Fractal Fibo Retracement"); //ObjectCreate("Fractal Fibo Retracement",OBJ_FIBO,0,TimeOfLastUpFractal,LastUpFractal,TimeOfLastDownFractal,LastDownFractal); FractalEnvelope=MathRound((LastUpFractal-LastDownFractal)/myPoint); FractalEnvelope_H1=MathRound((LastUpFractal_H1-LastDownFractal_H1)/myPoint); midFractal=0; midFractal=(LastUpFractal-((LastUpFractal-LastDownFractal)/2)); CurrentATR=MathRound(iATR(Symbol(), PERIOD_M15,4,0)/myPoint); bool FractalIsInsideEnvelope=false; if(Close[0]<=LastUpFractal_H1 && Close[0]>=LastDownFractal_H1){ FractalIsInsideEnvelope=true; }//end if //====================================================================================================================================================== if (IsTradeTime()) { Comment( "\n "+Expert_Name, "\n\n T R A D E S E S S I O N", "\n*=====================*", "\n Broker Time = ", Hour()+" : "+Minute(), "\n Time Star Trading = ", OpenHour, "\n Time Stop Trading = ", CloseHour, "\n*=====================*", "\n Fractal Envelope = "+FractalEnvelope+" pips", "\n MidFractal = "+DoubleToStr(midFractal,Digits), //"\n ATR(4)_M5 = "+CurrentATR+" pips", "\n*=====================*", "\n L O T S = " + DoubleToStr(GetLots(),2), "\n B A L A N C E = " + DoubleToStr(AccountBalance(),2), "\n E Q U I T Y = " + DoubleToStr(AccountEquity(),2), "\n*=====================*", //saya salut dengan teman-teman coder... //saya hanya orang pelosok yang tidak berpeluang trading karena keterbatasan dana //karena itu... saya memutuskan untuk mengoprek/membuat EA dan indi untuk digunakan para trader... //mohon kiranya jika anda menggunakan script ini... jangan menghapus kalimat dibawah... salam coder... semoga sukses... "\n\n "+Expert_Name+" EA is free and still on developing", "\n You can discuss to me how to applying it or to develop this ea", "\n To support my creativity please donate for me with all yours heart...", "\n\n For further information or to make a donation please contact me on :", "\n email / PayPal : abdulrahman_maros@yahoo.com", "\n Bank Wire : BCA : 7990026640", "\n Liberty Reserve : U7067895 ( Abdul Rahman )" ); } else { Comment( "\n "+Expert_Name, "\n\n O u t O f S E S S I O N", "\n*=====================*", "\n Broker Time = ", Hour()+" : "+Minute(), "\n Time Star Trading = ", OpenHour, "\n Time Stop Trading = ", CloseHour, "\n*=====================*", "\n Fractal Envelope = "+FractalEnvelope+" pips", "\n MidFractal = "+DoubleToStr(midFractal,Digits), //"\n ATR(4)_M5 = "+CurrentATR+" pips", "\n*=====================*", "\n L O T S = " + DoubleToStr(GetLots(),2), "\n B A L A N C E = " + DoubleToStr(AccountBalance(),2), "\n E Q U I T Y = " + DoubleToStr(AccountEquity(),2), "\n*=====================*", //saya salut dengan teman-teman coder... //saya hanya orang pelosok yang tidak berpeluang trading karena keterbatasan dana //karena itu... saya memutuskan untuk mengoprek/membuat EA dan indi untuk digunakan para trader... //mohon kiranya jika anda menggunakan script ini... jangan menghapus kalimat dibawah... salam coder... semoga sukses... "\n\n "+Expert_Name+" EA is free and still on developing", "\n You can discuss to me how to applying it or to develop this ea", "\n To support my creativity please donate for me with all yours heart...", "\n\n For further information or to make a donation please contact me on :", "\n email / PayPal : abdulrahman_maros@yahoo.com", "\n Bank Wire : BCA : 7990026640", "\n Liberty Reserve : U7067895 ( Abdul Rahman )" ); } //====================================================================================================================================================== if (Time_Opened_Protection == TRUE) { for (int j = 0; j < OrdersTotal(); j++) { OrderSelect(j, SELECT_BY_POS, MODE_TRADES); //====================================================================================================================================================== if (OrderType() == OP_BUY && (OrderMagicNumber() == Magic)) { if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_1 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_2 && Bid >= OrderOpenPrice() + pips_1*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Orange); Print("Prot. Level 1 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_2 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_3 && Bid >= OrderOpenPrice() + pips_2*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Orange); Print("Prot. Level 2 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_3 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_4 && Bid >= OrderOpenPrice() + pips_3*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Orange); Print("Prot. Level 3 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_4 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_5 && Bid >= OrderOpenPrice() - pips_4*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Orange); Print("Prot. Level 4 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_5 && Bid >= OrderOpenPrice() - pips_5*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Orange); Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (DayOfWeek() == 5 && Hour()>=16) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Orange); Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } } //====================================================================================================================================================== if (OrderType() == OP_SELL && (OrderMagicNumber() == Magic)) { if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_1 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_2 && Ask <= OrderOpenPrice() - pips_1*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Orange); Print("Prot. Level 1 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_2 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_3 && Ask <= OrderOpenPrice() - pips_2*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Orange); Print("Prot. Level 2 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_3 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_4 && Ask <= OrderOpenPrice() - pips_3*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Orange); Print("Prot. Level 3 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_4 && TimeCurrent() - OrderOpenTime() < 60 * LimitTime_5 && Ask <= OrderOpenPrice() + pips_4*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Orange); Print("Prot. Level 4 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (TimeCurrent() - OrderOpenTime() > 60 * LimitTime_5 && Ask <= OrderOpenPrice() + pips_5*myPoint) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Orange); Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } if (DayOfWeek() == 5 && Hour()>=16) { RefreshRates(); OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Orange); Print("Prot. Level 5 - Close Price :" + DoubleToStr(OrderClosePrice(), Digits) + " Lots : " + DoubleToStr(OrderLots(), LotsDigit) + " Order Number : " + DoubleToStr(OrderTicket(), 0) + " Profit : $ " + DoubleToStr(OrderProfit(), 2)); } } //======== } } //====================================================================================================================================================== CloseAll(); double MA_M1 = iCustom (Symbol(),PERIOD_M1 ,"MA_AngleZeroSigma",MA_AngleZero_PERIOD,1,0,0.2,6,0,9,1,"","",4,0); if (IsTradeTime() && IsTradeTimeA()) { if(TOTAL_OpenPosition <= MaxTrades) { if(BarCount != Bars) { TradePerBar = 0; BarCount = Bars; } RefreshRates(); //====================================================================================================================================================== if ((Ask-Bid<MaxSpread*myPoint) && FractalIsInsideEnvelope && (TradePerBar <= MaxTradePerBar)) { if ((BUY_OpenPosition < 1) && MA_M1<=-0.12 && Bid<=midFractal-(OPFromFractal*myPoint) && GetSignal(OP_BUY)==1) { if(AccountFreeMarginCheck(Symbol(),OP_BUY,GetLots())<=0 || GetLastError()==134) {Print("We have no money.Reduce your Lots! Free Margin = ", AccountFreeMargin());} else { if(Hidden_TP==true && Hidden_SL==false) Ticket = OrderSend(Symbol(),OP_BUY,GetLots(),Ask,Slippage,Ask-SLB*myPoint, 0,Expert_Name+" "+Symbol(),Magic,0,Blue); else if(Hidden_TP==true && Hidden_SL==true) Ticket = OrderSend(Symbol(),OP_BUY,GetLots(),Ask,Slippage,0, 0,Expert_Name+" "+Symbol(),Magic,0,Blue); else Ticket = OrderSend(Symbol(),OP_BUY,GetLots(),Ask,Slippage,Ask-SLB*myPoint, Ask+TP*myPoint,Expert_Name+" "+Symbol(),Magic,0,Blue); if (Ticket > 0) TradePerBar++; } next_sell = true; //next_buy = false; } //============================================================= if ((BUY_OpenPosition>0) && (BUY_OpenPosition<MaxTradePerPosition) && MA_M1<=-0.12 && (Last_BUY_OpenPrice-Bid>=Range_OP*myPoint) && Bid<=midFractal-(OPFromFractal*myPoint) && GetSignal(OP_BUY)==1) { if(AccountFreeMarginCheck(Symbol(),OP_BUY,GetLots())<=0 || GetLastError()==134) {Print("We have no money.Reduce your Lots! Free Margin = ", AccountFreeMargin());} else { if(Hidden_TP==true && Hidden_SL==false) Ticket = OrderSend(Symbol(),OP_BUY,GetLots(),Ask,Slippage,Ask-SLB*myPoint, 0,Expert_Name+" "+Symbol(),Magic,0,Blue); else if(Hidden_TP==true && Hidden_SL==true) Ticket = OrderSend(Symbol(),OP_BUY,GetLots(),Ask,Slippage,0, 0,Expert_Name+" "+Symbol(),Magic,0,Blue); else Ticket = OrderSend(Symbol(),OP_BUY,GetLots(),Ask,Slippage,Ask-SLB*myPoint, Ask+TP*myPoint,Expert_Name+" "+Symbol(),Magic,0,Blue); if (Ticket > 0) TradePerBar++; } next_sell = true; next_buy = false; } //====================================================================================================================================================== if ((SELL_OpenPosition<1) && MA_M1>=0.12 && Ask>=midFractal+(OPFromFractal*myPoint) && GetSignal(OP_SELL)==1) { if(AccountFreeMarginCheck(Symbol(),OP_BUY,GetLots())<=0 || GetLastError()==134) {Print("We have no money.Reduce your Lots! Free Margin = ", AccountFreeMargin());} else { if(Hidden_TP==true && Hidden_SL==false) Ticket = OrderSend(Symbol(),OP_SELL,GetLots(),Bid,Slippage,Bid+SLB*myPoint,0,Expert_Name+" "+Symbol(),Magic,0,Red); else if(Hidden_TP==true && Hidden_SL==true) Ticket = OrderSend(Symbol(),OP_SELL,GetLots(),Bid,Slippage,0,0,Expert_Name+" "+Symbol(),Magic,0,Red); else Ticket = OrderSend(Symbol(),OP_SELL,GetLots(),Bid,Slippage,Bid+SLB*myPoint,Bid-TP * myPoint,Expert_Name+" "+Symbol(),Magic,0,Red); if (Ticket > 0) TradePerBar++; } next_buy = true; //next_sell = false; } //============================================================= if ((SELL_OpenPosition>0) && (SELL_OpenPosition<MaxTradePerPosition) && MA_M1>=0.12 && (Ask-Last_SELL_OpenPrice>=Range_OP*myPoint) && Ask>=midFractal+(OPFromFractal*myPoint) && GetSignal(OP_SELL)==1) { if(AccountFreeMarginCheck(Symbol(),OP_BUY,GetLots())<=0 || GetLastError()==134) {Print("We have no money.Reduce your Lots! Free Margin = ", AccountFreeMargin());} else { if(Hidden_TP==true && Hidden_SL==false) Ticket = OrderSend(Symbol(),OP_SELL,GetLots(),Bid,Slippage,Bid+SLB*myPoint,0,Expert_Name+" "+Symbol(),Magic,0,Red); else if(Hidden_TP==true && Hidden_SL==true) Ticket = OrderSend(Symbol(),OP_SELL,GetLots(),Bid,Slippage,0,0,Expert_Name+" "+Symbol(),Magic,0,Red); else Ticket = OrderSend(Symbol(),OP_SELL,GetLots(),Bid,Slippage,Bid+SLB*myPoint,Bid-TP * myPoint,Expert_Name+" "+Symbol(),Magic,0,Red); if (Ticket > 0) TradePerBar++; } next_buy = true; next_sell = false; } //====================================================================================================================================================== } } if ((MA_M1<0.1 && MA_M1>-0.1)) { next_sell = true; next_buy = true; } } return(0); } //----------------------------------------------------------------------------- int GetSignal(int OP) { int signal=0; int ss=0; int sx=3; if (Digits == 5 || Digits == 3) {ss=10*sx;} else {ss=sx;} if (OP==OP_BUY) { if(Ask<=NormalizeDouble(iMA(Symbol(),PERIOD_M5,IMA_PERIOD,0,MODE_SMA,PRICE_OPEN,0),Digits)-(myPoint*ss)) signal=1; } else if (OP==OP_SELL) { if(Bid>=NormalizeDouble(iMA(Symbol(),PERIOD_M5,IMA_PERIOD,0,MODE_SMA,PRICE_OPEN,0),Digits)+(myPoint*ss)) signal=1; } return(signal); } //----------------------------------------------------------------------------- void CloseAll() { for (int cnt = OrdersTotal()-1 ; cnt >= 0; cnt--) { OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderCloseTime()==0) { if (SecurProfit()==1) { if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue); if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red); } else { if (IsTradeTime()) { if((OrderType()==OP_BUY) && (((OrderOpenPrice()-Bid)/myPoint) > SLA)) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue); if((OrderType()==OP_SELL) && (((Ask-OrderOpenPrice())/myPoint) > SLA)) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red); } else { if (Hidden_SL==true) if((OrderType()==OP_BUY) && (((OrderOpenPrice()-Bid)/myPoint) > SLB)) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue); if((OrderType()==OP_SELL) && (((Ask-OrderOpenPrice())/myPoint) > SLB)) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red); } } } } } //----------------------------------------------------------------------------- void ForceCloseAll() { 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); } } } //====================================================================================================================================================== bool IsTradeTime() { if (OpenHour < CloseHour && TimeHour(TimeCurrent()) < OpenHour || TimeHour(TimeCurrent()) >= CloseHour) return (FALSE); if (OpenHour > CloseHour && (TimeHour(TimeCurrent()) < OpenHour && TimeHour(TimeCurrent()) >= CloseHour)) return (FALSE); if (OpenHour == 0) CloseHour = 24; if (Hour() == CloseHour - 1 && Minute() >= MinuteToStop) return (FALSE); return (TRUE); } //====================================================================================================================================================== bool IsTradeTimeA() { if (DayOfWeek() == 5 && Hour()>=CloseHour) return (FALSE); return (TRUE); } //====================================================================================================================================================== double GetLots() { double lots,MD,RM,FMM,MinLots,maxlot,maximlot,LotSize; int lotsdigit; LotSize = MarketInfo(Symbol(), MODE_LOTSIZE); MD = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2); RM = NormalizeDouble(MarketInfo(Symbol(), MODE_MARGINREQUIRED), 4); //====================================================================================================================================================== if (MD==0.01) lotsdigit=2; else if (MD==0.10) lotsdigit=1; else lotsdigit=0; LotsDigit=lotsdigit; //====================================================================================================================================================== if (LotsOptimized==true) lots = NormalizeDouble((AccountFreeMargin()*Risk/LotSize)/MaxTrades,LotsDigit); else lots=Lots; MinLots=NormalizeDouble(MarketInfo(Symbol(),MODE_MINLOT),2); maxlot=NormalizeDouble(MarketInfo(Symbol(),MODE_MAXLOT),2); if (LotsDigit == 2) MinLots = 0.01; if (LotsDigit == 1) MinLots = 0.1; if (LotsDigit == 0) MinLots = 1; if (lots < MinLots) lots = MinLots; if (maxlot > MaxLots) maximlot = MaxLots; else maximlot=maxlot; if (lots > maximlot) lots = maximlot; return (lots); } //====================================================================================================================================================== double TickValue() { double tv; tv = NormalizeDouble(MarketInfo(Symbol(), MODE_TICKVALUE), Digits); return(tv); } //====================================================================================================================================================== int SecurProfit() { int sp=0; if (OrderProfit()>(TickValue()*GetLots()*TP)) sp=1; return(sp); } //====================================================================================================================================================== double SetPoint() { double mSetPoint; if (Digits==5 || Digits==3) mSetPoint = 0.00001; else mSetPoint = 0.0001; return(mSetPoint); } //======================================================================================================================================================
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Indicators Used:
Fractals
Indicator of the average true range
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Checks for the total of open orders
It Closes Orders by itself
It automatically opens orders when conditions are reached
Other Features: