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

[amibroker] Compacting IF statements and variable assignments



PureBytes Links

Trading Reference Links

Hello, hoping someone can give their two sense on this. As part of my system I assign variables to dozens of different conditions, then optimize on past data to find likely best conditions. I then buy on the best conditions for forward-testing.

The question I have is one of efficiency. In the code snippet below, I manually write out 100 conditions, then write 100 IF statements to assign those conditions to 100 variables.

Is there a more compact way to achieve this, without having to manually write out the 100 separate IF statements? Maybe some kind of nested function?

A            = Optimize("A",    0,      0,     100,     1);


Tier0        = Rank <
0;
Tier1        = Rank >=
0  AND Rank < 60;
Tier2        = Rank >=
30 AND Rank < 60;
Tier3        = Rank >=
60 AND Rank < 90;
Tier4        = Rank >=
90 AND Rank < 100;
.
.  etc....
.
Tier100     = ...

if(A == 0)  Tier = Tier0;
if(A == 1)  Tier = Tier1;
if(A == 2)  Tier = Tier2;
if(A == 3)  Tier = Tier3;
if(A == 4)  Tier = Tier4;
.
. etc...
.
if(A == 100)  Tier = Tier100;


Buy = Tier;

__._,_.___

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

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

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

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___