#property copyright "Copyright 6 January 2019, Beerrun(R.M.)" #property link "https://www.mql5.com/en/users/beerrun" #property strict #property show_inputs enum scn {n,//0 Seconds s1,//1 Second s3=3,//3 Seconds s10=10,//10 Seconds s30=30,//30 Seconds m1=60,//1 Minute m5=300,//5 Minutes m15=900,//15 Minutes }; enum _type_ {Buy,Sell,None}; enum ny {No,Yes}; input ny symbol=0;//Restrict To Chart Symbol input int BE=8;//Points To BE input int bep=3;//BE+ In Points input int bStep=10;//Points To Begin Trail After BE input int Trail=7;//Points To Trail Price input scn Scan=1;//Time Between Stoploss Scans input ny sticky=1;//Script Remains On Chart input _type_ hiddentype=None;//Hidden Order Type input double hiddenprice;//Price input double hiddenlots=0.01;//Lots input int hiddenslip=2;//Slippage input double hiddensl;//StopLoss input double hiddentp;//TakeProfit input int hiddenmagic=99;//Magic Number string com="Scanning Orders"; int comcnt=0; int start(){ for(;;){ if(IsStopped()){Comment("");return 0;} int adjcnt=0; static bool hiddensw=1; if(hiddensw&&hiddentype!=None) if((hiddentype==Sell&&(Bid>=hiddenprice))||(hiddentype==Buy&&(Ask<=hiddenprice))) if(OrderSend(_Symbol,hiddentype,hiddenlots,hiddenprice,hiddenslip,hiddensl,hiddentp,MQLInfoString(MQL_PROGRAM_NAME),hiddenmagic))hiddensw=0; Comment(com); for(int i=OrdersTotal()-1;i>=0;i--){ com+="."; comcnt++; if(comcnt==4){com="Scanning Orders";comcnt=0;} Comment(com); if(IsStopped())return 0; if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){ string ordersymbol=OrderSymbol(); RefreshRates(); double point=_Point,ask=Ask,bid=Bid; if(ordersymbol!=_Symbol){ if(symbol)continue; else{point=SymbolInfoDouble(ordersymbol,SYMBOL_POINT);ask=SymbolInfoDouble(ordersymbol,SYMBOL_ASK);bid=SymbolInfoDouble(ordersymbol,SYMBOL_BID);}} double OOP=OrderOpenPrice(),SL=OrderStopLoss(); if(OrderType()==0) if(bid>=(OOP+(BE*point))){ if(SL=(OOP+((BE+bStep)*point))) if(Trail>0) if(SL=SL)continue;; if(OrderModify(OrderTicket(),OOP,SL,0,0)){adjcnt++;continue;}} if(OrderType()==1) if(ask<=(OOP-(BE*point))){ if(SL>OOP||SL==0)SL=OOP-(bep*point); if(ask<=(OOP-((BE+bStep)*point))) if(Trail>0) if(SL>=ask+(Trail*point))SL=ask+(Trail*point); SL=round(SL*point)/point; if(OrderStopLoss()<=SL)continue; if(OrderModify(OrderTicket(),OOP,SL,0,0)){adjcnt++;continue;}}}} Comment("Scan Finished\nStoplosses Adjusted: "+(string)adjcnt); Sleep(Scan); if(!sticky)break;} return 0;}