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

[amibroker] Re: basic question about referencing bars



PureBytes Links

Trading Reference Links

See Andrew's reply for the solution. http://finance.groups.yahoo.com/group/amibroker/message/135499

Basically, you don't need a loop at all. It is actually pretty rare 
that you ever need one. In the vast majority of cases, your problem 
can be expressed in array manipulations across all bars 
simultaneously.

If you haven't come across this page yet, it helps to clarify things:
http://www.amibroker.com/guide/h_understandafl.html

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "bigitop" <doctormuniz@xxx> wrote:
>
> i read the user guide thouroughly but it seems im missing something. 
> i had tried "if(result == 1)" (with the equality operator) but it
> gives me the same error as in the beginning:
> 
> variableX = variableY / abs(variableZ);
> result = IIf (variableX > .5, 1, 0);
> 
> if(result == 1){
> Filter = Open > 40 & Open < 60;
> }
> 
> it is still seeing "result" as an array instead of as a number!
> 
> "Condition in IF, WHILE, FOR statements has to be numeric or boolean
> type. You cannot use an array here, please use [] (array subscript
> operator) to access array elements"
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@> 
wrote:
> >
> > You need to use == instead of =...
> > 
> > i.e. change the line,
> > 
> > if(result = 1){
> > 
> > to,
> > 
> > if(result == 1){
> > 
> > '==' checks equality... '=' assigns a value...
> > 
> > I would recommend a good read of the AFL user guide... then all 
this
> > will be obvious.
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "bigitop" <doctormuniz@> wrote:
> > >
> > > thanks for bearing with me. ok i'm making some progress but 
still got
> > > new setbacks.
> > > 
> > > variableX = variableY / abs(variableZ);
> > > result = IIf (variableX > .5, 1, 0);
> > > 
> > > if(result = 1){
> > > Filter = Open > 40 & Open < 60;
> > > }
> > > 
> > > the problem now is that "result" is evaluating to true (1) even 
when
> > > "variableX" is in reality less < .5
> > > 
> > > therefore i'm getting all tickers in the 40-60 Open range. I 
only want
> > > to get the tickers where "variableX" is more > .5
> > > 
> > > does it make sense?
> > > 
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, Andrew Senft <senft@> wrote:
> > > >
> > > > Use IIF for arrays
> > > > 
> > > > bigitop wrote:
> > > > >
> > > > >
> > > > > thanks!! Ref() worked perfectly.
> > > > >
> > > > > can you please help me with one more thing
> > > > >
> > > > > i have a variable:
> > > > >
> > > > > variableX = variableY / abs(variableZ);
> > > > >
> > > > > i'm trying to use inside an if statement like this:
> > > > >
> > > > > if (variableX > .5)
> > > > >
> > > > > but it gives me the following error:
> > > > >
> > > > > "Condition in IF, WHILE, FOR statements has to be numeric or
> boolean
> > > > > type. You cannot use an array here, please use [] (array 
subscript
> > > > > operator) to access array elements"
> > > > >
> > > > > i tried referencing it as variableX[0] but it doesnt work. 
how
> do i
> > > > > know what's inside an array so that i can refer to it??
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx
> > > <mailto:amibroker%40yahoogroups.com>, 
> > > > > "sidhartha70" <sidhartha70@> wrote:
> > > > > >
> > > > > > Use the Ref() function...
> > > > > >
> > > > > > --- In amibroker@xxxxxxxxxxxxxxx 
> > > > > <mailto:amibroker%40yahoogroups.com>, "bigitop" 
<doctormuniz@>
> > wrote:
> > > > > > >
> > > > > > >
> > > > > > > hi, im learning AFL and need some basic help.
> > > > > > >
> > > > > > > while i'm running a script how can i reference previous
> bars and
> > > > > > > forward bars?
> > > > > > >
> > > > > > > in other words, how do i get OCHLV info from a bar(s) 
that are
> > > back in
> > > > > > > time and forward in time from the current array for the 
same
> > > symbol?
> > > > > > >
> > > > > > > I guess it would be something like: TimeFrameSet( 
currentBar
> > - 1 )
> > > > > > >
> > > > > > > is this possible with AB?
> > > > > > >
> > > > > >
> > > > >
> > > > > 
> > > > >
> > >
> --------------------------------------------------------------------
----
> > > > >
> > > > >
> > > > > No virus found in this incoming message.
> > > > > Checked by AVG - http://www.avg.com 
> > > > > Version: 8.0.176 / Virus Database: 270.11.3/1967 - Release 
Date:
> > > 2/23/2009 7:17 AM
> > > > >
> > > > >
> > > >
> > >
> >
>




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

**** 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:
    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/