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

[amibroker] Re: Working with DateNum and If Statement



PureBytes Links

Trading Reference Links

Thanks Graham and Ed.  I can now cancel my order for Rogaine!

MM

--- In amibroker@xxxxxxxxxxxxxxx, "Edward Pottasch" <empottasch@xxx>
wrote:
>
> > 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. 
> 
> hi,
> 
> you could just use iif for that:
> 
> x = IIf(DateNum() < 1080101,4,0); 
> WriteVal(x); 
> 
> if you choose to use a loop it would look like: 
> 
> x = 0; 
> DN = DateNum(); 
> for( i = 0; i < BarCount; i++ ) 
> { 
> if (DN[ i ] < 1080101) 
>    x[ i ] = 4; 
> else 
>    x[ i ] = 0; 
> } 
> WriteVal(x); 
> 
> rgds, Ed
> 
> 
> 
>   ----- Original Message ----- 
>   From: marketmonk777 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Tuesday, June 03, 2008 7:19 AM
>   Subject: [amibroker] Working with DateNum and If Statement
> 
> 
>   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/