SetOption("UseCustomBacktestProc", True ); IncludeTopN = 1; // how many top positions to exclude if( Status("action") == actionPortfolio ) { // retrieve the interface to portfolio backtester bo = GetBacktesterObject(); bo.PreProcess(); for( bar = 0; bar < BarCount; bar++ ) { Cnt = 0; // this for loop iterates through all trade signals and adjust pos size for( sig = bo.GetFirstSignal( bar ); sig; sig = bo.GetNextSignal( bar ) ) { if( Cnt >= IncludeTopN ) sig.Price = -1; // setting price to -1 excludes given signal from entry if( IsNull( bo.FindOpenPos(sig.Symbol) ) ) Cnt++; } bo.ProcessTradeSignals( bar ); } bo.PostProcess(); } SetBacktestMode( backtestRegularRaw ); SetOption("MaxOpenPositions", 240 ); SetOption( "InitialEquity", 240000); volumefilter = v>100000 AND O>1; delisting = GetFnData("DelistingDate"); Cond = IIf( IsNull(delisting), 1, DateTime() < delisting); m = Month(); Buy = m != Ref(m,-1) AND cond AND volumefilter; exitLastBar = datetime() >= GetFnData("DelistingDate"); bi = BarIndex(); lastBar = bi == LastValue( bi ); Sell = exitlastbar OR lastbar; fixeddollaramount = 1000; PositionSize = fixeddollaramount; PositionScore= 1/RSI(14);