> >
40yahoogroups.com>,
> >
> > "Louis
> > > > P." <rockprog80@> wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I need the gradient of the slope, and for each bar. This
is where
> > > > it is
> > > > > > difficult...
> > > > > >
> > > > > > Thanks,
> > > > > >
> > > > > > Louis
> > > > > >
> > > > > > 2008/9/19 Tony Grimes <Tonez.Email@>
> > > > > >
> > > > > > > Louis,
> > > > > > >
> > > > > > > If your looking for the slope & difference between HHV of 20
> > bars
> > > > > & the
> > > > > > > current close, all you should need is this:
> > > > > > >
> > > > > > > Pds=20;
> > > > > > >
> > > > > > > LastHighBar = HHVBars(High, Pds);
> > > > > > > LastHighVal = HHV(High, Pds);
> > > > > > >
> > > > > > > Slope = IIf(LastHighBar,(Close - LastHighVal) /
LastHighBar,0);
> > > > > > > CloseDiff = Close - Ref(Close, -LastHighBar);
> > > > > > >
> > > > > > >
> > > > > > > On Fri, Sep 19, 2008 at 4:51 PM, Louis P. <rockprog80@>
wrote:
> > > > > > >
> > > > > > >> Hi Tony,
> > > > > > >>
> > > > > > >> Thank you a lot for your response. I'm still very weak with
> > > > > loops. Last
> > > > > > >> time experimented with one, I had to reboot my
computer! :) So
> > > > > do you know
> > > > > > >> how such a loop could work? And if I run, let's say 2
minutes
> > > > > bar for one
> > > > > > >> year, wouldn't that be really really long to deal with?
I have
> > > > > PIV with 1.5
> > > > > > >> GHz ram.
> > > > > > >>
> > > > > > >> I am looking for a line that ends at each bar and that
starts
> > > > > from the HHV
> > > > > > >> of 20 bars, and I want to do things with this bar: e.g.
compare
> > > > > the closes
> > > > > > >> between current bar and the HHV to the bar and
establish the
> > > > > gradient of
> > > > > > >> that linear regression bar for each bar.
> > > > > > >>
> > > > > > >> Thanks a lot!
> > > > > > >>
> > > > > > >> Louis
> > > > > > >>
> > > > > > >> 2008/9/19 Tony Grimes <Tonez.Email@>
> > > > > > >>
> > > > > > >>> Hi Louis,
> > > > > > >>>
> > > > > > >>> A loop will work, but how slow - it depends (Speed of your
> > > > computer,
> > > > > > >>> number of bars loaded, how many loops your using etc...).
> > > > > Without seeing
> > > > > > >>> what your actually looking for (The end result), I
think you
> > > > > could do it
> > > > > > >>> with one loop, with only one pass through the loop.
The speed
> > > > > should be OK.
> > > > > > >>>
> > > > > > >>> Good Luck.
> > > > > > >>>
> > > > > > >>> Tony
> > > > > > >>>
> > > > > > >>> On Fri, Sep 19, 2008 at 2:47 PM, Louis P.
<rockprog80@> wrote:
> > > > > > >>>
> > > > > > >>>> Hi Tony,
> > > > > > >>>>
> > > > > > >>>> Thanks for the tips. Basically, I'd need a loop and
use it on
> > > > > each and
> > > > > > >>>> every bar of the array to determine the LR, right?
> > > > > > >>>>
> > > > > > >>>> That will slow down my computer a lot, don't you think?
> > > > > > >>>>
> > > > > > >>>> Thanks,
> > > > > > >>>>
> > > > > > >>>> Louis
> > > > > > >>>>
> > > > > > >>>> 2008/9/16 Tony Grimes <Tonez.Email@>
> > > > > > >>>>
> > > > > > >>>>> SelectedValue takes an array ( of numbers) and returns a
> > > > single
> > > > > > >>>>> number based on the bar that is selected in the chart.
> > > > > > >>>>>
> > > > > > >>>>> The first formula worked because SelectedValue was
> > giving you a
> > > > > > >>>>> number.
> > > > > > >>>>>
> > > > > > >>>>> Look at it this way: Array --> SelectedValue --->
Number.
> > > > > > >>>>>
> > > > > > >>>>> Remove SelectedValue: Array---->Array.
> > > > > > >>>>>
> > > > > > >>>>> You can draw a line with single numbers, but not arrays.
> > > > > > >>>>>
> > > > > > >>>>> You can always use a loop.
> > > > > > >>>>>
> > > > > > >>>>> You might want to read: Understanding how AFL works,
in the
> > > > > Amibroker
> > > > > > >>>>> users guide. Until you really understand AFL & array
> > > > > processing, you are
> > > > > > >>>>> going to keep running into these problems, which
will just
> > > > > slow you down.
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>> On Tue, Sep 16, 2008 at 10:34 PM, Louis P.
> > <rockprog80@>wrote:
> > > > > > >>>>>
> > > > > > >>>>>> Hi Tony,
> > > > > > >>>>>>
> > > > > > >>>>>> Why was the first formula working (the one with
> > > > > selectedvalue) and not
> > > > > > >>>>>> the second one? Why simply deleting the "selectedvalue"
> > > > > makes it an array
> > > > > > >>>>>> that will not be accept in "linearray"?
> > > > > > >>>>>>
> > > > > > >>>>>> Is there any way to draw a line without using
lastvalue or
> > > > > > >>>>>> selectedvalue? Do I need to use a loop?
> > > > > > >>>>>>
> > > > > > >>>>>> Thanks,
> > > > > > >>>>>>
> > > > > > >>>>>> Louis
> > > > > > >>>>>>
> > > > > > >>>>>> 2008/9/16 Tony Grimes <Tonez.Email@>
> > > > > > >>>>>>
> > > > > > >>>>>>> Louis,
> > > > > > >>>>>>>
> > > > > > >>>>>>> All of the variables you are creating for the
LineArray
> > > > > function are
> > > > > > >>>>>>> arrays themselves. Although LineArray generates an
> > array, it
> > > > > does not accept
> > > > > > >>>>>>> any arrays as inputs. Additionally, your error
message was
> > > > > probably
> > > > > > >>>>>>> different. It probably went from complaining about
> > argument
> > > > > #4 having the
> > > > > > >>>>>>> incorrect type (which you corrected) to argument
#3 having
> > > > > the incorrect
> > > > > > >>>>>>> type.
> > > > > > >>>>>>>
> > > > > > >>>>>>> On Tue, Sep 16, 2008 at 9:10 PM, Louis P.
> > <rockprog80@>wrote:
> > > > > > >>>>>>>
> > > > > > >>>>>>>> Hi,
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> Thank you for your help.
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> @Ara:
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> If in
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> barhh1 = HHVBars( High, Periods ) ;
> > > > > > >>>>>>>> bi1 = BarIndex();
> > > > > > >>>>>>>> y11 = LinearReg( C, barhh1 ) ;
> > > > > > >>>>>>>> y01 = LinRegIntercept( C, barhh1 ) ;
> > > > > > >>>>>>>> sl1 = LineArray( bi1-barhh1+0, y01, bi1, y11, 0,
True );
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> I replace
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> sl1 = LineArray( bi1-barhh1+0, y01, bi1, y11, 0,
True );
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> by
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> sl1 = LineArray( bi1-barhh1+0, y01, bi1,
> > LastValue(y11), 0,
> > > > > True
> > > > > > >>>>>>>> );
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> I still have the same error message. I don't know
from
> > > > > where it is
> > > > > > >>>>>>>> coming.. unfortunately!
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> @gp_sydney:
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> That was a typo, you are right; I arranged that by
> > adding a
> > > > > 1. But
> > > > > > >>>>>>>> still, the problem remains: the last line does
not work.
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> One day, I asked support if I needed a loop to do
such LR
> > > > > and they
> > > > > > >>>>>>>> said I should not need one.
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> Here is the original code:
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> barhh = SelectedValue( HHVBars( High, Periods ) );
> > > > > > >>>>>>>> bi = SelectedValue( BarIndex() );
> > > > > > >>>>>>>> y1 = SelectedValue( LinearReg( C, barhh ) );
> > > > > > >>>>>>>> y0 = SelectedValue( LinRegIntercept( C, barhh ) );
> > > > > > >>>>>>>> sl = LineArray( bi-barhh+0, y0, bi, y1, 0, True );
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> What I want to do is simply eliminate the
"selectedvalue"
> > > > > part and
> > > > > > >>>>>>>> use the code not only for the selected data but
for the
> > > > > whole data. I want
> > > > > > >>>>>>>> to be able to draw a line from each HHV to each
bar and
> > > > > then work with the
> > > > > > >>>>>>>> result.
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> If it can't be done without a loop, I feel like
I'll be
> > > > > lost in time
> > > > > > >>>>>>>> again; last time I tried to run a loop on my
computer it
> > > > > freezed and after 2
> > > > > > >>>>>>>> minutes I decided to shut down AB...
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> Thanks for the help,
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> Louis
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>> 2008/9/16 gp_sydney <gp.investment@>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>>> As Ara said, in the shown code snippet you don't
have
> > > > > "barhh"
> > > > > > >>>>>>>>> defined,
> > > > > > >>>>>>>>> only "barhh1".
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>> Beyond that, you have the same issue I mentioned
> > > > > originally, that
> > > > > > >>>>>>>>> the
> > > > > > >>>>>>>>> linear regression functions and LineArray
function take
> > > > scalar
> > > > > > >>>>>>>>> values
> > > > > > >>>>>>>>> (ie. single numbers) as parameters, not arrays.
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>> I gather you're trying to create a line from the
> > > > > most-recent HHV
> > > > > > >>>>>>>>> value
> > > > > > >>>>>>>>> using the subsequent close data for every bar on the
> > > > > chart. As I
> > > > > > >>>>>>>>> don't
> > > > > > >>>>>>>>> think the linear regression functions can take
arrays
> > > > for the
> > > > > > >>>>>>>>> period,
> > > > > > >>>>>>>>> I think you'd need to use a loop and do the linear
> > > > regression
> > > > > > >>>>>>>>> yourself
> > > > > > >>>>>>>>> at each bar (you could call the array functions
> > within the
> > > > > loop,
> > > > > > >>>>>>>>> but
> > > > > > >>>>>>>>> since they fill a whole array each time, they
would do a
> > > > > lot of
> > > > > > >>>>>>>>> unnecessary work). If you do that yourself
inside the
> > > > > loop, then at
> > > > > > >>>>>>>>> each bar you'd have scalar 'x' and 'y' values to
> > calculate
> > > > > the line
> > > > > > >>>>>>>>> slope and so on.
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>> For what it's worth, the BarIndex function
simply gives
> > > > > you the bar
> > > > > > >>>>>>>>> number. It provides a way of using the current bar
> > number
> > > > > in array
> > > > > > >>>>>>>>> formula.
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>> Regards,
> > > > > > >>>>>>>>> GP
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>> --- In
> >
amibroker@xxxxxxxxxxxxxxx <amibroker%
40yahoogroups.com><amibroker%
> >
40yahoogroups.com>
> > > > > <amibroker%
40yahoogroups.com>,
> > > > > > >>>>>>>>> "Louis P." <rockprog80@> wrote:
> > > > > > >>>>>>>>> >
> > > > > > >>>>>>>>> > Hi,
> > > > > > >>>>>>>>> >
> > > > > > >>>>>>>>> > Sorry, You can replace "periods" by 50 if you
wish. I
> > > > > just forgot
> > > > > > >>>>>>>>> to
> > > > > > >>>>>>>>> > include that.
> > > > > > >>>>>>>>> >
> > > > > > >>>>>>>>> > barhh1 = HHVBars( High, *50* ) ;
> > > > > > >>>>>>>>> > bi1 = BarIndex() ;
> > > > > > >>>>>>>>> > y11 = LinearReg( C, barhh ) ;
> > > > > > >>>>>>>>> > y01 = LinRegIntercept( C, barhh ) ;
> > > > > > >>>>>>>>> > sl1 = LineArray( bi1-barhh1+0, y01, bi1, y11, 0,
> > True );
> > > > > > >>>>>>>>> >
> > > > > > >>>>>>>>> > Still, it is not working, even if barhh1 is
defined...
> > > > > > >>>>>>>>> >
> > > > > > >>>>>>>>> > Louis
> > > > > > >>>>>>>>> >
> > > > > > >>>>>>>>> > 2008/9/16 Ara Kaloustian <ara1@>
> > > > > > >>>>>>>>> >
> > > > > > >>>>>>>>> > > y11 and y01 use "barhh" which is not defined.
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > > You have defined "barhh1"
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > > ----- Original Message -----
> > > > > > >>>>>>>>> > > *From:* Louis P. <rockprog80@>
> > > > > > >>>>>>>>> > > *To:*
> >
amibroker@xxxxxxxxxxxxxxx <amibroker%
40yahoogroups.com><amibroker%
> >
40yahoogroups.com>
> > > > > <amibroker%
40yahoogroups.com>
> > > > > > >>>>>>>>> > > *Sent:* Tuesday, September 16, 2008 2:46 PM
> > > > > > >>>>>>>>> > > *Subject:* [amibroker] What is wrong?
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > > Hi,
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > > What is wrong in the following formula?
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > > barhh1 = HHVBars( High, Periods ) ;
> > > > > > >>>>>>>>> > > bi1 = BarIndex() ;
> > > > > > >>>>>>>>> > > y11 = LinearReg( C, barhh ) ;
> > > > > > >>>>>>>>> > > y01 = LinRegIntercept( C, barhh ) ;
> > > > > > >>>>>>>>> > > sl1 = LineArray( bi1-barhh1+0, y01, bi1, y11, 0,
> > True );
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > > Thanks,
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > > Louis
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > > p.s. There was "Selectedvalue" in the first four
> > lines
> > > > > but I
> > > > > > >>>>>>>>> don't
> > > > > > >>>>>>>>> want to
> > > > > > >>>>>>>>> > > plot it on the chart based on where I am on that
> > > > > chart, but
> > > > > > >>>>>>>>> simply
> > > > > > >>>>>>>>> set the
> > > > > > >>>>>>>>> > > variable so I can use the stuff later.
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> > >
> > > > > > >>>>>>>>> >
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>>
> > > > > > >>>>>>>>
> > > > > > >>>>>>>
> > > > > > >>>>>>
> > > > > > >>>>>
> > > > > > >>>>
> > > > > > >>>
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
>