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

[amibroker] Re: Coding assistance please



PureBytes Links

Trading Reference Links

I found a way. I added a for loop around the buy and that works. I 
don't understand why I had to do that. 

aDate = DateNum();
for (a=0; a < BarCount; a++)
{
    Buy[a] = ifDate(aDate[a]);
}

--- In amibroker@xxxxxxxxxxxxxxx, "Barry Scarborough" <razzbarry@xxx> 
wrote:
>
> I am trying to create a file that will show trades on dates from an 
> input file. The program almost works but the entire array either 
has 
> 0 or 1. Scan does not output anything. It appears that Buy is an 
> integer rather then an array. What I mean is when I plot Buy it is 
a 
> flat line, 1 if the condition is true, 0 if not when I move the 
> cursor over the buy dates. I expected to see spikes where buy is 
true 
> and 0 if not. What is wrong?
> 
> Thanks in advance,
> Barry
> 
> // Plot dates for Druster signals
> 
> function ifDate(num)
> {
> 	Cond = 0;
> 	fh = fopen( "C:\\Program 
> Files\\AmiBroker\\TradeDates\\DrusterBuyDates.csv", "r"); 
> 	if( fh ) 
> 	{ 
> 		while( ! feof( fh ) AND Cond == 0) 
> 		{ 
>   			data = fgets( fh );  
> 			mm = StrToNum(StrLeft(data ,2));
> 			dd = StrToNum(StrMid(data ,3,2));
> 			yy = StrToNum(StrRight(data ,2));
> 			if (yy < 20)
> 				yy = 2000 + yy;
> 			else
> 				yy = 1900 + yy;
>   			dNum = (10000 * (yy - 1900)) + (100 * mm) + 
> dd;
> 			if(dNum == num)
> 				Cond = 1;
> 		}  
> 		fclose( fh );
> 	} 
> 	else 
> 	{ 
> 		printf("Error opening read file");
> 	}
> 	return Cond;
> }
> 
> //Buy = ifDate(SelectedValue(DateNum())); 
> // NOTE the above and following line produce the same results.
> 
> Buy = IIf(ifDate(SelectedValue(DateNum())), 1, 0);
> Plot(Buy, "Buy", colorGreen);
> Plot(DateNum(), "DateNum", colorRed, styleOwnScale | styleNoLine | 
> styleNoLabel);
> Filter = Buy;
>




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/