/*[[ Name := TSD Author := Copyright © 2005 Bob O'Brien / Barcode Link := Notes := Based on Alexander Elder's Triple Screen system. To be run only on a daily chart. Lots := 1.00 Stop Loss := 0 Take Profit := 0 Trailing Stop := 0 ]]*/ ///////////////////////////////////////////////////// // Defines ///////////////////////////////////////////////////// Defines: Slippage(3), atrfactor(1.25),pt(4); // Slippage ///////////////////////////////////////////////////// // Variables ///////////////////////////////////////////////////// var: I(0),MAsell(0),MAbuy(0),istop(0),sellstop(0),buystop(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); ///////////////////////////////////////////////// // New Orders Management ///////////////////////////////////////////////// MASell = ima(12,mode_sma,1)>ima(6,MODE_EMA,1); MABuy = ima(12,mode_sma,1)=buystop then{ SetOrder(OP_SELL,lots,bid,Slippage,bid+istop,sellstop,Green); 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; }; }; };};