[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [EquisMetaStock Group] Re: To create ATR*1.5 for short



PureBytes Links

Trading Reference Links

HI Jose
  Thanks for coding the formula for Long/Short ATR. 
  Could you break it up the formula one for Long and the another for short? 
  Thanks
  Alwin Chuah 
  

Jose Silva <josesilva22@xxxxxxxxx> wrote:
          Alwun, your original formula plots a 3 ATR semi-trailing stop.
I would code your trailing stop this way:

================================
Alwun Long & Short trailing stop
================================
---8<----------------------------------

{ Custom ATR Long/Short "trailing stop".
http://www.metastocktools.com }

{ User inputs }
StDay:=Input("start Day",1,31,1);
StMnth:=Input("start Month",1,12,1);
StYear:=Input("start Year",1800,2200,2006);
multi:=Input("ATR multiplier",0,10,1.5);
pds:=Input("ATR periods",1,252,14);
plot:=Input("Trail stop: [1]Long, [2]Short, [3]Both",1,3,3);

{ Date signal }
start:=Year()>StYear
OR (Year()=StYear AND (Month()>StMnth
OR Month()=StMnth AND DayOfMonth()>=StDay));
date:=start AND Alert(start=0,2);

{ Restrict out-of-range date signal to chart }
date:=If(LastValue(Cum(date))>0,date,Cum(1)=1);

{ Long trailing stop }
TSP1:=HighestSince(1,date,H);
TSP2:=TSP1-ATR(pds)*multi;
long:=HighestSince(1,Ref(date,-1),TSP2);

{ Short trailing stop }
TSP1:=LowestSince(1,date,L);
TSP2:=TSP1+ATR(pds)*multi;
short:=LowestSince(1,Ref(date,-1),TSP2);

{ Plot on price chart }
If(plot=1,long,short);
If(plot=2,short,long)

---8<----------------------------------

Note how the date signal will now accept non-trading days.

jose '-)
http://www.metastocktools.com

--- In equismetastock@xxxxxxxxxxxxxxx, Alwin Chuah <ctk188@xxx> wrote:
>
> Hi
> I have a formula for ATR *1.5 for long. 
> Below is the formula
> 
> Pday:=Input("Day of Month",1,31,3);
> Pmonth:=Input("Month of Year",1,12,1);
> PYear:=Input("Year",2000,2010,2006);
> Ppercent:=Input("ATR",1.5,5,3);
> TSP1:=BarsSince(DayOfMonth()=Pday AND Month()=Pmonth AND 
Year()=PYear);
> TSP2:=HighestSince(1,TSP1=0,H);
> TSP3:= TSP2-ATR(14)*Ppercent;
> HighestSince(1,TSP1=1,TSP3)
>
> Can you help me in editing it to create ATR *1.5 for short.
> Thanks
> Alwun Chuah ( KL,Malaysia)



         

 		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

[Non-text portions of this message have been removed]





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/