Stochastic Divergence Indicator for MT4 and MT5

TrueTL Stochastic Divergence indicator finds Stochastic divergences and draws them directly on the chart. It shows regular and hidden divergence lines on the price chart and in the Stochastic window, with optional arrows, vertical lines, alerts, multi-timeframe calculation, and EA-ready signal buffers.

Confirmed divergence signals do not repaint (more info). Confirmed arrows are drawn only after the signal candle has closed and the divergence is confirmed. Predicted divergence is different: it is an early warning mode, and predicted signals can disappear if the setup does not confirm.

Key features:

  • Works in both MetaTrader 4 and MetaTrader 5.
  • Finds regular and hidden Stochastic divergences automatically.
  • Draws divergence lines on the main chart, in the Stochastic window, or both.
  • Confirmed divergence signals do not repaint after confirmation (more info).
  • Optional predicted divergence mode can warn earlier, before full confirmation. This is useful for early context, but the signal can disappear.
  • Built-in Stochastic %K and %D calculation with K period, D period, slowing, MA method, applied price, and bar shift settings.
  • Multi-timeframe support with step, linear, smooth, weighted, and SMA interpolation modes.
  • Works with normal candle charts, line charts, and offline charts such as Renko or block charts.
  • 5 configurable signal slots. Each slot has its own buffer, arrow color, vertical line option, and alert timing.
  • Signal types include Stochastic crosses, level crosses, direction changes, peaks/valleys, trendline breakout, trendline approach, regular divergence, hidden divergence, and predicted divergence.
  • Alerts can be sent by popup, push notification, email, sound, Telegram, CSV file, and chart pictogram.
  • Force refresh and smart HTTP/cache modes help keep visual backtesting and repeated testing faster (more info).
  • Divergence filtering can be tightened with maximum distance, candle-body filtering, Stochastic level filters, value tolerance, and sensitivity control (more info).
  • All drawing colors, line styles, arrow symbols, Stochastic line styles, and the show/hide button are controlled from the Inputs tab.

EA and iCustom usage:

The indicator is ready for Expert Advisor integration through iCustom(). The first two buffers return the Stochastic lines. Buffers 2-6 return the five user-configurable signal slots, so an EA can read only the events you select in the inputs.

For example, Signal 1 can be set to any divergence, Signal 2 to regular divergence only, Signal 3 to a Stochastic level cross, and the EA can read those events from separate buffers. This keeps manual trading, alert trading, and automated trading aligned with the same indicator settings.

  • Buffer 0: Stochastic %K (or dynamic) main line.
  • Buffer 1: Stochastic %D (or dynamic) signal line.
  • Buffer 2: Signal 1 buffer. Returns 1 or -1 based on the selected Signal 1 setting.
  • Buffer 3: Signal 2 buffer. Returns 1 or -1 based on the selected Signal 2 setting.
  • Buffer 4: Signal 3 buffer. Returns 1 or -1 based on the selected Signal 3 setting.
  • Buffer 5: Signal 4 buffer. Returns 1 or -1 based on the selected Signal 4 setting.
  • Buffer 6: Signal 5 buffer. Returns 1 or -1 based on the selected Signal 5 setting.

Stochastic Divergence Indicator Settings Panel
Stochastic Divergence Indicator Settings Panel


Indicator Inputs

  • Version: shows the installed indicator version. If support asks for your version, this is the value to check.
  • Username (without spaces, case sensitive): enter the username you received after purchase. After the first successful activation, you can usually leave it unchanged in other instances (about our ex4 protection).
  • Auto refresh: controls when server-side divergence objects are refreshed.
    Off disables automatic refresh.
    On refreshes when needed after closed bars.
    Force refresh also refreshes while you scroll the chart. This is useful during visual backtesting (Example Video).
  • Smart HTTP request: controls how often the indicator sends calculation requests.
    Off requests calculation on every bar. Use this if you want the most direct mode.
    Estimate skips requests when the indicator is very likely not to need a new object. This is faster.
    Cache saves and reuses previous results for the same symbol, timeframe, and settings. This is usually the fastest for repeated tests.
    Cache reset rebuilds the cache for the current symbol, period, and settings.
  • K period / D period / Slowing period: set the Stochastic calculation. K period controls the main range, D period smooths the signal line, and Slowing period smooths the main %K line.
  • Applied MA method: selects the smoothing method used by the Stochastic calculation:
    Simple
    Exponential
    Smoothed
    Linear weighted
  • Applied price: selects the Stochastic price formula.
    Low/High uses the candle high-low range.
    Close/Close uses close prices.
  • Stochastic bar shift: shifts the Stochastic calculation by the selected number of bars. Most users should keep this at 0.
  • Stochastic timeframe: selects the timeframe used for the Stochastic calculation. It can use the current chart timeframe, fixed timeframes, or relative lower/higher timeframe presets.
  • MTF on higher TF only: when enabled, multi-timeframe mode is applied only if the selected Stochastic timeframe is higher than the chart timeframe.
  • MTF Interpolation mode: controls how values from another timeframe are placed on the current chart.
    Off keeps step-like values.
    Linear connects values evenly.
    Smooth uses smoother transitions.
    Weighted gives more weight to closer source bars.
    SMA smooths values with a period based on the timeframe ratio.
  • Maximum bars to calculate: limits how many bars are calculated. A lower value can improve performance. A higher value gives more history.
  • Show in the indicator window: controls the label shown in the indicator window. Use Allow multiple instances if you want to run more than one copy on the same chart. Available options are:
    Only "TrueTL"
    Indicator name
    Indicator name + settings
    Indicator name + settings + values
    Indicator name + values
  • Allow multiple instances: allows several Stochastic Divergence indicators on the same chart by giving each instance its own settings identity.

