Rotational system does not work with multiple conditions in Score

G'day All,

I am a new user of Amibroker and really love the tool.

I am trying to code a simple rotational backtest system but when I add additional conditions to my Positionscore, the backtest does not generate any signals. Removing the condition works fine.

As Soon as I add "AND NorgateIndexConstituentTimeSeries("$XFL.au")" to my Buysignal line, the backtest stop generating any trades. I did do data exploration and with or without the line above, the code is generating buy signals.

Here is my code:

//Norgate Settings
#include_once "Formulas\Norgate Data\Norgate Data Functions.afl";

#include <Myfunctions.afl>; //<<<Custom Functions>>>

OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() == (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() >= (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") );


//############ NORMAL BACKTEST CODE ############

Positions = 5;
SetOption ("MaxOpenPositions",Positions);
SetPositionSize (100/Positions, spsPercentOfEquity);
//SetOption("WorstRankHeld",5);
SetBacktestMode( backtestRotational );

Market = Foreign ("$XFL.au","Close");
MarketMA = MA(Market,150);
RegimeFilter = Market > MarketMA;

//DiffMnth = Month() != Ref(Month(),-1); OR Below - This function needs to look forward where below doesn't.
Lastday = LastTradeDayOfMonth(); // <<<From Custom Functions>>>

Buysig = /*DiffMnth*/ Lastday AND NorgateIndexConstituentTimeSeries("$XFL.au"); // AND (NorgatePaddingStatusTimeSeries()==0) ;//AND NOT OnLastTwoBarsOfDelistedSecurity AND NorgateIndexConstituentTimeSeries("$XFL");
Sellsig = 1;

Score = IIf(Buysig,10000+ROC(C,21),scoreNoRotate);
PositionScore = IIf(RegimeFilter , Score, scoreNoRotate);


//EXPLORATION
Filter=1;
AddColumn(Score, "Roc(C,1)", 1.2);
AddColumn(PositionScore, "P.Score", 1.2);
AddColumn (NorgateIndexConstituentTimeSeries("$XFL.au"),"In Norgate Index",1.2);
AddColumn(Buysig, "Buy Signal", 1.2);
AddColumn (Lastday,"Lastday",1.2);

Here is my exploration results with both backtests:
image

Please advise if I am doing something obvious wrong. I am a Newbie so please forgive my ignorance

You might consider running backtest in "Detailed log" report mode. To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.