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

[amibroker] Re: How to extract position in (non time based) array - AFL EXPERTS?


  • Date: Tue, 22 Dec 2009 01:29:14 -0000
  • From: "Mike" <sfclimbers@xxxxxxxxx>
  • Subject: [amibroker] Re: How to extract position in (non time based) array - AFL EXPERTS?

PureBytes Links

Trading Reference Links

Try this:

y[1] = 1103;
y[2] = 1107;
y[3] = 1095;
y[4] = 1100;

highestY = Highest(y);
indices = BarIndex();
x = LastValue( ValueWhen( y == highestY, indices ) );

_TRACE("Highest Y is: " + LastValue(highestY));
_TRACE("Last index of highest Y is: " + x);

Keep in mind that although you are creating your own array (y), the length of that array is dictated by the duration of the scan/exploration/backtest/optimization. In other words, if you explore a single bar from the AA window, your code will fail since you require at least 4 bars to populate your array. Also, array indexing is zero based. So, it would be cleaner to have your elements populated starting at [0] instead of [1].

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "kevinoversby" <kevinoversby@xxx> wrote:
>
> Thanks Ara,
> 
> I tried it like this:
> 
> y[1]=1103; y[2]=1107; y[3]= 1095; y[4]= 1100;
> x = ValueWhen(HHVBars(y,4)==0,BarIndex());
> 
> but get 16,758 rather than 2 - is there another way to write it?
> 
> Looks like a simple problem!
> 
> 
> Kevin
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@> wrote:
> >
> > use valuewhen function and return the barindex() value
> > 
> > ----- Original Message ----- 
> > From: "kevinoversby" <kevinoversby@>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Monday, December 21, 2009 12:31 PM
> > Subject: [amibroker] How to extract position in (non time based) array
> > 
> > 
> > >I can't find a function in the reference to do this.
> > > 
> > > For example, I have an array of the last 4 highs (from Zig function):
> > > 
> > > {1103 1107 1095 1100}
> > > 
> > > I want to return the index of the highest value (i.e 2).
> > > 
> > > Is there a way to do this?
> > > 
> > > 
> > > Thanks
> > > 
> > > Kevin
> > > 
> > > 
> > > 
> > > 
> > > 
> > > ------------------------------------
> > > 
> > > **** IMPORTANT PLEASE READ ****
> > > This group is for the discussion between users only.
> > > This is *NOT* technical support channel.
> > > 
> > > TO GET TECHNICAL SUPPORT send an e-mail directly to 
> > > SUPPORT {at} amibroker.com
> > > 
> > > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> > > http://www.amibroker.com/feedback/
> > > (submissions sent via other channels won't be considered)
> > > 
> > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > > http://www.amibroker.com/devlog/
> > > 
> > > Yahoo! Groups Links
> > > 
> > > 
> > > 
> > >
> >
>




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

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

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:
    amibroker-digest@xxxxxxxxxxxxxxx 
    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/