Levels Settings

  • Show levels: shows or hides the Stochastic reference levels in the indicator window.
  • High level (overbought) / Low level (oversold): set the upper and lower Stochastic zones. These levels are used for display, coloring, filters, and level-cross signals.
  • Show middle level: adds the middle level between the high and low levels. With the default 80/20 settings, the middle level is 50.
  • Color of indicator levels / Style and width of indicator levels: set the color, style, and width of the level lines. Available line styles include solid, dash, dot, dash-dot, and dash-dot-dot.

Divergence Settings

  • Use line chart (close prices) for divergence: makes divergence detection use close prices instead of candle highs and lows. This is useful for line charts or when you want to ignore wick extremes.
  • Maximum divergence distance (bars): limits how far apart the two divergence points can be. Smaller values focus on recent structures. Larger values allow wider swings.
  • Filter by candle body: removes weaker divergences when candle bodies conflict with the price-side divergence line. This can help reduce wick-based noise.
  • Value filter: filters divergence by where the two Stochastic points are located. A and B are the two Stochastic points of the divergence line. For example, you can require bullish divergences to form near or below the low level and bearish divergences near or above the high level (more info). Available rules are:
    Show all divergences
    A: above/below high/low B: above/below high/low
    A: above/below high/low B: above/below middle
    A: above/below high/low B: all
    A: above/below middle B: above/below high/low
    A: above/below middle B: above/below middle
    A: above/below middle B: all
    A: all B: above/below high/low
    A: all B: above/below middle
  • Value tolerance: gives the Value filter a little extra room. A value of 0 applies the level rule exactly.
  • Detection sensitivity: controls how many divergence structures the indicator searches for. Normal is stricter. Higher finds more setups. Highest is the most sensitive.
  • Divergence prediction: enables early predicted divergence markers. Use this when you want earlier warning, not final confirmation.
    Off
    Same sensitivity as the divergence
    Highest sensitivity
    Confirmed divergences do not repaint, but predicted markers can disappear if the candle closes without confirmation.
  • Divergence showing mode: chooses which divergence direction remains visible:
    Show all divergences
    Show only bullish divergences
    Show only bearish divergences
  • Draw divergence lines on price chart / Draw divergence lines on indicator: chooses where divergence lines are drawn: main chart, Stochastic window, or both.
  • Draw objects in background: places divergence objects behind candles and other chart drawings.
  • Approach distance (Stochastic units): sets how close the Stochastic line must come to a drawn trendline before an approach signal can trigger.
  • Bullish regular style and color / Bullish hidden style and color / Bearish regular style and color / Bearish hidden style and color: set the line style and color for each divergence type. Off hides that type. Other styles include solid, dash, dot, dash-dot, and dash-dot-dot.
  • Filtered divergence color: sets the color for divergence objects detected outside the selected filter rules.
  • Predicted bullish divergence color / Predicted bearish divergence color: set the arrow and line color used for predicted divergence markers.
  • Status notification corner: sets where chart-side status messages are shown.

Signal Settings

  • Signal 1 / Signal 2 / Signal 3 / Signal 4 / Signal 5: each signal slot can watch a different event. Each slot has its own iCustom buffer, arrow color, vertical line output, and alert timing. Available events are:
    None
    Main line direction change
    Signal line direction change
    Both lines direction change
    Lines cross each other
    Main line cross high level
    Main line cross mid level
    Main line cross low level
    Main line cross any level
    Signal line cross high level
    Signal line cross mid level
    Signal line cross low level
    Signal line cross any level
    Both lines cross high level
    Both lines cross mid level
    Both lines cross low level
    Both lines cross any level
    Main line peak/valley
    Signal line peak/valley
    Trendline breakout
    Stochastic approaches trendline
    Regular divergences
    Hidden divergences
    Any divergence (regular and hidden)
    Regular predicted divergence
    Hidden predicted divergence
    Any divergence + predicted divergence
  • Vertical line on/off and size/style: draws an optional vertical line on signal bars. Use it when you want signals to remain easy to see during chart review.
  • Arrow on/off and size: draws signal arrows on the main chart. Arrow size can be set to Size 1-8, or turned off.
  • Arrow distance from candle: controls how far arrows are placed from candles. ATR-based distance adapts to volatility. Point-based distance uses fixed point values.
  • Up arrow code / Down arrow code: set the Wingdings symbols for confirmed bullish and bearish signal arrows. Defaults are 233 for up and 234 for down.
  • Arrow symbol at predicted bullish divergence / Arrow symbol at predicted bearish divergence: set separate Wingdings symbols for predicted divergence markers, so early warnings can look different from confirmed signals.
  • Signal 1-5 Up color / Signal 1-5 Down color: assign separate bullish and bearish colors to each signal slot. This is useful when several signals are active at the same time.

