StrategyQuant
Q AI AssistantAlgoCloudQuantAnalyzerQuantDataManager
Free CourseCompany
BlogDocumentationForumContact us
BlogMarketplace
Log in
Create free account

Product

  • Pricing & licenses
  • Learn
  • Marketplace
  • Start free trial

Legal

  • Terms of Service
  • Privacy Policy
  • Cookies

Contact

[email protected]

Company

StrategyQuant s.r.o.

Korunní 2569/108, Vinohrady, 101 00 Praha 10, Czech Republic, EU

IČ: 04000498

DIČ: CZ04000498

Social

  • Legal Notice | PROCESSING AND PROTECTION OF PERSONAL DATA

    Past performance is no guarantee of future success. All information should be viewed as educational only

    UNITED STATES Disclaimer required by Government - Commodity Futures Trading Commission informs: Futures and options trading have great potential rewards, but also great potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don't trade with money you can't afford to lose. This is neither a solicitation nor an offer to buy/sell futures, shares or options on the same. No representation is being made that any account will or is likely to realise profits or losses similar to those discussed in this document. The past performance of any trading system or methodology is not necessarily indicative of future results.

    CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE A RECORD OF ACTUAL PERFORMANCE, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES WERE NOT EXECUTED, THE RESULTS MAY HAVE OFFSET THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMMES IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO REALISE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN.

    NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL, OR IS LIKELY TO, REALISE PROFITS OR LOSSES SIMILAR TO THOSE DISCUSSED WITHIN THIS SITE. IF YOU DECIDE TO INVEST REAL MONEY, ALL TRADING DECISIONS IN THE FINANCIAL MARKETS SHOULD BE YOUR OWN.

    © StrategyQuant 2026

    Powered by Klaudie.ai

    Back to marketplaceDIGITAL

    Number of trades from WF Matrix

    StrategyQuantPlugins
    Number of trades from WF Matrix

    Databank column that calculates the number of trades across all Walk Forward Matrix result combinations, useful for analyzing trade frequency and strategy robustness across parameters.

    Note – there is an updated version for SQX Build 140 and above – see attached snippet.

    This Java snippet adds a new databank column functionality and allows you to calculate the number of trades of all combinations of a WF Matrix.

    /*
     * Copyright (c) 2017-2018, StrategyQuant - All rights reserved.
     *
     * Code in this file was made in a good faith that it is correct and does what it should.
     * If you found a bug in this code OR you have an improvement suggestion OR you want to include
     * your own code snippet into our standard library please contact us at:
     * https://roadmap.strategyquant.com
     *
     * This code can be used only within StrategyQuant products.
     * Every owner of valid (free, trial or commercial) license of any StrategyQuant product
     * is allowed to freely use, copy, modify or make derivative work of this code without limitations,
     * to be used in all StrategyQuant products and share his/her modifications or derivative work
     * with the StrategyQuant community.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
     * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
     * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES
     * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     *
     */
    package SQ.Columns.Databanks;
    import com.strategyquant.lib.L;
    import com.strategyquant.tradinglib.DatabankColumn;
    import com.strategyquant.tradinglib.ResultsGroup;
    import com.strategyquant.tradinglib.SettingsKeys;
    import com.strategyquant.tradinglib.ValueTypes;
    import com.strategyquant.tradinglib.WalkForwardResult;
    import com.strategyquant.tradinglib.optimization.WalkForwardMatrixResult;
    public class NumberOfTradeWF extends DatabankColumn {
    	public NumberOfTradeWF() {
    		super(L.tsq("# of trades WF"), DatabankColumn.Integer, ValueTypes.Aproximate, 0, 0, 100);
    		setWidth(70);
    		setTooltip(L.tsq("Number of trades WF"));
    		// this means that value depends on number of trading days 
    		// and has to be normalized by days when comparing with another
    		// result with different number of trading days
    		setDependentOnTradingPeriod(true); 
    	}
    	//------------------------------------------------------------------------
    	@Override
    	public String getValue(ResultsGroup results, String resultKey, byte direction, byte plType, byte sampleType) throws Exception {		
    		/*
    		 * Sample code to obtain the stat value of the WF result
    		 * ----------------------------------------------------
    		 * ----------------------------------------------------
    		 * ----------------------------------------------------
    		 */
    		//Retrieve the WF matrix results
    		WalkForwardMatrixResult mwfResult = (WalkForwardMatrixResult) results.mainResult().get(SettingsKeys.WalkForwardResult);
    		if(mwfResult==null) {
    			return "NA";
    		}
    		/*
    		 *  WalkForwardMatrixResult opt params
    		 * 	public int start1;
    			public int stop1;
    			public int increment1;
    			public int start2;
    			public int stop2;
    			public int increment2;
    			for(int j=mwfResult.start2; j<=mwfResult.stop2; j+=mwfResult.increment2) {
    				for(int i=mwfResult.start1; i<=mwfResult.stop1; i+=mwfResult.increment1) {
    					WalkForwardResult wfResult = mwfResult.getWFResult(i, j);
    				}
    			}
    		 */
    		int param1 = mwfResult.start1; //oos		
    		int param2 = mwfResult.start2; //run
    		//Obtain a specific WF result from the matrix
    		WalkForwardResult wfResult = mwfResult.getWFResult(param1, param2);
    		/*
    		 * WalkForwardResult calculated stats
    		 * public SQStats stats = null; //Full Sample stats
    		 * public SQStats statsOOS = null; //OOS stats
    		 * public SQStats statsStability = null; //The stats stability
    		 * public SQStats statsScore = null; //The stats score
    		 * public SQStats statsSpecial = null; //The stats special
    		 */
    		//Return the calculated value of stats
    		return wfResult.stats.getInt("NumberOfTrades")+"";
    	}
    }
    Past performance is no guarantee of future success. All information should be viewed as educational only UNITED STATES Disclaimer required by Government - Commodity Futures Trading Commission informs: Futures and options trading have great potential rewards, but also great potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don't trade with money you can't afford to lose. This is neither a solicitation nor an offer to buy/sell futures, shares or options on the same. No representation is being made that any account will or is likely to realise profits or losses similar to those discussed in this document. The past performance of any trading system or methodology is not necessarily indicative of future results. CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE A RECORD OF ACTUAL PERFORMANCE, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES WERE NOT EXECUTED, THE RESULTS MAY HAVE OFFSET THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMMES IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO REALISE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL, OR IS LIKELY TO, REALISE PROFITS OR LOSSES SIMILAR TO THOSE DISCUSSED WITHIN THIS SITE. IF YOU DECIDE TO INVEST REAL MONEY, ALL TRADING DECISIONS IN THE FINANCIAL MARKETS SHOULD BE YOUR OWN.
    Free

    Files

    • Snippet-NumberoftradesfromWFMatrix.sqm4 KBLocked

    Download unlocks after purchase or with an active tier.

    Details
    Version1.0.0
    PublishedOctober 19, 2026
    Last updatedOctober 22, 2026
    AppSQ
    TypeSnippet
    Authortomas262
    App version145.3058
    Codebase categoryDatabank / Filter