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

Re: [amibroker] detecting un-initialized, or {EMPTY}, array element



PureBytes Links

Trading Reference Links



When everything fails - check the manual:
 
 
 
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: wml67
Sent: Saturday, September 12, 2009 2:06 PM
Subject: [amibroker] detecting un-initialized, or {EMPTY}, array element

Say, I have a strategy based on more than one securities and indicators with different lookbacks.

BuySignal = fn(Price1, Price2, MA, STDEV, etc);

In order to calculate annualized profit in my backtests (and for other purposes), I want to find the date of the first bar when the system actually have enough data to provide signals. This date will depend on the the start of the backtest range, presence of data in the database, some securities may have started to trade only recently, lookback periods etc etc.

My idea was to loop through BuySignal and see when it ceases to be {EMPTY}. I tried checking if BuySignal != Null and some other stupid things,  but none worked. I ended up doing this (full snippet below):

dt=DateTime();
for( i = 0; i < BarCount; i++ )
  {

    
if( WriteVal(BuySignal[i]) != "{EMPTY}" )
     {
      bo.addCustomMetric(
"Start date", WriteVal(dt[i],formatDateTime));
      
break;
     }
  }


Now, there ought to be a more direct and efficient way to check if the array element is initialized, not involving formatting. Anyone?

Also, maybe there's some built-in functionality to find what I need without looping?

Cheers!



__._,_.___


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





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

__,_._,___