Backtester Driving me nuts :)

#1
Hi,

Need help from people experienced in AFL.

I am trying to get the date at which the buy signal was generated in a variable. I need this variable to be part of the decision in the sell signal.

So let us say GoldenCross is an array which gets generated whenever there is a crossing of certain oscillators and moving averages cross each other.

GoldenCross = <conditions>

/* Get date of GoldenCross */

if(SelectedValue(GoldenCross) == 1)
{
bi = BarIndex();
arrayitem = SelectedValue(GoldenCross) - bi[ 0 ];
d = DateTime() ;
_TRACE("#Ticker " + Name() + " Golden Cross " + GoldenCross + " Phase " + Phase + " Date : " + DateTimeToStr(d[arrayitem]));
}


Unfortunately not only does this not show the correct date, the backtester ticker results printed are entirely different from the ones indicated by GoldenCross. For example, Ticker ACC shows up in backtester for buy and sell. But Ticker ACC does not show up in the TRACE above.

Help!!!
 
#2
The only one who is driving you nuts is you, my dear.
This is an example of a simple exploration code.
Code:
EMA15  = EMA(C,15);
EMA50  = EMA(C,50);
gcBuy  = Cross(EMA15, EMA50);
gcSell = Cross(EMA50, EMA15);
dt     = DateTime();
dtbuy  = IIf(gcBuy, dt, Null);
dtsell = IIf(gcSell, dt, Null);
Filter = gcBuy||gcSell;
SetOption("nodefaultcolumns", True);
AddTextColumn(Name(),"Symbol",1);
AddColumn(gcbuy,"buy", 1);
AddColumn(gcsell,"sell", 1);
AddColumn(dtbuy,"dtbuy",formatDateTime, colorDefault, colorDefault, 120);
AddColumn(dtsell,"dtsell",formatDateTime, colorDefault, colorDefault, 120);
 
Last edited:

Similar threads