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

Re: [amibroker] Re: Coding assistance please



PureBytes Links

Trading Reference Links

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 <razzbarry@xxxxxxxxxxxx> 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@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 = "" 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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___