Hi Barry -- The loop is the correct solution.
This statement: Buy = IIf(ifDate(SelectedValue(DateNum())), 1, 0); Returned either 0 or 1 -- a scalar -- which was then assigned to the entire Buy array. Thanks, Howard www.quantitativetradingsystems.com On Jan 7, 2008 8:28 AM, Barry Scarborough <[EMAIL PROTECTED]> wrote: > 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@yahoogroups.com <amibroker%40yahoogroups.com>, "Barry > Scarborough" <[EMAIL PROTECTED]> > > 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; > > > > >