//+------------------------------------------------------------------+ //| AmazingEA.mq4 Version 1.0.5 | //| FiFtHeLeMeNt | //| http://www.irxfx.com | //| fifthelement80@gmail.com | //+------------------------------------------------------------------+ #property copyright "FiFtHeLeMeNt" #property link "http://www.irxfx.com" extern int TP=25; extern int NHour=0; extern int NMin=0; extern int BEPips=11; extern int TrailingStop=0; extern double Lots=0.2; extern string TradeLog = " MI_Log"; double h,l,ho,lo,hso,lso,htp,ltp,sp; int Magic=2210; string filename; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } int CheckOrdersCondition() { int result=0; for (int i=0;i byPips * Point) if (OrderStopLoss() < OrderOpenPrice()) { Write("Movine StopLoss of Buy Order to BE+1"); OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + Point, OrderTakeProfit(), Red); } if (OrderType() == OP_SELL) if (OrderOpenPrice() - Ask > byPips * Point) if (OrderStopLoss() > OrderOpenPrice()) { Write("Movine StopLoss of Buy Order to BE+1"); OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - Point, OrderTakeProfit(), Red); } } } } void DoTrail() { for (int i = 0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if ( OrderSymbol()==Symbol() && (OrderMagicNumber() == Magic)) // only look if mygrid and symbol... { if (OrderType() == OP_BUY) { if(Bid-OrderOpenPrice()>Point*TrailingStop) { if(OrderStopLoss()(Point*TrailingStop)) { if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } void DeleteBuyStop() { for (int i = 0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol()==Symbol() && (OrderMagicNumber() == Magic) && (OrderType()==OP_BUYSTOP)) { OrderDelete(OrderTicket()); Write("in function DeleteBuyStopOrderDelete Executed"); } } } void DeleteSellStop() { for (int i = 0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol()==Symbol() && (OrderMagicNumber() == Magic) && (OrderType()==OP_SELLSTOP)) { OrderDelete(OrderTicket()); Write("in function DeleteSellStopOrderDelete Executed"); } } } int Write(string str) { int handle; handle = FileOpen(filename,FILE_READ|FILE_WRITE|FILE_CSV,"/t"); FileSeek(handle, 0, SEEK_END); FileWrite(handle,str + " Time " + TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS)); FileClose(handle); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { Comment("Amazing EA Version 1.0.5 By FiFtHeLeMeNt"); int i; int OrdersCondition,minofday,minofnews; filename=Symbol() + TradeLog + "-" + Month() + "-" + Day() + ".txt"; if (BEPips>0) DoBE(BEPips); if (TrailingStop>0) DoTrail(); OrdersCondition=CheckOrdersCondition(); minofday=Hour()*60+Minute(); minofnews=NHour*60+NMin; if ((minofday==minofnews-2) || (minofday==minofnews-1)) { h=iHigh(NULL,PERIOD_M1,0); l=iLow(NULL,PERIOD_M1,0); for (i=1;i<=3;i++) if (iHigh(NULL,PERIOD_M1,i)>h) h=iHigh(NULL,PERIOD_M1,i); for (i=1;i<=3;i++) if (iLow(NULL,PERIOD_M1,i)