//+-------------------------------------------------------------------+ //| Made/Modified by Alejandro Galindo | //| | //| If this work/modification is helpful to you | //| send me a PayPal donation to ag@elcactus.com | //| any help is apreciated :) | //| Thanks. | //+-------------------------------------------------------------------+ /*[[ Name := NRTR ATR STOP 1.0 Author := Copyright © 2005, Alejandro Galindo. Link := Lots := 1.00 Stop Loss := 999 Take Profit := 999 Trailing Stop := 999 ]]*/ Define: mm(0); Define: risk(12); Define: ATR(50); Define: Coeficient(3); var: cnt(0),tmp(0); var: lotsi(0); var: NRTRBUYb4(0), NRTRSELLb4(0); var: NRTRBUY(0), NRTRSELL(0); var: NRTRBUYnow(0), NRTRSELLnow(0); var: OpenTrades(0); var: Slippage(5); Var: BuyPrice(0), SellPrice(0); var: OpenBuy(false), OpenSell(false), CloseBuy(false), CloseSell(false); //var: SuperSignalF(0), SuperSignalS(0); //If TimeYear(time)<2005 then Exit; if Curtime - LastTradeTime < 15 then exit; if mm<>0 then lotsi=Ceil(Balance*risk/10000)/10 else lotsi=Lots; OpenBuy=False; OpenSell=False; CloseBuy=False; CloseSell=False; BuyPrice = Ask; SellPrice = Bid; NRTRBUYb4= iCustom("NRTR_ATR_STOP",ATR,Coeficient,MODE_FIRST,2); NRTRSELLb4= iCustom("NRTR_ATR_STOP",ATR,Coeficient,MODE_SECOND,2); NRTRBUY= iCustom("NRTR_ATR_STOP",ATR,Coeficient,MODE_FIRST,1); NRTRSELL= iCustom("NRTR_ATR_STOP",ATR,Coeficient,MODE_SECOND,1); NRTRBUYnow= iCustom("NRTR_ATR_STOP",ATR,Coeficient,MODE_FIRST,0); NRTRSELLnow= iCustom("NRTR_ATR_STOP",ATR,Coeficient,MODE_SECOND,0); OpenTrades=0; For cnt=1 to TotalTrades { If (OrderValue(cnt,VAL_SYMBOL) == symbol) then OpenTrades++; }; //print("Period=",Period,"NRTRBUY=",NRTRBUY," NRTRSELL=",NRTRSELL); If NRTRSELLb4>0 and NRTRSELL<=0 and NRTRBUYb4<=0 and NRTRBUY >0 then { CloseSell=True; OpenBuy=True; }; If NRTRBUYb4>0 and NRTRBUY<=0 and NRTRSELLb4<=0 and NRTRSELL>0 then { CloseBuy=True; OpenSell=True; }; // if we have opened positions we take care of them for cnt=1 to TotalTrades { if OrderValue(cnt,VAL_SYMBOL) == Symbol then { if OrderValue(cnt,VAL_TYPE) == OP_BUY then { if CloseBuy then { CloseOrder(OrderValue(cnt,VAL_TICKET),Lotsi,Bid,Slippage,green); Exit; }; }; if OrderValue(cnt,VAL_TYPE) == OP_SELL then { if CloseSell then { CloseOrder(OrderValue(cnt,VAL_TICKET),Lotsi,Ask,Slippage,green); Exit; }; }; if OrderValue(cnt,VAL_TYPE) == OP_BUYSTOP then { if CloseBuy then { DeleteOrder(OrderValue(cnt,VAL_TICKET),Brown); Exit; }; }; if OrderValue(cnt,VAL_TYPE) == OP_SELLSTOP then { if CloseSell then { DeleteOrder(OrderValue(cnt,VAL_TICKET),Brown); Exit; }; }; }; }; If OpenTrades<1 and OpenBuy then { SetOrder(OP_BUY,Lotsi,BuyPrice,Slippage,NRTRBUY,0,Blue); SetArrow(CurTime, Low - 15 * Point, 233, BLUE); Exit; }; If OpenTrades<1 and OpenSell then { SetOrder(OP_SELL,Lotsi,SellPrice,Slippage,NRTRSELL,0,Red); SetArrow(CurTime, High + 15 * Point, 234, RED); Exit; };