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

Re: [amibroker] Re: Changing RoundLotSize on the fly



PureBytes Links

Trading Reference Links

Hello,

IIF is NOT a conditional statement. It is a FUNCTION that returns
values, therefore assignments inside argument part are wrong.

See it is listed in "Most common AFL mistakes" part of User's Guide 
http://www.amibroker.com/guide/a_mistakes.html

Instead one should write:

rls = IIF( e < 10000, 100,
        IIF( e < 100000, 500,
        IIF( e < 1000000, 1000,
        IIF( e < 10000000, 5000,
                                    10000 /* otherwise */
            ) ) ) );

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Fred" <ftonetti@xxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Thursday, September 01, 2005 3:52 AM
Subject: [amibroker] Re: Changing RoundLotSize on the fly


> As I said ... the statement structure would need to be changed ...
> 
> IIF(a is true, then do x, else do y) i.e.
> 
> iif(e > 1000, rls=w, iif(e > 100, rls=x, iif(e > 10, rls=y, rls=z)));
> 
> etc ... as deep as you need to go ... with whatever values you want.
> 
> --- In amibroker@xxxxxxxxxxxxxxx, eric paradis 
> <thechemistrybetweenus@xxxx> wrote:
>> Fred, if I do this I still get a syntax error. 
>> 
>>  e =Equity(1);
>> IIf( e<10000) RoundLotSize=100;
>> IIf( e>=10000 AND e<100000) RoundLotSize=500 ;
>> IIf( e>=100000 AND e<1000000) RoundLotSize=1000 ;
>> IIf( e>=1000000 AND e<10000000) RoundLotSize=10000 ;
>> IIf( e>=10000000 AND e<100000000) RoundLotSize=50000 ;
>> IIf( e>=100000000) RoundLotSize=100000;
>> 
>> I also tried to attempt a typecast, separately on a
>> different backtest with no luck.
>> 
>>  //e= 0;
>>   //e[0]=0;
>>   //e[0] = Equity(1);
>>   
>> no luck here, as it says its not possible to have an
>> element on the rightside of the array. 
>> 
>> --- Fred <ftonetti@xxxx> wrote:
>> 
>> > IIF ... but you'll have to change the statement
>> > structure.
>> > 
>> > --- In amibroker@xxxxxxxxxxxxxxx, eric paradis 
>> > <thechemistrybetweenus@xxxx> wrote:
>> > > Graham thanks. I get an error message for all the
>> > > lines of code saying:
>> > > 
>> > > Error 6. Condition in IF, WHILE, FOR statements
>> > has to
>> > > be numeric or boolean type. You can not use an
>> > array
>> > > here. Please use [ ] ( array subscript operator)
>> > to
>> > > access array. 
>> > > 
>> > > Any ideas on how to solve this?
>> > > 
>> > > Thanks
>> > > 
>> > > 
>> > > 
>> > > --- Graham <kavemanperth@xxxx> wrote:
>> > > 
>> > > > try using some If statements
>> > > > something like this for starters, don't know off
>> > > > hand if a for loop
>> > > > would be required
>> > > > e=equity(1);
>> > > > if( e<100000) roundlotsize=100;
>> > > > if( e>=100000 and e<1000000) roundlotsize=1000 ;
>> > > > if( e>=1000000) roundlotsize=10000;
>> > > > 
>> > > > On 9/1/05, eric paradis
>> > > > <thechemistrybetweenus@xxxx> wrote:
>> > > > > Hi,
>> > > > > 
>> > > > > Can anyone suggest how to code a rule for
>> > setting
>> > > > > RoundLotSize so that when the Equity reachs
>> > 100k,
>> > > > > RoundLotSize gets set to 1000 shares, when
>> > 1mil,
>> > > > > RoundLotSize get set to 10000 shares, and so
>> > on.
>> > > > > 
>> > > > > Much appreciated.
>> > > > > 
>> > > > > Eric
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > >
>> > > >
>> > ____________________________________________________
>> > > > > Start your day with Yahoo! - make it your home
>> > > > page
>> > > > > http://www.yahoo.com/r/hs
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > > 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
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > > 
>> > > > 
>> > > > 
>> > > > -- 
>> > > > Cheers
>> > > > Graham
>> > > > AB-Write >< Professional AFL Writing Service
>> > > > Yes, I write AFL code to your requirements
>> > > > http://e-wire.net.au/~eb_kavan/ab_write.htm
>> > > > 
>> > > 
>> > > 
>> > > __________________________________________________
>> > > Do You Yahoo!?
>> > > Tired of spam?  Yahoo! Mail has the best spam
>> > protection around 
>> > > http://mail.yahoo.com
>> > 
>> > 
>> > 
>> 
>> 
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection around 
>> http://mail.yahoo.com
> 
> 
> 
> 
> 
> 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 --------------------~--> 
Help Sudanese refugees rebuild their lives through GlobalGiving.
http://us.click.yahoo.com/hjNroD/EbOLAA/cosFAA/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/