//+------------------------------------------------------------------+ //| Jump.mq4 | //| Copyright 2014, Maxim Bondarchuk | //| https://login.mql5.com/en/users/belkamax05 | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, Maxim Bondarchuk" #property link "https://login.mql5.com/en/users/belkamax05" #property version "1.00" #property strict enum TypeEnum { LimitOrders, StopOrders }; extern TypeEnum PendingType = LimitOrders;//Pending Type extern double Lots = 1; //Lots extern int Step = 100; //Step extern int StopLoss = 50; //Stop Loss extern int TakeProfit = 0; //Take Profit extern int Magic = 1353;//Magic Number extern int Period1 = 1; //Period (seconds) extern int BreakevenStart = 30; //Breakeven Start extern int BreakevenPips = 10;// Breakeven Pips extern int TrailingStart = 50; //Trailing Start extern int TrailingStop = 10; //Trailing Stop extern int TrailingStep = 1; //Trailing Step int NormKoef=2; double MinLot = 0.01; double StopLevel; int OnInit() { MinLot = MarketInfo(Symbol(),MODE_MINLOT); if(MinLot>=1)NormKoef=0; else if(MinLot>=0.1)NormKoef=1; else if(MinLot>=0.01)NormKoef=2; else if(MinLot>=0.001)NormKoef=3; else NormKoef=4; StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Point; EventSetTimer(1); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { EventKillTimer(); } void OnTick() { StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point+Point; if(IsTesting() && Volume[0]==1)Action(); BreakEvenCheck(); TrailingStopCheck(); } void OnTimer() { Action(); } void Action() { int ticket=0; bool res=false; double BSPrice = Ask+Step*Point; double BLPrice = Ask-Step*Point; double SSPrice = Bid-Step*Point; double SLPrice = Bid+Step*Point; double BSStop = BSPrice-StopLoss*Point; double BSTake = BSPrice+TakeProfit*Point; double SSStop = SSPrice+StopLoss*Point; double SSTake = SSPrice-TakeProfit*Point; double BLStop = BLPrice-StopLoss*Point; double BLTake = BLPrice+TakeProfit*Point; double SLStop = SLPrice+StopLoss*Point; double SLTake = SLPrice-TakeProfit*Point; if(StopLoss==0){BSStop = 0;SSStop = 0;BLStop = 0;SLStop = 0;} if(TakeProfit==0){BSTake = 0;SSTake = 0;BLTake = 0;SLTake = 0;} if (OrdersCount()<1) { if(PendingType==StopOrders) { ticket=OrderSend(Symbol(),OP_BUYSTOP,NormalizeDouble(Lots,NormKoef),BSPrice,3,BSStop,BSTake,"",Magic,0,clrBlue); ticket=OrderSend(Symbol(),OP_SELLSTOP,NormalizeDouble(Lots,NormKoef),SSPrice,3,SSStop,SSTake,"",Magic,0,clrRed); } if(PendingType==LimitOrders) { ticket=OrderSend(Symbol(),OP_BUYLIMIT,NormalizeDouble(Lots,NormKoef),BLPrice,3,BLStop,BLTake,"",Magic,0,clrBlue); ticket=OrderSend(Symbol(),OP_SELLLIMIT,NormalizeDouble(Lots,NormKoef),SLPrice,3,SLStop,SLTake,"",Magic,0,clrRed); } } if(OrdersCount(OP_SELL)>0) { if(IsDemo())PlaySound("alert2.wav"); DeletePendings(); } if(OrdersCount(OP_BUY)>0) { if(IsDemo())PlaySound("alert2.wav"); DeletePendings(); } ObjectsDeleteAll(); for(int i =0; i=0; i--) { if(OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && OrderType()>1) { res=OrderDelete(OrderTicket()); } } return(res); } int OrdersCount(int type=-1) { int count=0; for(int i=0; iOrderOpenPrice() && Bid-sl>=StopLevel && (OrderStopLoss()=StopLevel && (OrderStopLoss()>sl || OrderStopLoss()OrderOpenPrice() && Bid-buySL>=StopLevel && (buySL-OrderStopLoss()>TrailingStep*Point || OrderStopLoss()=StopLevel && (OrderStopLoss()-sellSL>TrailingStep*Point || OrderStopLoss()