Alert Settings

  • Alert on new divergences: sends an alert when a new regular or hidden divergence is detected. This works independently from the five signal slots.
  • Alert for Signal 1-5: sets alert timing separately for each signal slot:
    Off
    After candle closed
    Before candle is closing
    Both
  • Trendline objects to alert for: selects which chart objects are monitored by trendline breakout and approach alerts:
    TrueTL drawn trendlines only
    All trendlines and horizontal lines
    Selected trendline colors only
  • Trendline color filter: defines the monitored object color when trendline alerts are set to selected colors.
  • Alert interval limit (minutes, 0 = no limit): prevents repeated alerts from firing too often. 0 disables the interval limit.
  • Shortcut key to send test alert: lets you send a test alert from the chart with a keyboard shortcut. Available keys are 0-9 and A-Z.
  • Alert start time / Alert end time: limits alerts to a daily time window. 00:00 to 00:00 means alerts are allowed all day.
  • Message identifier: adds a short label to alert messages. This is useful when several charts, symbols, or indicator instances are running.
  • Alert via email / Alert via push notification / Alert via popup window / Alert with sound / Sound file: enable the MetaTrader alert channels and select the sound file for sound alerts.
  • Telegram Notifications / Token / Chat ID: enable Telegram delivery and define the bot token and destination chat ID.
  • Pictogram alert: shows a chart-corner symbol that changes with the latest alert direction.
  • Pictogram corner / Pictogram X / Pictogram Y / Pictogram size / Pictogram symbol: control the position, size, and Wingdings symbol of the pictogram alert.
  • Pictogram UP color / Pictogram DOWN color / Pictogram neutral color: set the bullish, bearish, and neutral pictogram colors.
  • Write alert to CSV file: writes alerts to a CSV file in the platform files folder for later review or external automation.

Color and Style Settings

  • Color mode: controls how the %K and %D lines are colored. Available modes are:
    Simple color
    Cross
    Crossed after closed
    Cross on selected timeframe
    Crossed after closed on selected timeframe
    Only direction
    Direction with levels
    Only levels
  • Draw Main line in histogram mode: displays the Stochastic %K main line as a histogram instead of a line.
  • Color 1-4 of Main line: set the four possible color states for the %K main line. The active color depends on the selected Color mode.
  • Style and width of Main line: selects the line style and width for the %K main line.
  • Draw Signal line in histogram mode: displays the Stochastic %D signal line as a histogram instead of a line.
  • Color 1-4 of Signal line: set the four possible color states for the %D signal line. The active color depends on the selected Color mode.
  • Style and width of Signal line: selects the line style and width for the %D signal line.

Show/Hide Button Settings

  • Enable show/hide button: enables the chart button used to show or hide the indicator without removing it from the chart (more info).
  • Shortcut for button / Apply for all TrueTL Indicators on the chart: controls keyboard access and whether the button affects only this instance or all TrueTL indicators on the chart. Available shortcut values are Off, 0-9, and A-Z.
  • Adjust the corner of button / Adjust the coordinate X of button / Adjust the coordinate Y of button: sets the button position on the chart.
  • Adjust the text of button / Adjust the text's font of button / Adjust the text's size of button / Adjust the text's color of button: controls the button caption.
  • Adjust the background color of button / Adjust the background color of button when hidden / Adjust the border color of button: controls the button colors in visible and hidden states.
  • Adjust the width of button / Adjust the height of button / Button DPI scale: controls the button size on different displays. DPI scale can be automatic or fixed from 50% to 200%.
Stochastic Divergence #1 Stochastic Divergence #2 Stochastic Divergence #3 Stochastic Divergence #4

Risk warning

Foreign exchange transactions carry a high degree of risk and any transaction involving currencies is exposed to, among other things, changes in a country's political condition, economic climate, acts of nature - all of which may substantially affect the price or availability of a given currency.

Speculative trading in the foreign exchange market is a challenging prospect with above average risk. You must therefore carefully consider your investment objectives, level of experience and appetite for such risk prior to entering this market. Most importantly, do not invest money that you are not in a position to lose.

In addition, trading on a margin basis means that any market movement will have a proportionate effect on your deposited funds. This can work for you as well as against you. The possibility exists that you could sustain a total loss of initial margin funds.

Risk Warning