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

Re: [amibroker] syntax error help



PureBytes Links

Trading Reference Links

Hmmm, well I tried:

vSARUp = Ref(SAR(0.02,0.2),-1) >= Ref(High,-1) AND SAR(0.02,0.2) < Low 
AND closeAll;
if (vSARUp[0])

and this didn't get any errors. I've no idea why, since vSARUp still 
contains this mix of arrays and numeric values. Doesn't seem right to me.

Martin

Martin Cooney wrote:
> Yep, I certainly got the error and looked at the Help file which you 
> also included below. I have no doubt it's my fault in mixing arrays and 
> numeric values.
> 
> All I know is I've got these 3 conditions that if True, I want to do 
> this other stuff. No barcount 'for' loop stuff - maybe down the track 
> once I work out what I need it for :)
> 
> Again, apologies for not understanding stuff that you guys take for 
> granted. Despite Graham's wonderful reply, I still am uncertain what to do.
> 
> Martin
> 
> Joe Landry wrote:
>> First thing I can spot is you're mixing arrays and single 
>> expresssion/numeric values.  Usually syntax checker or precompiler spots 
>> that right off with an Error 6.  If you want to prove it to
>>
>> yourself insert the following code in AutoAnalysis, select a single 
>> ticker, set number of bars for 20 or some and you'll see that both A and 
>> B are arrays with B being the previous bars SAR. Note that C is an array 
>> also of true and false.when the conditions are met. This is a slow and 
>> brute force way of putting an expression together but hope this helps 
>> when you see what's happening.
>>
>> A = SAR(0.02,0.2);
>>
>> B  = Ref(A,-1);
>>
>> * *
>>
>> *C* = B >= Ref(*High*,-1);
>>
>> * *
>>
>> *Filter* =1;
>>
>> AddColumn(a,"A");
>>
>> AddColumn(b,"B");
>>
>> AddColumn(*C*,"C");
>>
>> The < if  > statements are for single numeric elements/expressions and 
>> for arrays you need to use IIF.
>>
>> JOE
>>
>>  
>>
>>
>>     *Common Coding mistakes in AFL*
>>
>> This document presents most common mistakes and problems that users 
>> encounter when writing their custom formulas. Please read carefully to 
>> avoid making similar error
>>
>> *-----------------------------------------------------------------------------------------------------------------------*
>>
>> *if-else statement needs boolean (or single numeric expression), not array*
>>
>> The *if* keyword executes /statement1/ if /expression/ is true 
>> (nonzero); if *else* is present and /expression/ is false (zero), it 
>> executes /statement2/. After executing /statement1/ or /statement2/, 
>> control passes to the next statement. E/xpression /must be boolean ( 
>> True/False) type (so it CANNOT be ARRAY because there would be no way do 
>> decide whether to execute /statement1/ or not, if for example array was: 
>> [True,True,False,.....,False,True] )
>>
>> *if*( expression )
>>    statement1
>> *else*
>>    statement2
>>
>> *EXAMPLE*
>>
>> |*if*( *Close* > *Open* ) // WRONG
>>    Color = *colorGreen*; //statement 1
>> *else*
>>    Color = *colorRed*; //statement 2
>>
>> Plot(*Close*,"Colored Price",Color,*styleCandle*);|
>>
>>  
>>
>>     ----- Original Message -----
>>     *From:* Martin Cooney <mailto:martin@xxxxxxxxxxxxx>
>>     *To:* Amibroker General Forum <mailto:amibroker@xxxxxxxxxxxxxxx>
>>     *Sent:* Thursday, March 02, 2006 8:10 PM
>>     *Subject:* [amibroker] syntax error help
>>
>>     Hi Guys,
>>
>>     Sorry to do this so often but I'm having trouble working out the best
>>     way to do some Metatrader code conversion into AB and I'm getting a
>>     syntax error that my present coding level is having problems in working
>>     around.
>>
>>     MT4 Code:
>>
>>         if (iSAR(NULL,0,0.02,0.2,1) >= High[1] &&
>>             iSAR(NULL,0,0.02,0.2,0) < Low[0] &&
>>             closeAll)
>>
>>     SAR of previous bar equal or greater than High of previous AND SAR of
>>     current bar is less than Low of current bar and the Boolean variable
>>     closeAll is True. Essentially, Sar was above and now below.
>>
>>     My Conversion to AB:
>>
>>         if (Ref(SAR(0.02,0.2),-1) >= Ref(High,-1) &&
>>             SAR(0.02,0.2) < Low &&
>>             closeAll)
>>
>>     This gives me an Error 6. Condition in IF, WHILE, FOR statements has to
>>     be Numeric or Boolean type. You can not use array here, please use []
>>     (array subscript operator) to access array elements.
>>
>>     I know it's something stupid that I've not yet experienced and stored
>>     away yet so any help would be appreciated (as always).
>>     Martin
>>
>>
>>     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 other support material please check also:
>>     http://www.amibroker.com/support.html
>>
>>
>>
>>
>>
>>     SPONSORED LINKS
>>     Investment management software
>>     <http://groups.yahoo.com/gads?t=ms&k=Investment+management+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=_XXUzbE9l5lGlZNcMu4KNQ>
>>     	Real estate investment software
>>     <http://groups.yahoo.com/gads?t=ms&k=Real+estate+investment+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=5_sgDczz3ArKGMtJ9tFSJA>
>>     	Investment property software
>>     <http://groups.yahoo.com/gads?t=ms&k=Investment+property+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=_N6zcwefgp4eg5n6oX5WZw>
>>
>>     Software support
>>     <http://groups.yahoo.com/gads?t=ms&k=Software+support&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=MJ2jP31F3n64RDZkDadU8w>
>>     	Real estate investment analysis software
>>     <http://groups.yahoo.com/gads?t=ms&k=Real+estate+investment+analysis+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=GmF8PlAJASx0wrSaX5-Zlw>
>>     	Investment software
>>     <http://groups.yahoo.com/gads?t=ms&k=Investment+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=aMgGsKT4w29dMAYUzQUKzg>
>>
>>
>>
>>     ------------------------------------------------------------------------
>>     YAHOO! GROUPS LINKS
>>
>>         *  Visit your group "amibroker
>>           <http://groups.yahoo.com/group/amibroker>" on the web.
>>            
>>         *  To unsubscribe from this group, send an email to:
>>            amibroker-unsubscribe@xxxxxxxxxxxxxxx
>>           <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
>>            
>>         *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>>           Service <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 other support material please check also:
> http://www.amibroker.com/support.html
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 
> 


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

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