/*[[ Name := Author := Jesse Breaker Link := http://www.metaquotes.net/ Lots := 0 Stop Loss := 35 Take Profit := 0 Trailing Stop := 25 ]]*/ Var: SL(0),vSL(0),cnt(0),cnt2(0),slippage(5),first(0),AvoidSell(0),AvoidBuy(0),b(0),KillHour(3),KillMinute(30),StartHour(0),StartMinute(0); var: yesterday_high(0),Global_high(0),yesterday_low(0),Global_low(0),yesterday_close(0),Global_close(0),KillFlag(0); var: BuyStop(0),SellStop(0),CK_PL_2ND_B(0),CK_PL_INIT_B(0),CK_PL_2ND_S(0),CK_PL_INIT_S(0),DEL_S(0),DEL_B(0),PL_2ND_B(0),PL_INIT_B(0),PL_2ND_S(0),PL_INIT_S(0),CK_DEL_B(0),CK_DEL_S(0),CL_B(0),CL_S(0),CK_CL_B(0),CK_CL_S(0); If CK_DEL_B == 1 then { DEL_B = 0; CK_DEL_B = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_BUYSTOP then { CK_DEL_B = 0; DEL_B = 1; }; }; }; EXIT; }; If CK_DEL_S == 1 then { DEL_S = 0; CK_DEL_S = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_SELLSTOP then { CK_DEL_S = 0; DEL_S = 1; }; }; }; EXIT; }; If CK_PL_INIT_B == 1 then { PL_INIT_B = 1; CK_PL_INIT_B = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) = OP_BUYSTOP then { CK_PL_INIT_B = 0; PL_INIT_B = 999; }; }; }; EXIT; }; If CK_PL_INIT_S == 1 then { PL_INIT_S = 1; CK_PL_INIT_S = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_SELLSTOP then { CK_PL_INIT_S = 0; PL_INIT_S = 999; }; }; }; EXIT; }; If CK_CL_B == 1 then { CL_B = 0; CK_CL_B = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_BUY then { CK_CL_B = 0; CL_B = 1; }; }; }; EXIT; }; If CK_CL_S == 1 then { CL_S = 0; CK_CL_S = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_SELL then { CK_CL_S = 0; CL_S = 1; }; }; }; EXIT; }; If DEL_B == 1 then { DEL_B = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_BUYSTOP then { DEL_B = 0; CK_DEL_B = 1; DeleteOrder(OrderValue(cnt,VAL_TICKET),Red); }; }; }; EXIT; }; If DEL_S == 1 then { DEL_S = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_SELLSTOP then { DEL_S = 0; CK_DEL_S = 1; DeleteOrder(OrderValue(cnt,VAL_TICKET),Red); }; }; }; EXIT; }; If CL_B == 1 then { CL_B = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_BUY then { CL_B = 0; CK_CL_B = 1; CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Bid,5,Violet); }; }; }; EXIT; }; If CL_S == 1 then { CL_S = 0; For cnt = 1 to TotalTrades { If OrderValue(cnt,VAL_SYMBOL)=Symbol then { If OrderValue(cnt,VAL_TYPE) == OP_SELL then { CL_S = 0; CK_CL_S = 1; CloseOrder(OrderValue(cnt,VAL_TICKET),OrderValue(cnt,VAL_LOTS),Ask,5,Violet); }; }; }; EXIT; }; If PL_INIT_B == 1 then { CK_PL_INIT_B = 1; PL_INIT_B = 999; SetOrder(OP_BUYSTOP,Lots,Ask,Slippage,Ask - (StopLoss * Point),TakeProfit * Point,BLUE); EXIT; }; If PL_INIT_S == 1 then { CK_PL_INIT_S = 1; PL_INIT_S = 999; SetOrder(OP_SELLSTOP,Lots,Bid,Slippage,Bid + (StopLoss * Point),TakeProfit * Point,BLUE); EXIT; }; if TimeHour(CurTime) == KillHour and TimeMinute(CurTime)>=KillMinute and KillFlag == 1 then { Comment(Symbol+" Killing any open positions..."); DEL_B=1; DEL_S=1; CL_B=1; CL_S=1; PL_INIT_B=0; PL_INIT_S=0; PL_2ND_B=0; PL_2ND_S=0; AvoidBuy=0; AvoidSell=0; KillFlag = 0; exit; }; if TimeHour(CurTime) == StartHour and TimeMinute(CurTime)>=0 then { KillFlag = 1; If PL_INIT_B !=999 then { PL_INIT_B=1; exit; }; If PL_INIT_S!=999 then { PL_INIT_S=1; exit; }; };