I'm new to Amibroker and am trying to use it to backtest signals that
come from an external program that get written to a CSV file.

I'm able to use AFL to read the CSV file and create variable for each
of the signals (using the symbol and the date and time of the entry).
 I'm also able to loop through the bars and compare current symbol and
timestamp to see if it is a bar where an entry should occur.

My AFL works fine in identifying the bars (executing the code in the
IF block in the code below).  However, the Buy and Sell variables
aren't working as I
thought they would.  I'm getting far more entries in the backtest
results than I should be.

My question is: What should I be using for the Buy and Sell variables
to initiate a buy for the current bar when it's identified an alert
(but not otherwise)?

for (i = 0; i < BarCount; i++) {
    Variable = Name() + DateTimeToStr(dt[i]);
    alert_now = VarGetText(Variable);
    if (alert_now != "") {
        // We've found an alert - try to generate a buy here.
        _TRACE("Found alert: " + Name() + " " + Variable);
        EOD = 0;
        EOD = IIf((Hour() == 15 AND Minute() == 59),1,0);
        Buy = 1;
        Sell = EOD;
        ApplyStop(1,1,1,1);
    }
}

Thanks and happy 2008.

Reply via email to