/*[[ Name := Up&Down Author := Dominic. Link := http://www.metaquotes.net/ Separate Window := No First Color := Blue First Draw Type := Symbol First Symbol := 225 Use Second Data := Yes Second Color := Red Second Draw Type := Symbol Second Symbol := 226 ]]*/ Variable : shift(0); Define: nPips(0.004); var: cnt(0),TrStopLevel(0),PREV(0), pass(0),TrStopLevel2(0); SetLoopCount(0); // loop from first bar to current bar (with shift=0) For shift=Bars-2 Downto 0 Begin If(close[shift]==PREV) then { TrStopLevel=PREV; } else { If (Close[shift+1])PREV) AND (close[shift]>PREV) then { TrStopLevel=Max(PREV,close[shift]*(1-nPips)); } else { If(close[shift]>PREV) then { TrStopLevel=close[shift]*(1-nPips); } else TrStopLevel=close[shift]*(1+nPips); }; }; }; if close[shift] > TrStopLevel and close[shift+1]0 then { //SetOrder(OP_BUY,1,ask,2,0,ask+TakeProfit*Point,blue); //Alert("buy"); SetIndexValue(shift, TrStopLevel); }; if close[shift] < TrStopLevel and close[shift+1]>PREV and PREV<>0 then { //SetOrder(OP_SELL,1,bid,2,0,bid-TakeProfit*Point,Red); SetIndexValue2(shift, TrStopLevel); //Alert("Sell"); }; PREV=TrStopLevel; // Alert(TrStopLevel); End;