When everything fails - check the manual: http://www.amibroker.com/f?isnull
Best regards, Tomasz Janeczko amibroker.com ----- Original Message ----- From: wml67 To: [email protected] 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!
