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

[EquisMetaStock Group] Re: Caculating the actual number of degrees of the slope of the 34 EMA



PureBytes Links

Trading Reference Links

The way I got around this problem is to use a simpler approach. 
Instead of computing the ArcTan I use the % change per day.

In my application, I compute a Regression fit to a Quadratic equation
y = a + bx + cx^2, then take the first derivative of the equation
which of course is the slope d/dx = b + 2cx.  With this equation, I
can compute the instaneous slope at any bar (x) of interest.  

We're not quite there yet, however.  Another way of looking at %
change per day, is that you are normalizing the stock price to
$100/share.  This enables you to compare the Canadian dollar futures
price around 0.8000 to the dow mini futures price around 10,000.

I use a simple EMA of the close over the same number of bars that is
used for the quadratic fit like %/day =  (100 * (d/dx)) / (EMA(close ).

This has produced a reliable, quiet rate of change indicator, that is
independent of price.


Reef-Break





--- In equismetastock@xxxxxxxxxxxxxxx, "Jose Silva" <josesilva22@xxxx>
wrote:
> CNxxx, this is the same problem that plagues Elliot Wave & Fib
followers.
> 
> When you really think about it, it is not possible to derive an
absolute 
> value for the slope of any indicator or price on a chart.  Any pseudo 
> slope, such as the AmiBroker & MetaStock code sample plots, cannot 
> provide absolute slope values.
> 
> An absolute slope requires two absolute values: x (horizontal, time)
and 
> y (vertical, price) axis.  The vertical component of a plot can be
absolute 
> (price, indicator/oscillator values), but the horizontal axis is not
- it shifts 
> from chart to chart, from user to user.
> 
> Since the reference x-axis (date bar) is not constant or absolute, the 
> slope of an indicator being relative to the x-axis, slope values will 
> depend on how far one stretches the total number of bars viewed on a 
> chart.
> 
> In other words, an EMA will look much steeper on a compressed chart 
> (say, 260 bars from left to right edges), than it would on a more
diluted 
> chart (say, a 60 bar chart).
> 
> In any case, the MetaStock sample code below provides a constant 
> pseudo-slope in degrees.  Perhaps this can be of use.
> 
> ==================
> EMA - slope degrees
> ==================
> ---8<---------------------------
> 
> { EMA slope % v2.1, +/- 0~90deg }
> { ©Copyright 2005 Jose Silva }
> { For personal use only }
> { http://www.metastocktools.com }
> 
> pds:=Input("EMA periods",2,2600,34);
> x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5",1,5,4);
> 
> x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,C))));
> EMA:=Mov(x,pds,E);
> EMAprev:=Ref(EMA,-1);
> 
> y:=Min(EMA,EMAprev)/Max(EMA,EMAprev);
> EMAratio:=(If(EMA>EMAprev,2-y,y)-1)*100;
> EMAdeg:=If(EMAratio<0,Atan(EMAratio,1)-360,
>  Atan(EMAratio,1)){*10/9};
> signal:=Mov(EMAdeg,pds,E);
> 
> 0;signal;EMAdeg
> 
> ---8<---------------------------
> 
> 
> jose '-)
> http://www.metastocktools.com
> 
> 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, "cn001532" 
> <cn001532@xxxx> wrote:
> > If been having a devil of a time trying to calculate the actual 
> > number of degrees of the slope of the 34 EMA and 25 LSMA. I've got 
> > some opensource AMIbroker code and was able to get some
> > information from www.metastocktools.com which get me close but
> > not quite there. 
> > 
> > I have no trouble creating an exploration using the slope, to produce 
> > an equivalent results that I require, however I really would like to 
> > be able to calculate the actual number of degrees of both slopes for 
> > other purposes. 
> > 
> > A simple atan function of the slope does not do the trick. 
> > 
> > Posted below is the relavent open source amibroker code that 
> > caclulates the actual number of degrees of the angle of the 34 ema 
> > and 25 LSMA. 
> > 
> > Any help would be most appreciated. 
> > 
> > 
> > 
> > I would like to replicate these in Metastock: 
> > 
> > EMA34 = EMA(C,34); 
> > PI = 3.141593; 
> > periods = 30; 
> > HighHigh = HHV(H, periods); 
> > LowLow = LLV(L, periods); 
> > range = 25 / (HighHigh - LowLow) * LowLow; 
> > 
> > x1_EMA34 = 0; 
> > x2_EMA34 = 2; 
> > y1_EMA34 = 0; 
> > y2_EMA34 = (Ref(EMA34, -2) - EMA34) / Avg * range; 
> > 
> > c_EMA34 = sqrt((x2_EMA34 - x1_EMA34)*(x2_EMA34 - x1_EMA34) + 
> > (y2_EMA34 - y1_EMA34)*(y2_EMA34 - y1_EMA34)); 
> > angle_EMA34 = round(180 * acos((x2_EMA34 - 
> x1_EMA34)/c_EMA34) / PI); 
> > 
> > 
> > x1_LSMA25 = 0; 
> > x2_LSMA25 = 2; 
> > y1_LSMA25 = 0; 
> > y2_LSMA25 = (Ref(LSMA25, -2) - LSMA25) / Avg * range; 
> > 
> > c_LSMA25 = sqrt((x2_LSMA25 - x1_LSMA25)*(x2_LSMA25 - 
> x1_LSMA25) + 
> > (y2_LSMA25 - y1_LSMA25)*(y2_LSMA25 - y1_LSMA25)); 
> > angle_LSMA25 = round(180 * acos((x2_LSMA25 - 
> x1_LSMA25)/c_LSMA25) / 
> > PI); 
> > 
> > 
> > I tried using/modifying the following code from metastocktools.com 
> > with no luck: 
> > MetaStock -> Tools -> Indicator Builder -> New 
> > Copy and paste formula below. 
> > 
> > 
> > ============================ 
> > Linear Regression true slope 
> > ============================ 
> > ---8<--------------------------- 
> > 
> > { Linear Regression true Slope v3.5 } 
> > { -100~+100% / -90~+90 degrees } 
> > { ©Copyright 2003-2004 Jose Silva } 
> > { http://www.metastocktools.com } 
> > 
> > pds:=Input("Linear Regression periods",2,2520,21); 
> > pds1:=Input("Lin Reg Signal periods",1,252,5); 
> > x:=Input("Open=1, High=2, Low=3, Close=4, Volume=5, 
> P=6",1,6,4); 
> > display:=Input("display -100~100%=1, -90~90 degrees=2",1,2,1); 
> > hist:=Input("display positive histogram fill (on=1, off=0)",0,1,1); 
> > plot:=Input("[1] LinReg Slope, [2] signals",1,2,1); 
> > 
> > x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C))))); 
> > LRlast:=LinearReg(x,pds); 
> > LRS:=LinRegSlope(x,pds); 
> > LRprev:=LRlast-LRS; 
> > {LRstart:=Ref(LRlast-LRS*(pds-1),pds-1);} 
> > 
> > a:=Min(LRlast,LRprev)/Max(LRlast,LRprev); 
> > LRratio:=(If(LRlast>LRprev,2-a,a)-1)*80; 
> > LRSdeg:=If(LRratio<0,Atan(LRratio,1)-360, 
> > Atan(LRratio,1)); 
> > LRSper:=LRSdeg*10/9; 
> > LRStrue:=If(display=2,LRSdeg,LRSper); 
> > signal:=Mov(LRStrue,pds1,E); 
> > BuySell:=Cross(LRStrue,signal)-Cross(signal,LRStrue); 
> > odd:=Cum(1)/2=Int(Cum(1)/2); 
> > odd:=If(hist=1 AND LRStrue>signal,If(odd,signal,LRStrue),LRStrue); 
> > 
> > If(plot=1,odd,0); 
> > If(plot=1,signal,0); 
> > If(plot=1,LRStrue,BuySell) 
> > 
> > ---8<--------------------------- 
> > 
> > 
> > http://www.metastocktools.com 
> > 
> > 
> > and 
> > 
> > MetaStock -> Tools -> Indicator Builder -> New 
> > Copy and paste formula below. 
> > 
> > 
> > ============= 
> > EMA - slope % 
> > ============= 
> > ---8<--------------------------- 
> > 
> > { EMA slope % v2.0, +/- 0~100% } 
> > { ©Copyright 2003 Jose Silva } 
> > { http://www.metastocktools.com } 
> > 
> > pds:=Input("EMA periods",2,2520,21); 
> > x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5
> P=6",1,6,4); 
> > 
> > x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C))))); 
> > EMA:=Mov(x,pds,E); 
> > EMAprev:=Ref(EMA,-1); 
> > 
> > y:=Min(EMA,EMAprev)/Max(EMA,EMAprev); 
> > EMAratio:=(If(EMA>EMAprev,2-y,y)-1)*100; 
> > EMAper:=If(EMAratio<0,Atan(EMAratio,1)-360, 
> > Atan(EMAratio,1))*10/9; 
> > signal:=Mov(EMAper,pds,E); 
> > 
> > 0;signal;EMAper 
> > 
> > ---8<--------------------------- 
> > 
> > 
> > http://www.metastocktools.com





------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12htl1dc3/M=362131.6882500.7825259.1493532/D=groups/S=1705375617:TM/Y=YAHOO/EXP=1124997355/A=2889190/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Put more honey in your pocket. (money matters made easy) Welcome to the Sweet Life - brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

 
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/