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;