Time: 2014-11-20 | Download file:EA-Breakermind.mq4
//+------------------------------------------------------------------+ //| eurjpy.mq4 | //| Copyright 2013 Breakermind | //| http://breakermind.com | //+------------------------------------------------------------------+ // Not tested use only for training #property link "http://breakermind.com" #property copyright "Copyright 2013 Breakermind.com" //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ extern bool ShowStat = true; extern double Lots = 0.01; extern double StartBalance = 1000; extern bool MultipleLots = true; extern double StopProfit = 10000; extern double MaxPositionsLong = 100; extern double MaxPositionsShort = 100; extern bool StopWeekend = false; extern bool CrossWeekend = true; extern double MaxEquity = 0.5; extern bool TradeAfterCloseAll = true; extern double StopLossBack = 60; extern double PipsBack = 50; extern double StopLossTrailing = 400; extern int SL = 0; // lepiej nie używać nie opłaca się int Ban = 0; //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ int total, total1, MagicNumber, AccountNr, IntBid,cnt1, tmp; double MarginFree, Balance, Equity, Margin, Lots1, PosUpDouble, PosDnDouble; int BanUp = 1; int BanDown = 1; int PosUp = 0; int PosDn = 0; int LevelUp[2000]; int LevelDn[2000]; //+------------------------------------------------------------------+ //|Functions //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //|Start //+------------------------------------------------------------------+ int start(){ double Ma5=iMA(NULL,0,200,0,MODE_EMA,PRICE_CLOSE,0); double Ma5p=iMA(NULL,0,200,0,MODE_EMA,PRICE_CLOSE,3); double Ma200=iMA(NULL,0,200,0,MODE_LWMA,PRICE_MEDIAN,0); if(MultipleLots == true){ Lots1 = Lots; int ilerazy = Balance/StartBalance; if(ilerazy <= 0){ilerazy = 1;} Lots1 = ilerazy*Lots; }else{Lots1 = Lots;} //=== Stop ea on weekends if(StopWeekend == true){ if(DayOfWeek() > 4 && Hour() == 21 && Minute() > 30){ CloseAll(); return; } } // === if(CrossWeekend == true){ if(DayOfWeek() > 4 && Hour() == 21 && Minute() > 30){ ClosePending(); total1 = OrdersTotal(); double OpenLongLot = 0, OpenShortLot = 0; for(int q=0;qOpenShortLot){ OrderSend(Symbol(),OP_SELL,OpenLongLot-OpenShortLot,Bid,3,0,0,"breakermind",0,0,Red); } //=== if(OpenShortLot > OpenLongLot){ OrderSend(Symbol(),OP_BUY,OpenShortLot-OpenLongLot,Ask,3,0,0,"breakermind",0,0,Green); } // === } } //=== if(StopLossTrailing <= 0){ StopLossTrailing = 400; } for(int z = 0; z < 2001;z++){ LevelUp[z] = 0; LevelDn[z] = 0; } double Dayline = iOpen(NULL, PERIOD_D1, 0); ObjectsDeleteAll(0); ObjectCreate("Dayline", OBJ_HLINE, 0, Time[0], Dayline); IntBid = Bid*10000/10000; //+------------------------------------------------------------------+ //|Policz pozycje //+------------------------------------------------------------------+ total = OrdersTotal(); double OpenLongOrders = 0, OpenShortOrders = 0, PendLongs =0, PendShorts =0; for(int i=0;i StopProfit){ CloseAll(); Ban=1; TradeAfterCloseAll = false; return; } //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ if(Equity < MaxEq || Ban == 1){ CloseAll(); Alert("Close all positions Equity limit !!!"); // deselect if you want trade befor close all poss Ban = 1; if(TradeAfterCloseAll){Ban = 0;} return; } if(tmp != Time[0]){ tmp = Time[0]; int MBid = Bid*10000/10000; int MBid2 = MBid +1; if(AllLong < MaxPositionsLong){ for(int a = 1; a < 5; a++){ if(LevelUp[MBid+a] == 0 && AllLong < MaxPositionsLong ){ OrderSend(Symbol(),OP_BUYSTOP,Lots1+Lots1,MBid+a,3,0,0,"breakermind",MBid+a,0,Green); OrderSend(Symbol(),OP_BUYSTOP,Lots1,MBid+a+0.75,3,0,0,"breakermind",0,0,Green); OrderSend(Symbol(),OP_BUYSTOP,Lots1,MBid+a+0.55,3,0,0,"breakermind",0,0,Green); OrderSend(Symbol(),OP_BUYSTOP,Lots1+Lots1,MBid+a+0.25,3,0,0,"breakermind",0,0,Green); } } } // ==== if(AllLong < MaxPositionsLong){ for(int b = 1; b < 5; b++){ if(LevelDn[MBid2-b] == 0 && AllShort < MaxPositionsShort){ OrderSend(Symbol(),OP_SELLSTOP,Lots1,MBid2-b,3,0,0,"breakermind",MBid2-b,0,Red); OrderSend(Symbol(),OP_SELLSTOP,Lots1,MBid2-b-0.75,3,0,0,"breakermind",0,0,Red); OrderSend(Symbol(),OP_SELLSTOP,Lots1+Lots1,MBid2-b-0.55,3,0,0,"breakermind",0,0,Red); OrderSend(Symbol(),OP_SELLSTOP,Lots1,MBid2-b-0.25,3,0,0,"breakermind",0,0,Red); } } } } //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ for(int cnt=0;cnt 0) { if(Bid-OrderOpenPrice()>Point*StopLossBack) { if(OrderStopLoss() == 0 || OrderStopLoss() < OrderOpenPrice()) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point*PipsBack,OrderTakeProfit(),0,Green); return(0); } } } // check for stop loss if(StopLossTrailing>0) { if(OrderStopLoss()==0 && SL > 0) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-SL*Point,OrderTakeProfit(),0,Green); } if(Bid-OrderOpenPrice()>Point*StopLossTrailing) { if(OrderStopLoss() 0) { if((OrderOpenPrice()-Ask)>(Point*StopLossBack)) { if(OrderStopLoss()==0 || OrderStopLoss() > OrderOpenPrice()) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*PipsBack,OrderTakeProfit(),0,Red); //OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*PipsBack,OrderTakeProfit(),0,Red); return(0); } } } // check for stop loss if(StopLossTrailing>0) { if(OrderStopLoss()==0 && SL > 0) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-SL*Point,OrderTakeProfit(),0,Red); } if((OrderOpenPrice()-Ask)>(Point*StopLossTrailing)) { if((OrderStopLoss()>(Ask+Point*StopLossTrailing)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*StopLossTrailing,OrderTakeProfit(),0,Red); return(0); } } } } } } }//end void CloseAll() { for (int i=0; i