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

[amibroker] Working with DateNum and If Statement



PureBytes Links

Trading Reference Links

I am making a lot of progress on some custom studies and indicators
but I have run into a road block and am hoping someone here can point
me in the right direction.

Although the help file states that there are 6 arrays for each symbol,
isn't there a 7th?  That being the date?  One array each for Date,
High, Low, Open, Close, Volume, and OI?

Or is the date a part of each array as in (Date, High) ... (Date, Close)?

If I can learn how figure out how to code a simple little indicator it
will allow me to move forward.

All I would like to do is create an indicator that assigns 4 to a
variable called x if the date of the bar is before the year 2008.
After that date I want the value to be zero. 

This is the code I created:

if (DateNum() < 1080101)
	x = 4;
else 
	x = 0;

>From the error message I get it sounds like I have to use a script to
cycle through each bar.

That means I have to use some looping code and therefore tried this:

for( i = 1; i < BarCount; i++ )
{
DN = DateNum();
if (DN[i] < 1080101)
	x = 4;
else 
	x = 0;
}

Plot( X, "X", ParamColor("Color", colorBlack ), styleLine );

All it plots is a zero across all dates.

I have tried a lot of other combinations as well.  Please help as I
have lost enough of my hairline for one night, lol.

Regards,
MM







------------------------------------

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 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
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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