I can't get any results in backtesting and exploration

I am trying to do a Best of Best strategy back test and exploration such that it will scan the sectors located in the watchlist 'BOB', then it will choose the top 3 (criteria is 'GainAv' inside the code) sectors inside and then use the same criteria to choose the top stock to buy in the 3 sectors identified. i am not able to do the second ranking to dive into the stocks yet though.

My code is below, i tried to do backtesting and exploration but both came up 'no results'.

this is the 1st time something like that happened and there are no errors in my code.

can anyone point out where i went wrong?

SetOption("InitialEquity", 10000);
SetOption("MaxOpenPositions", 3); //33% equity a trade
SetTradeDelays(1,1,1,1); // Buy/Sell at next bar after signal (Perform scan on Friday's date, after mkt close)
SetPositionSize(33.33, spsPercentOfEquity ); //set 33% as max equity for each position. so total can have 4 concurrent positions

Buy = 0;
Sell = 0;


//Gains over the last 5 days
Gain=(C-O)/O;
Gain1=Ref(Gain,-1);
Gain2=Ref(Gain,-2);
Gain3=Ref(Gain,-3);
Gain4=Ref(Gain,-4);
Gain5=Ref(Gain,-5);

//Assign 1 point for each day where Gain>0 (Positive Gain)
G1=Gain1>0;
G2=Gain2>0;
G3=Gain3>0;
G4=Gain4>0;
G5=Gain5>0;

//Identify GapDowns in last 4 days. Assign 1 point for each day where there is GapDown
aGapDn = ( H < Ref(L, -1) ); 
aGapDn1 = Ref(aGapDn, -1); 
aGapDn2 = Ref(aGapDn1, -2); 
aGapDn3 = Ref(aGapDn1, -3);  
aGapDn4 = Ref(aGapDn1, -4); 

//Identify GapUps in last 4 days. Assign 1 point for each day where there is GapUp
aGapUp = ( L > Ref(H, -1) );
aGapUp1 = Ref(aGapUp,-1);
aGapUp2 = Ref(aGapUp1,-2);
aGapUp3 = Ref(aGapUp1,-3);
aGapUp4 = Ref(aGapUp1,-4);

//Criterias
GainT=Gain1+Gain2+Gain3+Gain4+Gain5; // Total gain over last 5 days 
GainAv=0.2*GainT; // Average gain over last 5 days [Must be Positive]
GainScore=G1+G2+G3+G4+G5; // Total score (0 to 5) [Must be at least 3]
GapDnScore=aGapDn1+aGapDn2+aGapDn3+aGapDn4; // Total GapDown days [To be 0]
GapUpScore=aGapUp1+aGapUp2+aGapUp3+aGapUp4; // Total GapUp days [Not using for now]


//Ranking of ETFs in BOB Watchlist (Watchlist set manually in filter list)
wlnumber  = GetOption( "FilterIncludeWatchlist" );
watchlist = GetCategorySymbols( categoryWatchlist, wlnumber );
category = categoryWatchlist;

Tickerlist = CategoryGetSymbols( category, wlnumber );

if( Status( "stocknum" ) == 0 ) // generate ranking when on first symbol
{
    StaticVarRemove( "values*" );

    for( n = 0; ( Symbol = StrExtract( Tickerlist, n ) )  != "";  n++ )
    {
        SetForeign( symbol );
        values = GainAv;//ranking criteria
        RestorePriceArrays();
        StaticVarSet( "values"  +  symbol, values );
    }

    StaticVarGenerateRanks( "top", "values", 3, 1224 );
}

symbol = Name();

values = StaticVarGet( "values" +  symbol);
rank = StaticVarGet( "rankvalues" +  symbol );
StaticVarGet( "Rankvalues" + Name() );

Filter = GainAv;


//Exploration
//1st 2 columns are ticker and date.
AddColumn( rank, "Rank", 1.0, colorDefault, colorDefault ); //3rd column, 0 decimal places
AddColumn(Ref(GainAv,-1), "GainAv", 1.4 );//4th column, 4 decimal places
SetSortColumns( -4 ); //sort 4th column in descending order
AddColumn(Ref(GainScore,-1), "GainScore", 1.0);//5th column, 0 decimal places
//AddColumn(TopGainAv, "Ranked1", 1.0);

Buy = GainAv>0 AND GainScore>2 AND GapDnScore<1;
//Trail stop by %
Sell = 0 ; // DO NOT exit normally

// APPLY STOP DURING BACKTESTING !  
ApplyStop(stopTypeTrailing, stopModePercent, 15, True, True );

PositionScore = GainAv;

BuyPrice=Open; // buy at mkt open
SellPrice=Open;

Try debugging

`Filter = 1;
AddColumn(GainAv.....

still the same, both backtest and exploration still no results :frowning:

As part of debugging, @awilson said to try 'Filter = 1' yet you put 'Filter = GainAv'!

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