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

Re: [amibroker] Re: Average Range



PureBytes Links

Trading Reference Links

Hi Grant,
 
Several hours ago I posted a reply to you with code attached, however it has yet to show up.  Maybe I've been away so long that the rules have changed, but no matter.  I'll try again and just include the code within the message.  The following will plot the Average Range as either points or percent of average Typical price (selectable via the parameters menu (right click the chart, select Parameters in the popup).  Period for the average is also selectable in Parameters.  This uses a simple MA.  MA variations for Exp, Hull, etc. can easily be substituted, or added as parameter selectable choices.
 
One note on the code Brian provided:  the _expression_ H-L used in Midpoint returns the range for only the last bar (day).  As such, IMHO  it is not useful for evaluating the midpoint of each day in the average range period.  And while I didn't play with it much, I couldn't get it to function properly in an indicator  (my apologies Brian if I missed something).  As such, I find that either the MA of Close or Average [ (H+L+C)/3 ] array are useful for an indicator such as I think you wanted.  Below is the code originally attached to the missing post, slightly modified to use AVG rather than C for the % indicator.
 
Enjoy.
 
Peace and Justice   ---   Patrick
 
 

// Average Daily Range

// coded by NWTrader

 

R = H-L;

periods = Param( "Periods", 5, 1, 65, 1 );

Display = Param("Display Points (1) or % of MA of Typical Price (2)", 1,1,2,1 );

AR = MA(R, Periods);

PAR = (AR/MA(Avg,periods) )*100 ;

X = IIf(display == 1, AR, PAR);

Plot( X , WriteIf(DISPLAY==1,

EncodeColor(colorYellow) + "Average (" + WriteVal(PERIODS,2.0) + " period ) Daily Range (points) " ,

EncodeColor(colorBlue) + "Average (" + WriteVal(PERIODS,2.0) + " period ) Daily Range (% of C) "

),

IIf(display == 1, colorYellow , colorBlue) ,

ParamStyle(" MA Style", styleDashed | styleThick)

);

 

 
 
----- Original Message -----
From: longarm61
Sent: Monday, January 28, 2008 8:00 PM
Subject: [amibroker] Re: Average Range

Thank you very much, Brian.  Percentage is exactly what I wanted
(didn't want to ask for more than I absolutely needed, though). 
Sorry for being such a newb, but how would I plot this formula?


--- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@xxx> wrote:
>
> Actually, if I was going standardise BarRange I would use the
MidPoint
>
> Periods = x;
> MidPoint = (H-L)/2;
> BarRangePercent = (H-L)/Midpoint *100;
> AveBarRangePercent = MA(BarRangePercent,x);
>
>
> brian_z
>
> --- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@> wrote:
> >
> > Hello Grant,
> >
> > Something along the lines of?
> >
> > Periods = x;
> > AveBarRange = Sum(H-L,x)/x;
> >
> > You can standardise (or normalise) by converting to %:
> >
> > BarRangePercent = (H-L)/L * 100;
> > Periods = x;
> > AveBarRange = Sum(BarRangePercent,x)/x;
> >
> > I always normalise in situations like that.
> >
********************************************************************
> > SUM
> > - sum data over specified number of bars Moving averages,
summation
> >
> > 
> >
> > SYNTAX  sum( ARRAY, periods ) 
> > RETURNS ARRAY 
> > FUNCTION  Calculates a cumulative sum of the ARRAY for the
> specified
> > number of lookback periods (including today). 
> > EXAMPLE The formula "sum( CLOSE, 14 )" returns the sum of the
> > preceding 14 closing prices. A 14-period simple moving average
> could
> > be written "sum(C,14) / 14."
> >
>
*********************************************************************
> >
> > You can use the Param function for periods if you want to change
> the
> > periods from with the context menu on a chart.
> >
> > PARAM
> > - add user user-definable numeric parameter Exploration /
Indicators
> > (AFL 2.3)
> > 
> >
> > SYNTAX  Param( ''name'', defaultval, min, max, step, sincr = 0 ) 
> > RETURNS NUMBER 
> > FUNCTION  Adds a new user-definable parameter, which will be
> > accessible via Parameters dialog :
> > right click over chart pane and select "Parameters" or press
Ctrl+R
> > allows to change chart parameters - changes are reflected
> > immediatelly.
> >
> > "name" - defines parameter name that will be displayed in the
> > parameters dialog
> > defaultval - defines default value of the parameter
> > min, max - define minimum and maximum values of the parameter
> > step - defines minimum increase of the parameter via slider in
the
> > Parameters dialog
> > sincr - automatic section increment value (used by drag-drop
> > interface to increase default values for parameters)
> > WARNING: default/min/max/step parameters have to be CONSTANT
> numbers.
> > This is because these values are cached and are not re-read
during
> > subsequent formula evaluations.
> >
> >
> > brian_z
> > 
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "longarm61" <norm1@> wrote:
> > >
> > > I would simply like an indicator that shows the average range,
> from
> > > high to low, of x number of bars.  Just the bars only.  ATR
takes
> > > into account the previous close, which I don't want.
> > >
> > > Anyone have or can point me to a formula for this?
> > >
> > > Thanks in advance,
> > >
> > > Grant
> > >
> >
>




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/
__._,_.___

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___