I have a very simple set of rules where I go long (and cover if short) above
the high of the previous bar and I go short (and sell if long) below the low of
the previous bar. The problem is when I have a outside bar, I need to take two
trades inside of one bar. So far I have not found anyway inside AB AFL that
will allow me to do this. Is it possible?
Buy = Sell = Short = Cover = 0;
MP = 0;
for (i=1; i < BarCount; i++)
{
SetBacktestMode(backtestregularraw);
if ( BarType[i] < 3 ) // Normal bar or outside bar with down close
{
if ( BuySignal[i] )
{
if (MP == -1) { Cover[i] = 1; } else Cover[i] = 0;
Buy[i] = True;
MP = 1;
}
if ( SellSignal[i] )
{
if (MP == 1) { Sell[i] = 1; } else Sell[i] = 0;
Short[i] = True;
MP = -1;
}
}
else if (BarType[i] == 3) // Outside up bar
{
if ( SellSignal[i] )
{
if (MP == 1) { Sell[i] = 1; } else Sell[i] = 0;
Short[i] = True;
MP = -1;
}
if ( BuySignal[i] )
{
if (MP == -1) { Cover[i] = 1; } else Cover[i] = 0;
Buy[i] = True;
MP = 1;
}
}
}