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

[amibroker] Re: Absolute value ATR?



PureBytes Links

Trading Reference Links

Add a plot for the MA to Tomasz's percent bands (envelopes) and you 
will get a better feel for what they are all about.

brian_z

--- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@xxx> wrote:
>
> Louis,
> 
> Have you seen Tomasz's code for % bands (charts >> bands >> percent 
> bands
> 
> P = ParamField("Price field",-1);
> Periods = Param("Periods", 15, 2, 100, 1 );
> Width = Param("Width%", 2, 0, 10, 0.05 );
> Color = ParamColor("Color", colorCycle );
> Style = ParamStyle("Style");
> CenterLine = MA( P, Periods );
> Plot( (1 + Width * 0.01) * CenterLine, "%EnvTop" + _PARAM_VALUES(), 
> Color, Style ); 
> Plot( (1 - Width * 0.01) * CenterLine, "%EnvBot" + _PARAM_VALUES(), 
> Color, Style ); 
> 
> I think it is a fine example of bands - the same thing can be done 
> with StDev% - add or subtract it from a MA to form the bands.
> 
> I have used MA +_ smoothed StDev% as stops (profit and loss).
> 
> One of the hard choices is what type of smoothing/periods to use 
for 
> the bands OR should we use them in short time frames (less lag but 
> the stops jump around more)? - always hard decisions to make.
> 
> > StDevPercent = StDev(C,Periods)/Ref (C,-1) * 100;
> 
> Since StDev is constructed using variance from a arithmetic average 
I 
> feel StDevPercent = StDev(C,Periods)/MA (C,Periods) * 100; is 
> technically more correct but, IMO, it doesn't matter as long as 
> consistency is maintained and, more importantly,it works.
> 
> See how you get on along those lines.
> 
> brian_z
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Louis Préfontaine" 
> <rockprog80@> wrote:
> >
> > Hi Brian,
> > 
> > I kind of missed your reply, and got on other projects.. But I'm 
> back at the
> > Stdev problem, and here is the formula I got for Stdev:
> > 
> > _SECTION_BEGIN("Stdev");
> > SetChartOptions (0,0,Chartgrid0);
> > P = ParamField("Price field",-1);
> > Periods = Param("Periods", 15, 2, 200, 1 );
> > StDevPercent = StDev(C,Periods)/Ref (C,-1) * 100;
> > Plot( StDevpercent, _DEFAULT_NAME(), ParamColor( "Color", 
> colorCycle ),
> > ParamStyle("Style") );
> > _SECTION_END();
> > 
> > I re-read your previous posts, and I think you may be able to 
help 
> me with
> > what I am trying to do.
> > 
> > I would like to be able to set a different profit stop (33%)  and 
> stop-loss
> > (100%) depending on the results.  I don't know where to start to 
do 
> this.  I
> > am confident in writing simple rules like  "buy = ... AND ...  
> or ...
> > ,etc."  but I think I may need to do something more complex to do 
> what I
> > need to do with this.
> > 
> > Do you have any idea?
> > 
> > Thanks,
> > 
> > Louis
> > 
> > 2008/2/26, brian_z111 <brian_z111@>:
> > >
> > >   Louis,
> > >
> > > > Thanks for the suggestion. I must do something wrong however
> > > >because from
> > > > the code I wrote
> > > > I get only results of ATR > 3-4. Only Indu.x is under 2; all 
the
> > > >other one
> > > > are over 3-4, and sometimes 6-7 and more.
> > >
> > > I tried your code and didn't see any problems.
> > > For the Dow constituents most are around 1.25 - 2% for ATR(15) 
in 
> the
> > > period I looked at.
> > >
> > > Are you sure you didn't have Weekly selected instead of Daily?
> > >
> > > brian_z
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx <amibroker%
> 40yahoogroups.com>, "LouisPréfontaine"
> > > <rockprog80@> wrote:
> > > >
> > > > Hi,
> > > >
> > > > Thanks for the suggestion. I must do something wrong however
> > > because from
> > > > the code I wrote
> > > >
> > > > _SECTION_BEGIN("ATR");
> > > > periods = Param( "Periods", 15, 1, 200, 1 );
> > > > Plot( ATR(periods)/Ref(C,-1)*100
> > > > , _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), 
ParamStyle
> > > ("Style") );
> > > >
> > > > LongPer = Param("Long Period", 50, 10, 100, 5 ); /* select 
> periods
> > > with
> > > > parameter window */
> > > >
> > > > MidPer = Param("Mid Period", 20, 0, 50, 1);
> > > > ShortPer = Param("Short Period", 10, 3, 10, 1 );
> > > >
> > > > LongEMA = EMA( ATR(periods)/Ref(C,-1)*100, LongPer );
> > > > MidEMA = EMA (ATR(periods)/Ref(C,-1)*100, MidPer);
> > > > ShortEMA = EMA( ATR(periods)/Ref(C,-1)*100, ShortPer );
> > > >
> > > > _SECTION_END();
> > > >
> > > > _SECTION_BEGIN("ema-ATR");
> > > > Plot( LongEMA, "EMA(ATR(periods)/Ref(C,-1)*100, "+WriteVal
> > > (LongPer,1)+")",
> > > > colorBlue,
> > > > styleLine|styleNoRescale );
> > > > Plot( MidEMA, " EMA(ATR(periods)/Ref(C,-1)*100, "+WriteVal
> (MidPer,1)
> > > +")",
> > > > colorBrown,
> > > > styleLine|styleNoRescale );
> > > > Plot( ShortEMA, " EMA(ATR(periods)/Ref(C,-1)*100,
> > > > "+WriteVal(ShortPer,1)+")", colorGreen,
> > > > styleLine|styleNoRescale );
> > > >
> > > >
> > > > _SECTION_END();
> > > >
> > > > I get only results of ATR > 3-4. Only Indu.x is under 2; all 
the
> > > other one
> > > > are over 3-4, and sometimes 6-7 and more.
> > > >
> > > > However, are you sure about the idea of entering/exiting a 
stock
> > > when
> > > > volatility gets too high? Wouldn't it be better simply to 
scan 
> and
> > > avoid
> > > > high volatily stocks to reduce the drawdown possibility?
> > > >
> > > > Thanks,
> > > >
> > > > Louis
> > > >
> > > > 2008/2/24, brian_z111 <brian_z111@>:
> > > > >
> > > > > If you want a relative measure of range then you could use
> > > ATR%, as
> > > > > suggested by Graham.
> > > > >
> > > > > High volatility stocks would be filtered by e.g. ATR% > 2 
etc.
> > > > >
> > > > > In that case your stops would be something like:
> > > > >
> > > > > ProfitStop = Ref(C,-1) * (1 + ATR%/100);
> > > > > StopLoss = Ref(C,-1) * (1 - ATR%/100);
> > > > >
> > > > > If you want to standardise range then you could use:
> > > > >
> > > > > StandardATR = StDev(ATR(1),Periods);
> > > > >
> > > > > An example of a stop would then be:
> > > > >
> > > > > ProfitStop = Ref(C,-1) + StDev(ATR(1),20);
> > > > >
> > > > > Or maybe (for live work):
> > > > >
> > > > > ProfitStop = Ref(C,-1) + Ref(StDev(ATR(1),20),-1);
> > > > >
> > > > > Or something like that.
> > > > >
> > > > > That is only one way of doing it.
> > > > >
> > > > > You can try whatever you like, within the boundaries of your
> > > > > knowledge (plus a little bit more).
> > > > >
> > > > > brian_z *;-)
> > > > >
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx <amibroker%
> 40yahoogroups.com><amibroker%40yahoogroups.com>,
> > > > > "brian_z111" <brian_z111@> wrote:
> > > > > >
> > > > > > Louis,
> > > > > >
> > > > > > > only thing I need to know is simply to set the STdev at 
2 
> or 3
> > > > > (if
> > > > > > it's what
> > > > > > > I want to do) and then automatically ATR will be use 
that 
> new
> > > > > StDev?
> > > > > > >
> > > > > >
> > > > > > No.
> > > > > >
> > > > > > ATR and StDev are both measures of volatility but they 
> measure
> > > it
> > > > > in
> > > > > > different ways. Generally you would use one or the other.
> > > > > >
> > > > > > StDev has special uses.
> > > > > >
> > > > > > If you want to use them it would pay off to study them 
> closely
> > > > > first.
> > > > > >
> > > > > >
> > > > > > > I like your idea to make two groups; one with high 
> volatility
> > > and
> > > > > > one with
> > > > > > > low volatility. Would you consider it would be possible 
to
> > > > > adjust
> > > > > > the
> > > > > > > stop-loss differently for each group?
> > > > > >
> > > > > > You could try it e.g. the stop loss can be the close - 
StDev
> > > (C,20).
> > > > > > You can vary the stop loss for one group by using a 
> multiplier
> > > so
> > > > > the
> > > > > > stop loss could be close - StDev(C,20) * 1.5 for one 
group 
> and
> > > > > close -
> > > > > > StDev(C,20) for the other.
> > > > > >
> > > > > >
> > > > > >
> > > > > > > And how do you filter the top
> > > > > > > performers?
> > > > > >
> > > > > > It depends on what you have chosen as your favourite 
metric 
> for
> > > > > > evaluating systems. As I said in an earlier post I like 
> Power
> > > > > Factor
> > > > > > (I will be explaining this at the UKB soon) but you would 
be
> > > better
> > > > > > served choosing your own.
> > > > > >
> > > > > > If you are not sure on evaluation, and use of the 
metrics, 
> then
> > > > > > Howard Bandy's book is a good place to start.
> > > > > >
> > > > > > Sorry, I can't help you any further with this.
> > > > > > I have a couple of posts for the UKB I want to get 
finished.
> > > > > >
> > > > > > BTW did you see the answer I gave you yesterday 
on "Trying 
> to
> > > > > compare
> > > > > > market and industry" ?. see message # 120270
> > > > > >
> > > > > > I hopoe that helps you a little and good luck with your 
> trading.
> > > > > >
> > > > > > brian_z
> > > > > >
> > > > > >
> > > > > > --- In amibroker@xxxxxxxxxxxxxxx <amibroker%
> 40yahoogroups.com><amibroker%
> > > 40yahoogroups.com>, "Louis
> > > > > Préfontaine"
> > > > > > <rockprog80@> wrote:
> > > > > > >
> > > > > > > Hi Brian,
> > > > > > >
> > > > > > > Thanks for those explanation. I will experiment with 
this
> > > > > tonight
> > > > > > and
> > > > > > > tomorrow. However, I am not sure about something: are 
you
> > > saying
> > > > > > that the
> > > > > > > only thing I need to know is simply to set the STdev at 
2 
> or 3
> > > > > (if
> > > > > > it's what
> > > > > > > I want to do) and then automatically ATR will be use 
that 
> new
> > > > > StDev?
> > > > > > >
> > > > > > > I like your idea to make two groups; one with high 
> volatility
> > > and
> > > > > > one with
> > > > > > > low volatility. Would you consider it would be possible 
to
> > > > > adjust
> > > > > > the
> > > > > > > stop-loss differently for each group? And how do you 
> filter
> > > the
> > > > > top
> > > > > > > performers?
> > > > > > >
> > > > > > > As always, thanks for your help!
> > > > > > >
> > > > > > > Louis
> > > > > > >
> > > > > > > 2008/2/24, brian_z111 <brian_z111@>:
> > > > > > > >
> > > > > > > > Sorry Louis, a mistake there.
> > > > > > > >
> > > > > > > > I am getting my standard deviations mixed up between
> > > programs.
> > > > > > > >
> > > > > > > > In AB StDev is 1 by default and is in $values.
> > > > > > > > To use AB's StDev at 2,3 deviations etc just multiply 
> StDev
> > > > > (C,10)
> > > > > > * 2
> > > > > > > > etc
> > > > > > > > To use it as StDev%
> > > > > > > > StDevPercent = StDev(C,Periods)/MA(C,Periods) * 100;
> > > > > > > >
> > > > > > > > For STANDARD measures of deviation use StDev.
> > > > > > > > For relative measures of deviation use ATR as % or 
> StDev as
> > > %
> > > > > > > >
> > > > > > > > One example:
> > > > > > > >
> > > > > > > > Say you want to compare the performance of a fast 
horse 
> and
> > > a
> > > > > slow
> > > > > > > > horse. If they both travel 1 StDev in the same time 
> (number
> > > of
> > > > > > > > periods) their performance is equal but the VALUE 
> (QUALITY)
> > > of
> > > > > the
> > > > > > > > fast horses performance is higher - it's a grade one 
> horse
> > > > > > compared
> > > > > > > > to the other horse, which is a grade 2 (using speed 
as 
> the
> > > > > > criteria).
> > > > > > > >
> > > > > > > > In practice - profit/loss stops might be set at +- 1
> > > standard
> > > > > > > > devation and then filtered for the top performers. 
The 
> top
> > > > > > performers
> > > > > > > > could then be segregated into two watchlists - those 
> with 1
> > > > > stdev
> > > > > > >
> > > > > > > > 2% (high volatility stocks) and those with stdev <=2% 
> (low
> > > > > > volatility
> > > > > > > > stocks) - this would allow a comparison of the 
> performance
> > > of
> > > > > that
> > > > > > > > trading signal/stop loss combination on high and low
> > > volatility
> > > > > > > > stocks.
> > > > > > > >
> > > > > > > > brian_z
> > > > > > > >
> > > > > > > >
> > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx <amibroker%
> 40yahoogroups.com><amibroker%
> > > 40yahoogroups.com><amibroker%40yahoogroups.com>,
> > > > > > > > "brian_z111" <brian_z111@> wrote:
> > > > > > > > >
> > > > > > > > > Louis,
> > > > > > > > >
> > > > > > > > > >Does anyone know if it is possible to get an 
absolute
> > > value
> > > > > > ATR?
> > > > > > > > >
> > > > > > > > > The Abs() function serves that purpose but I think 
you
> > > mean
> > > > > > > > something
> > > > > > > > > else.
> > > > > > > > >
> > > > > > > > > ATR is a measure of volatility and it is specific 
for 
> each
> > > > > > stock (or
> > > > > > > > > instrument). The whole idea of it (AFAIK) is to use 
> it on
> > > an
> > > > > > > > > individual
> > > > > > > > > stock basis.
> > > > > > > > >
> > > > > > > > > It can be useful to compare volatility:
> > > > > > > > >
> > > > > > > > > 1) internally e.g. against an average of the last 
(x)
> > > days OR
> > > > > > > > against
> > > > > > > > > the StDev (standard deviation) of the volatility 
> measure
> > > OR
> > > > > > just use
> > > > > > > > > StDev of the Close etc on its own.
> > > > > > > > >
> > > > > > > > > StDev() function does allow to change the setting 
> between
> > > 1
> > > > > or
> > > > > > 2 etc
> > > > > > > > >
> > > > > > > > > 2) externally to the volatility of the market OR a 
> sector
> > > > > that
> > > > > > the
> > > > > > > > > stock is a member of OR compared to another stock 
in 
> the
> > > same
> > > > > > sector
> > > > > > > > > etc.
> > > > > > > > >
> > > > > > > > > brian_z
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx <amibroker%
> 40yahoogroups.com><amibroker%
> > > 40yahoogroups.com><amibroker%
> > > > > 40yahoogroups.com>,
> > > > > > Graham
> > > > > > > > <kavemanperth@> wrote:
> > > > > > > > > >
> > > > > > > > > > you could try a percentage type
> > > > > > > > > >
> > > > > > > > > > ATR(10)/ref(c,-1)*100
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Cheers
> > > > > > > > > > Graham Kav
> > > > > > > > > > AFL Writing Service
> > > > > > > > > > http://www.aflwriting.com
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 24/02/2008, louisprefontaine <rockprog80@> 
wrote:
> > > > > > > > > > > Does anyone know if it is possible to get an 
> absolute
> > > > > value
> > > > > > > > ATR?
> > > > > > > > > I
> > > > > > > > > > > already use the ATR, but it changes from stock 
to
> > > stock,
> > > > > > > > > depending on
> > > > > > > > > > > the value of the stock. Would it be possible to 
> get an
> > > > > > > > absolute
> > > > > > > > > value
> > > > > > > > > > > indicator, like CMF, RSI, etc.? 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
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >  
> > >
> >
>




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/