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

Re: [amibroker] Re: Converting selectedbar and lastvalue to...



PureBytes Links

Trading Reference Links

Are you looking for the Tushar-Kroll R-squared analysis?  If so, it is in the library.  If not it sounds like that would be a good place to start.
 
Bill
----- Original Message -----
From: Louis P.
Sent: Sunday, September 14, 2008 12:22 AM
Subject: Re: [amibroker] Re: Converting selectedbar and lastvalue to...

Hi,

Forget about the Linear Regression.  I can use Rsquared: I'd like to be able to calculate for each bar:

a) if it is close to a very good rsquared fit (let's say +0.50);
b) if the line that is drawn (or calculated, since there is no need to draw it) has a slope between 10 and 20 degrees.

How would you do that?

Thanks,

Louis


2008/9/13 gp_sydney <gp.investment@xxxxxxxxx>

Sorry, I'm not up on the maths of regression, and am not sure what
that code is trying to do. It seems to be correlating the Close array
to a fixed-slope bar number array (BarIndex) over the range since the
most recent HHV. From what I can see, there is no use of LastValue or
SelectedValue in that code, and so as long as MA and Sum can accept
arrays as the range, then r2 should be an array with the appropriate
value at each bar.

However, I'm not sure what correlating to the BarIndex array is
achieving, or what you mean by drawing (or calculating) lines from
some point to the HHV or by backtesting with a particular gradient.
Perhaps it's obvious, but regression is not something I'm very
familiar with.



Regards,
GP

--- In amibroker@xxxxxxxxxxxxxxx, "Louis P." <rockprog80@xxx> wrote:
>
> Hi,
>
> Ok let's look at this from a different perspective:
>
> // variable-period Correlation
> function CorrV( x, y, range )
> {
>
> avX = MA( x, range );
> avY = MA( y, range );
> avXY = MA( x * y, range );
>
> ssqrX = Sum( x * x, range );
> ssqrY = Sum( y * y, range );
>
> VarX = Max( ssqrx/range - avX * avX, 0 );
> VarY = Max( ssqry/range - avY * avY, 0 );
>
> return Nz( ( avXY - avX * avY ) / sqrt( VarX * VarY ) );
> }
>
> // variable-period R squared
> function RSquaredV( array, range )
> {
> return CorrV( BarIndex()+1, array, range ) ^ 2;
> }
>
> Periods = Param("HHV Period", 20, 1, 100, 1 );
>
> // bars since HHV
> barhh = HHVBars( High, Periods );
>
> r2 = RSquaredV( C, Max( 1, barhh ) );
>
> With the code above, I get a Rsquared from a HHV, which is good.
But I'd
> like that to be backtestable only with a slope of a particular gradient,
> let's say 10-20 degrees. I know it would sound useless to be able
to draw a
> line from each point to the HHV before (the chart would look like a
spider
> web) and I don't want to draw the stuff. But I'd like to be able to
> calculate for each bar:
>
> a) if it is close to a very good rsquared fit (let's say +0.50);
> b) if the line that is drawn (or calculated, since there is no need
to draw
> it) has a slope between 10 and 20 degrees.
>
> How would you do that?
>
> Thanks,
>
> Louis
>
>
>
> 2008/9/12 gp_sydney <gp.investment@xxx>

>
> > I think the first question needs to be what is the result you are
> > expecting?
> >
> > In that code you are passing arrays to functions that expect single
> > values, which is why the SelectedValue and LastValue functions would
> > have been there before.
> >
> > LineArray draws a line between two points on the chart, and the
> > coordinates of those points need to be single values. What would you
> > expect to see by passing arrays as the coordinates?
> >
> > Regards,
> > GP
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx <amibroker%40yahoogroups.com>,

"Louis P."
> > <rockprog80@> wrote:
> > >
> > > Hi,
> > >
> > > Here is what I tried to do:
> > >
> > > barhh1 = HHVBars( High, Periods ) ;
> > > bi1 = BarIndex() ;
> > > y11 = LinearReg( C, barhh1 ) ;
> > > y01 = LinRegIntercept( H, barhh1 ) ;
> > > sl1 = LineArray( bi1-barhh1+0, y01, bi1, y11, 0, True );
> > >
> > > Unfortunately it seems there is an error...
> > >
> > > What's the barindex for in that code, and if the problem is there,
> > how can I
> > > deal with it, considering that for the first 4 lines of that code it
> > began
> > > with "selectedvalue"?
> > >
> > > Thanks,
> > >
> > > Louis
> > >
> > >
> > >
> > > 2008/9/12 Barry Scarborough <razzbarry@>
> > >
> > > > Ara said just use the variable. For instance C is an array and
using
> > > > C will point to the last value, or the current bar, in the
array. To
> > > > point to a bar prior to the current one use Ref(C, -n); where n is
> > > > the number of bars prior to the current one. Replace C with
the array
> > > > you want to get the value for.
> > > >
> > > > Use LastValue when you need a value and not an array. An
example is
> > > > in an IF statement. IF() cannot take an array and you have to
get the
> > > > value. If you want the value of some previous value use
LastValue(ref
> > > > (c,-n));
> > > >
> > > > If your results get confusing dump it to the interpretation
window so
> > > > you can compare the values with what you expect them to be. Use
> > > > something like this:
> > > >
> > > > printf(numtostr(lastvalue(c), 1.2)); // current value of c
> > > > printf("\n" + numtostr(lastvalue(ref(c, -1)), 1.2)); // previous c
> > > >
> > > > Barry
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx
<amibroker%40yahoogroups.com><amibroker%

> > 40yahoogroups.com>, "Ara
> > > > Kaloustian" <ara1@> wrote:
> > > > >
> > > > > just use the variable (without selectedvalue or lastvalue)
> > > > > ----- Original Message -----
> > > > > From: Louis P.
> > > > > To: amibroker@xxxxxxxxxxxxxxx
<amibroker%40yahoogroups.com><amibroker%
> > 40yahoogroups.com>
> > > > > Sent: Friday, September 12, 2008 2:47 PM
> > > > > Subject: [amibroker] Converting selectedbar and lastvalue to...
> > > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > > I need to know how to convert code that is using selectedbar (it
> > > > gets the bar before where I am on the chart) and lastvalue (which
> > > > gets the bar at the end of the array) to a code that is
checking each
> > > > and every bar for the pattern.
> > > > >
> > > > > Anyone know how to do that?
> > > > >
> > > > > Thanks,
> > > > >
> > > > > Louis
> > > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
>




No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.169 / Virus Database: 270.6.21/1670 - Release Date: 9/13/2008 12:50 PM
__._,_.___

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

__,_._,___