/*[[ Name := 6 bar HI_LO v3a Author := JDG Link := geddiej@bellsouth.net Notes := www.metatrader.org / http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/ Lots := 1.00 Stop Loss := 0 Take Profit := 0 Trailing Stop := 0 ]]*/ If TimeYear(T) < 2006 then exit; ///////////////////////////////////////////////////// // Defines ///////////////////////////////////////////////////// Defines: Slippage(3), atrfactor(1.25),pt(4); // Slippage ///////////////////////////////////////////////////// // Variables ///////////////////////////////////////////////////// var: I(0),MAsell(0),MAbuy(0),istop(0),sellstop(0),buystop(0),openperiod(0); var: high1(0),high2(0),high3(0),high4(0),low1(0),low2(0),low3(0),low4(0); Var: TradesThisSymbol(0); ///////////////////////////////////////////////// // Initialisation ///////////////////////////////////////////////// TradesThisSymbol = 0; For I = 1 to TotalTrades { If ord(I, VAL_SYMBOL) == Symbol then { If OrderValue(I,VAL_TYPE)==OP_SELL OR OrderValue(I,VAL_TYPE)==OP_BUY then { TradesThisSymbol ++; }; }; }; If IsIndirect(Symbol) then exit; high1=max(h[1],h[2]); high2=max(h[3],h[4]); high3=max(h[5],h[6]); high4=max(high1,high2); buystop=max(high4,high3)-pt*Point; low1=min(l[1],l[2]); low2=min(l[3],l[4]); low3=min(l[5],l[6]); low4=min(low1,low2); sellstop=min(low4,low3)+pt*Point; istop=iatr(14,1)*atrfactor; If MASell > 0 then {Comment("Trend = Down", "\n","Sell Trigger Price = ",buystop, "\n","ATR Offset = ",istop); }; If MASell < 0 then {Comment("Trend = Up", "\n","Buy Trigger Price = ",sellstop, "\n","ATR Offset = ",istop); }; ///////////////////////////////////////////////// // New Orders Management ///////////////////////////////////////////////// If (ima(12,mode_sma,1)>ima(6,MODE_EMA,1)) then { MASell = 10; MABuy = -10; }; If (ima(12,mode_sma,1)0) and (ask<=sellstop) and (openperiod!=T[0])) then{ SetOrder(OP_BUY,lots,ask,Slippage,ask-istop,buystop,green); openperiod=10; exit;}; if ((MASell>0) and (bid>=buystop) and (openperiod!=T[0])) then{ SetOrder(OP_SELL,lots,bid,Slippage,bid+istop,sellstop,Green); openperiod=10; exit;};}; ///////////////////////////////////////////////// // Stop Loss Management ///////////////////////////////////////////////// If TradesThisSymbol > 0 Then { For i=1 to TotalTrades { If Ord(i,VAL_SYMBOL) = Symbol and Ord(i,VAL_TYPE) = OP_BUY Then { if ord(i,VAL_TAKEPROFIT) <> buystop Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), Ord(i,VAL_STOPLOSS), buystop, White); Exit; }; if ord(i,VAL_STOPLOSS) sellstop Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), ord(i,VAL_STOPLOSS), sellstop, White); Exit; }; if ord(i,VAL_STOPLOSS)>bid+istop Then { ModifyOrder(Ord(i,VAL_TICKET), Ord(i,VAL_OPENPRICE), Bid+istop, ord(i,VAL_TAKEPROFIT), White); Exit; }; }; If Ord(i,VAL_SYMBOL) = Symbol and Ord(i,VAL_TYPE) = OP_BUY Then { if (ord(i,VAL_TAKEPROFIT)-Ord(i,VAL_OPENPRICE)<=5*Point) OR (bid>=buystop) Then { CloseOrder(OrderValue(i,VAL_TICKET),OrderValue(i,VAL_LOTS),Bid,Slippage,RED);Exit; }; }; If Ord(i,VAL_SYMBOL) = Symbol and Ord(i,VAL_TYPE) = OP_SELL Then { if (Ord(i,VAL_OPENPRICE)-ord(i,VAL_TAKEPROFIT)<=5*Point) OR (ask<=sellstop) Then { CloseOrder(OrderValue(i,VAL_TICKET),OrderValue(i,VAL_LOTS),ask,Slippage,RED);Exit; }; }; };};