/*[[ Name := 6 bar HI_LO v2 Author := JDG , geddiej@bellsouth.net Link := www.metatrader.org / http://finance.groups.yahoo.com/group/MetaTrader_Experts_and_Indicators/ Notes := 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 ++; }; }; }; 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; Comment("Buystop=",buystop, "\n","Sellstop=",sellstop, "\n","ATR Offset=",istop, "\n","openperiod = ",openperiod, "\n","T[0] = ",T[0]," , MASell = ",MASell," , MABuy = ",MABuy); ///////////////////////////////////////////////// // New Orders Management ///////////////////////////////////////////////// // If No MA Cross then MASell and MABuy = 0 If ((ima(12,mode_sma,1)>=ima(6,MODE_EMA,1)) and (ima(12,mode_sma,2)>=ima(6,MODE_EMA,2))) then { MASell = 0; MABuy = 0; openperiod = 0; }; // If No MA Cross then MASell and MABuy = 0 If ((ima(12,mode_sma,1)<=ima(6,MODE_EMA,1)) and (ima(12,mode_sma,2)<=ima(6,MODE_EMA,2))) then { MASell = 0; MABuy = 0; openperiod = 0; }; // If MA Cross Up 6 over 12 then MASell = -10 and MABuy = 10 If ((ima(12,mode_sma,1)>ima(6,MODE_EMA,1)) and (ima(12,mode_sma,2)<=ima(6,MODE_EMA,2))) then { MASell = 10; MABuy = -10; }; // If MA Cross Down 6 under 12 then MASell = 10 and MABuy = -10 If ((ima(12,mode_sma,1)=ima(6,MODE_EMA,2))) then { MASell = -10; MABuy = 10; }; If tradesthissymbol<1 then{ if ((MABuy>0) and (ask<=sellstop) and (openperiod!=T[0])) then{ SetOrder(OP_BUY,lots,ask,Slippage,ask-istop,buystop,green); openperiod=T[0]; exit;}; if ((MASell>0) and (bid>=buystop) and (openperiod!=T[0])) then{ SetOrder(OP_SELL,lots,bid,Slippage,bid+istop,sellstop,Green); openperiod=T[0]; 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; }; }; };};