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

[amibroker] Re: Standard Deviation as an indicator



PureBytes Links

Trading Reference Links

I meant to say "you could have given us a better brief etc"

They have a left scale and also the StDev is in standard units.

You only see one line if you use montly charts (as they do).
If you change to daily charts you will see 3 lines.

Try this for leftscale:

//P_FixedStDev

Periods = 50;
difference = C - MA(C,Periods);
mean = MA(difference,Periods);
lvmean = LastValue(mean);
sdmean = StDev(mean, Periods);
top = LastValue(mean + sdmean);
bottom = LastValue(mean - sdmean);
 
Plot(lvmean, _DEFAULT_NAME(),colorGreen,styleLeftAxisScale);
Plot(top, _DEFAULT_NAME(),colorGreen,styleLeftAxisScale);
Plot(bottom, _DEFAULT_NAME(),colorGreen,styleLeftAxisScale); 
Plot(difference, _DEFAULT_NAME(),colorGreen,styleLeftAxisScale);


If you changeup the code to convert StDev to standard units you will 
be there.

brian_z 


--- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@xxx> wrote:
>
> It's plotting the grey SD +_ lines as per your example.
> 
> (You give us a better brief - just as well we are mind readers?)
> 
> It looks like you want to subtract close from MA(C,50) and then put 
> the SD over the top of that (substitute the difference for MA(C,50) 
> in Bills (adapted) code.
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "droskill" <droskill@> wrote:
> >
> > Hmmm...once again, I'm not getting anything from this code.  I 
just
> > get a straight line going across.
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@> 
wrote:
> > >
> > > //P_FixedStDev
> > > 
> > > mean = MA(C,50);
> > > lvmean = LastValue(mean);
> > > sdmean = StDev(mean, 50);
> > > top = LastValue(mean + sdmean);
> > > bottom = LastValue(mean - sdmean);
> > >  
> > > Plot(lvmean, _DEFAULT_NAME(),1,1);
> > > Plot(top, _DEFAULT_NAME(),1,1);
> > > Plot(bottom, _DEFAULT_NAME(),1,1);
> > > 
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "droskill" <droskill@> wrote:
> > > >
> > > > That solves some of it - so that gives me the upper and lower 
> lines
> > > > (over the entire range of the stock - not sure about that).  
> But I
> > > > need the line that represents the current standard deviation 
> from a
> > > > 50d moving average.
> > > > 
> > > > Appreciate the help though - it's a good start for me.
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "wavemechanic" 
<timesarrow@> 
> > > wrote:
> > > > >
> > > > > Something along these lines should work:
> > > > > 
> > > > > mean = cum(c) / (barcount -1);
> > > > > lvmean = lastvalue(mean);
> > > > > sdmean = stdev(mean, barcount -1);
> > > > > top = lastvalue(mean + sdmean);
> > > > > bottom = lastvalue(mean - sdmean);
> > > > > 
> > > > > plot(lvmean, ...
> > > > > plot(top, ...
> > > > > plot(bottom, ... 
> > > > > 
> > > > > Bill
> > > > > 
> > > > > ----- Original Message ----- 
> > > > > From: "droskill" <droskill@>
> > > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > > Sent: Thursday, March 20, 2008 12:14 PM
> > > > > Subject: [amibroker] Standard Deviation as an indicator
> > > > > 
> > > > > 
> > > > > > Hey all - I'm trying to put together an indicator based 
on 
> > > Standard
> > > > > > Deviation.  The difference, from, say Bollinger Bands in 
> this 
> > > case is
> > > > > > that I want to show the Std Dev from a moving average in 
> terms 
> > > of 1,2
> > > > > > and 3 standard deviations from mean, where mean is an N 
day 
> > > moving
> > > > > > average.  So, the mean would be represented by a constant 
> > > straight
> > > > > > line on a chart, and then a line would go up/down around 
it.
> > > > > > 
> > > > > > For an example, check this out:
> > > > > >
> > > > http://www.indexindicators.com/charts/sp500-vs-sp500-50d-rsma-
> > > params-3y-x-x/
> > > > > > 
> > > > > > I really don't know how to approach this - anybody have 
any
> > > > > > thoughts/ideas?  Or maybe someone has done it before (or 
> it's 
> > > in AB
> > > > > > already) and I just haven't found it.
> > > > > > 
> > > > > > Thanks!
> > > > > > 
> > > > > > 
> > > > > > ------------------------------------
> > > > > > 
> > > > > > Please note that this group is for discussion between 
users 
> > > only.
> > > > > > 
> > > > > > To get support from AmiBroker please send an e-mail 
> directly to 
> > > > > > SUPPORT {at} amibroker.com
> > > > > > 
> > > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check 
> > > DEVLOG:
> > > > > > http://www.amibroker.com/devlog/
> > > > > > 
> > > > > > For other support material please check also:
> > > > > > http://www.amibroker.com/support.html
> > > > > > Yahoo! Groups Links
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > -- 
> > > > > > No virus found in this incoming message.
> > > > > > Checked by AVG. 
> > > > > > Version: 7.5.519 / Virus Database: 269.21.7/1335 - 
Release 
> Date:
> > > > 3/19/2008 9:54 AM
> > > > > > 
> > > > > >
> > > > >
> > > >
> > >
> >
>



------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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

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