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

    (WD) Wasserstein Distance

    StrategyQuantIndicators
    (WD) Wasserstein Distance

    Measures price distribution shifts using Wasserstein Distance to detect changes in market structure. Useful for recognizing when trends are forming or weakening to adjust your strategies.

    The Wasserstein Distance indicator is a tool designed to measure how the market’s price distribution changes over time. It works by comparing two sets of historical price data, one from the most recent bars and one from a prior period. The goal is to identify shifts in the underlying price structure, giving you early insight into potential changes in market behavior.

    What the indicator measures:

    • Price Distribution Shifts:
    The WD indicator looks at the closing prices from two different windows of time. For example, it might compare the last 50 bars to the 50 bars that came before them. By assessing how the distributions of these prices differ, it provides a sense of how stable or volatile the market structure is.
    • Wasserstein Distance:
    This is the mathematical measure it uses. Essentially, it calculates the “distance” between the two sets of prices in terms of their distribution. The greater the difference, the larger the WD value. This distance is not just a simple average—it’s a more sophisticated comparison that accounts for the shape and spread of the price data.

    How the calculation works:

    • Divide into Two Windows:
    First, the indicator selects a set number of bars (say 50) from the most recent price data and another set from the preceding period.
    • Sort and Compare Prices:
    Both sets of prices are sorted in order. The indicator then compares corresponding points in these sorted sets. If the current set of prices has moved far away from the previous set, the Wasserstein distance will be larger.
    • Normalize the Output:
    The raw distance is then normalized—scaled into a range from 0 to 100. This makes it easy to interpret. A higher value means the price distribution has changed significantly; a lower value means it hasn’t changed much.

    How to interpret the WD value:

    • When the WD value is high, it suggests that the current price structure is very different from the previous one. This might mean the market is undergoing a shift, like moving from a trend to a range or vice versa.
    • A low WD value indicates that the price structure hasn’t changed much, so the current market behavior is likely stable.

    Parameter considerations:

    • Period:
    The “Period” parameter determines how many bars to include in each price window. Shorter periods will react more quickly to changes but may be more erratic. Longer periods smooth out noise and offer more stable signals.
    • Shift:
    Although not always necessary, a shift can be used to offset the indicator’s calculation, letting you analyze how the market behaved a certain number of bars back.

    What it’s good for:
    The WD indicator doesn’t tell you when to buy or sell. Instead, it helps you stay aware of how the market’s price structure is evolving. If you see the WD value start to climb, it’s a signal that the market’s rhythm might be changing. That could mean a new trend is forming, or the existing trend is weakening. With this information, you can pay closer attention, adjust your strategies, and make more informed decisions.

    Indicator Availability:
    This indicator is implemented for MT4, MT5, TradeStation, and MultiCharts.

    Using Custom Blocks for Conditions:
    You can easily define your own conditions in StrategyQuant X using Custom Blocks. This allows you to set up parameters such as periods or steps to fine-tune the indicator to your strategy. For more detailed information, refer to the following resources:

    • StrategyQuant Documentation: Custom Blocks
    • StrategyQuant Documentation: Strategy Templates & Custom Blocks
    • StrategyQuant YouTube Tutorial: Custom Blocks Overview

    Importing Custom Indicators into SQX:
    To import custom indicators into StrategyQuant X, follow the step-by-step instructions provided here:
    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.
    Free3 downloads

    Files

    • Snippet-WDWassersteinDistance.sqm19 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