/*====================================================================== Backtest Settings ======================================================================*/ initialEquity = 1000000; commission = 0.15; SystemName = "SQMinerviniTrendTemplate"; SetOption( "InitialEquity", initialEquity ); SetOption( "CommissionMode", 1); SetOption( "CommissionAmount", commission); SetOption( "MaxOpenPositions", 10000 ); SetOption( "PriceBoundChecking" , FALSE ); SetOption( "Minshares", 100 ); RoundLotSize = 100; Prd_1Y = 200; { // Calculate Ranking wlName = "List 0"; catNum = CategoryFind( wlName, categoryWatchlist ); list = CategoryGetSymbols( categoryWatchlist, catNum ); if ( Status("stocknum") == 0 ) { SQStaticVarRemove(); for ( n = 0; ( Symbol = StrExtract( list, n ) ) != ""; n++ ) { if ( Symbol != "0SET" ) { array = Foreign( Symbol, "C", fixup = 0 ); SQStaticVarROCSet( array, symbol, Prd_1Y ); } } SQStaticVarGenerateRanks(list, 1234); } } //*** Trend up ****// IsMinerviniTrendTemplate = SQMinerviniTrendTemplate(50, 150, 200); BreakHighEntry = Cross( H, Ref( HHV( H, 200), -1) ); RSRankBuy = SQStaticVarGetRankScorePercentile() > 80; // *** Growth ***// // Define Growth and PEG IsAnn_Roll_equal = IIf((SQEPS_ROLL() == SQEPS_ANN()),1,0); Growth = IIf (IsAnn_Roll_equal != 1, ( (SQEPS_ROLL() / SQEPS_ANN() ) -1)*100 , SQCAGR( SQEPS_ANN(), 1, True ) ); PEG = IIf (IsAnn_Roll_equal !=1 , Nz(SQPE()/Growth) , SQPEG(1)); G_filter_GrowthEPS = Growth > 25;// OR SQEPSAdjust_YoY() >15; G_filter_GrowthPEG = PEG >0 AND PEG <=3; G_filter = G_filter_GrowthEPS AND G_filter_GrowthPEG ; V_Filter = Ref(SQROE(),-1) >=10; CheckTrade_Volume = EMA(SQVALUE(), 10) > 2000000; SQFilter = CheckTrade_Volume AND SQIsStock() AND SQDataFilter(0) AND NOT InWatchListName("BADDATASTOCK"); /*====================================================================== Trigger : Signals ======================================================================*/ Buy = IsMinerviniTrendTemplate AND BreakHighEntry AND RSRankBuy AND SQFilter AND G_filter AND V_filter; //AND SETBull; Sell = Cross( EMA( C, 100 ), C ); Short = Cover = 0; Buy = ExRem( Buy, Sell ); Sell = ExRem( Sell, Buy ); /*====================================================================== Position Score ======================================================================*/ PositionScore = SQStaticVarGetRankScorePercentile(); /*====================================================================== Order Execution ======================================================================*/ settradedelays(1, 1, 1, 1); BuyPrice = SQBuySlippagePercent( Open, 1, False ); SellPrice = SQSellSlippagePercent( Open, 1, False); /*====================================================================== Position Size ======================================================================*/ posSize = 7; SetPositionSize( posSize, spsPercentOfEquity ); {//stoploss ApplyStop(stopTypeLoss,stopModePercent,8); //ApplyStop(stopTypeProfit,stopModePercent,16); //ApplyStop(stopTypeTrailing,stopModePercent,10); }