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

    Kolmogorov-Smirnov Test (KSTest)

    StrategyQuantIndicators
    Kolmogorov-Smirnov Test (KSTest)

    Statistical indicator that detects market regime changes by analyzing distribution shifts in price data. Includes two custom blocks for regime-change signals to strengthen trading system performance.

    Market conditions change constantly, but identifying meaningful shifts from normal market behavior remains one of trading’s biggest challenges. The Kolmogorov-Smirnov Test (KS Test) indicator offers a sophisticated statistical approach to detecting these critical market transitions.


    What is the KS Test?

    The Kolmogorov-Smirnov Test is a statistical tool that compares two samples of data to determine if they come from the same distribution. In trading terms, it compares recent price action against historical price behavior to identify statistically significant changes in market dynamics.


    How Does It Work in Practice?

    The indicator takes three main parameters:

    • Period1: The size of your recent price sample (e.g., the last 20 bars)
    • Period2: The size of your historical comparison sample (e.g., the previous 50 bars + Period1)
    • SignalThreshold: The statistical confidence level (typically 0.05 or 5%)

    When the test detects a significant difference between recent and historical price behavior, it generates a signal (1), suggesting a potential regime change. A value of 0 indicates no significant change detected.


    Key Benefits for Traders

    The KS Test offers several unique advantages over traditional technical indicators:

    1. Statistical Rigor: Unlike many technical indicators based on arbitrary rules, the KS Test uses proven statistical methods to identify market changes.
    2. Distribution-Agnostic: The test doesn’t assume prices follow any particular distribution, making it more robust across different market conditions.
    3. Early Detection: It can often identify regime changes before they become obvious in price action, giving traders a potential edge.
    4. Adaptability: The indicator automatically adjusts to changing market volatility and doesn’t require constant parameter optimization.


    Practical Implementation Tips

    To get the most out of the KS Test indicator:

    Start with longer timeframes (4H or daily charts) to reduce noise. The statistical nature of the test makes it more reliable with higher timeframe data.

    Consider using Period1=20 and Period2=50 as initial settings. These provide a good balance between responsiveness and reliability. Adjust based on your trading timeframe and style.

    The SignalThreshold of 0.05 is standard in statistics, but you might want to experiment. A lower threshold (e.g., 0.01) generates fewer but more significant signals, while a higher value (e.g., 0.10) provides more frequent signals.

    Combine the KS Test with other indicators for confirmation. For example, use it alongside trend indicators or volume analysis to build a more complete picture of market conditions.


    Risk Management Considerations

    While powerful, the KS Test shouldn’t be used in isolation. A regime change signal doesn’t necessarily indicate direction – it only suggests that market behavior has significantly changed. Always use proper position sizing and stop losses, and consider the broader market context when making trading decisions.


    Conclusion

    The Kolmogorov-Smirnov Test indicator brings statistical rigor to technical analysis, offering traders a sophisticated tool for detecting market regime changes. Its ability to identify significant shifts in market behavior makes it particularly valuable for both discretionary traders and systematic trading strategies. As with any trading tool, success comes from understanding its strengths and limitations, and incorporating it thoughtfully into a complete trading approach.

    Remember: The best trading tools are those that align with your trading style and risk management approach. Take time to understand how the KS Test behaves in different market conditions before incorporating it into your live trading.

    Part of the indicator also includes its own exported custom blocks, two in total. One custom block defines when the market regime changes, and the other custom block defines when the market regime remains the same.

    • KSTest_RegimeChanged
    • KSTest_RegimeNOTChanged

    Indicator is implemented for: MT4/MT5/Tradestation/ Multicharts.

    You can easily do your conditions in Custom blocks. More information you can find here:

    • https://strategyquant.com/doc/strategyquant/custom-blocks/
    • https://strategyquant.com/doc-category/strategy-templates-custom-blocks/
    • https://www.youtube.com/watch?v=CGkn5kh_etc

    In this module, you can also modify the custom blocks – change the periods, change the steps, etc.

    How to import custom indicators to SQX:

    • https://strategyquant.com/doc/programming-for-sq/import-export-custom-indicators-and-other-snippets/

    You know me as clonex. I’m Ivan Hudec — I built the free blocks you’re using here, and I write about the research behind them at algotrading.space. Need something built? Work with me.
    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.
    Free1 download

    Files

    • Snippet-KolmogorovSmirnovTestKSTest.sqm17 KBLocked

    Download unlocks after purchase or with an active tier.

    Details
    Version1.0.0
    PublishedOctober 19, 2026
    Last updatedNovember 2, 2026
    AppSQ
    TypeSnippet
    Authorclonex / Ivan Hudec
    App version145.3058
    Codebase categoryIndicators / Signals