Knoxville Divergence Settings/Inputs Guide for MT4 & MT5

12 March 2026, 09:09
Biswarup Banerjee
0
251

MT4 Version: KnoxVille Divergence EA MT4

MT5 Version:

Complete User Documentation — MT4 & MT5

1. OVERVIEW

The KnoxVille Divergence EA is an automated forex trading system built around the Knoxville Divergence indicator — a custom tool that spots hidden and regular divergences between price action and momentum oscillators like RSI and Stochastic. When it detects a divergence, the EA enters a position and then uses a grid averaging mechanism to manage open trades and recover from losing ones. This approach is designed for traders who want to capture reversal moves early but need a systematic way to handle the inevitable false starts that come with divergence trading.

Who Should Use It: Traders who understand divergence concepts and want to automate the detection and execution process, especially those comfortable with grid-based recovery systems for managing drawdowns.

Main Benefit: You get a hands-off system that continuously scans multiple timeframes for divergence setups and automatically manages trade recovery through grid averaging, removing the emotional guesswork from reversal trading.


2. INPUT PARAMETERS & SETTINGS

This product shares a common set of general input settings with all Expert Advisor products in this series. The following sections are covered in the common guide: General Settings (lot size, SL/TP modes, magic number, trade direction), Breakeven Settings, Trailing Stop Settings, News Filter Settings and News Action Settings, Martingale Settings, Grid Settings, Hedge Settings, Risk Settings, Position Sizing, Alert Settings, Display Settings, Trade Time Settings, Trade Days Settings, Safeguard Settings, and Trend Filter Settings (MA Filter, ADX Filter, RSI Filter, MACD Filter, Parabolic SAR Filter — each with their own strategy options). All of these are fully documented in the Common General Input Settings for Expert Advisors. The sections below cover only the product-specific inputs unique to this product.

____ General Settings ____

These parameters control the basic execution behavior of the EA, ensuring trades are placed only under favorable market conditions.

Setting Name Type Default Value Description Example
Slippage int 3 The maximum price deviation in points the EA will accept when sending a market order. If the market moves past this during execution, the order is rejected. Raising it helps during news spikes, but too high can hurt fill quality. 5 — Use this during high-impact news events like NFP to avoid order rejections when spreads widen briefly.
Max Spread double 20 The maximum spread in points the EA will tolerate before skipping a trade. This prevents entries during illiquid periods when slippage is more likely. Lower values protect against bad fills but may reduce trade frequency. 15 — Tighten this on EURUSD during the London close to avoid entering when spreads are widening into the afternoon.

____ Risk Settings ____

This setting lets you define how much monetary risk you're willing to take per micro lot, giving you direct control over position sizing.

Setting Name Type Default Value Description Example
Risk Per MicroLot double 10 The dollar amount risked per micro lot (0.01 lot) when the risk-to-lot feature is enabled. This directly scales your position size based on account equity. Lower values reduce exposure but also potential returns. 5 — Use this on a $500 account to keep per-trade risk around 1% of equity, giving you room to survive a few losing grid cycles.

____ Grid Settings ____

These parameters define how the grid averaging system behaves when managing open positions and recovering from losses.

Setting Name Type Default Value Description Example
Multiplier double 1 The lot size multiplier applied to each subsequent grid order. A value of 1 means all grid orders are the same size; higher values increase exposure on each step, accelerating recovery but also risk. 1.5 — Use this on a trending pair like GBPJPY where you expect strong reversals, but be aware it increases drawdown during prolonged trends.
On Loss[true]: On Profit[false] bool true Controls whether the grid activates after a losing trade or a winning one. When true, it adds positions only when the previous trade is in loss, aiming to average down. Set to false to pyramid on winners instead. false — Switch to profit-based grid if you're trading strong trends and want to add to winning positions rather than rescue losers.
Avg Stoploss double 0 The stop loss in points applied to the average price of all grid positions. A value of 0 disables it. This acts as a circuit breaker — if the average price moves against you by this amount, all positions close. 30 — Set this on a volatile pair like USDJPY to cap total grid loss at 30 pips from the average entry, preventing runaway drawdown.
Avg TakeProfit double 20 The take profit in points from the average price of all grid positions. Once the average price reaches this level, all grid orders close. Adjust based on typical market movement and your risk tolerance. 25 — Use this on EURUSD during the London session when you expect 20-30 pip moves; it gives the grid room to work without being too tight.

____ Trade Time Settings ____

These settings let you restrict trading to specific market sessions, helping you avoid low-liquidity periods or align with your preferred volatility windows.

Setting Name Type Default Value Description Example
Use Trading Times? (24/7 if false) bool false Enables or disables time-based trading restrictions. When false, the EA trades around the clock. When true, you can specify which sessions to trade, which is useful for focusing on high-volume periods. true — Enable this if you only want the EA active during the London and New York overlap, when divergence signals are most reliable.
American Session bool true When time restrictions are on, this toggles whether the EA can trade during the American session (roughly 12:00-20:00 broker time). The US session often brings strong momentum, but also wider spreads at the open. false — Disable the American session if you find that divergence signals during the New York afternoon are less reliable due to lower volume.

____ Safeguard Settings ____

These safety limits prevent the EA from overtrading or exceeding your maximum acceptable drawdown, acting as a hard stop on daily activity and loss exposure.

Setting Name Type Default Value Description Example
Max Drawdown Percent[0:disable] double 0 The maximum equity drawdown percentage allowed before the EA stops all trading. Once hit, it won't open new positions until the next day or manual reset. This is your last line of defense against a bad grid cycle. 15 — Set this on a $1,000 account to stop trading if equity drops below $850, preventing a single bad grid from wiping you out.
Max Trader Per Day[0: disable] int 0 The maximum number of trades (including grid entries) allowed per calendar day. Once reached, the EA stops until the next day. This prevents overtrading during volatile sessions and forces a cool-down period. 5 — Use this on a 15-minute chart to cap daily activity, ensuring the EA doesn't overcommit during a choppy session with many false divergences.

3. HOW IT WORKS

Core Calculation & Logic

The KnoxVille Divergence EA monitors the relationship between price action and a custom oscillator built from RSI, Momentum, and Stochastic values. It's not just looking for overbought or oversold levels — it's specifically watching for divergence: when price makes a higher high but the indicator makes a lower high (bearish divergence), or when price makes a lower low but the indicator makes a higher low (bullish divergence). The EA uses a 30-bar lookback window (CandlesBack) to scan for these patterns, and it combines them with a fast/slow MACD crossover filter to confirm the signal before entering. The grid averaging system then kicks in if the initial trade goes against you, adding positions at set step intervals to bring the average entry price closer to the market.

Mathematically, the EA calculates divergence by comparing the highest/lowest points of the indicator buffer over the lookback period against the corresponding price extremes. It stores these in arrays (Buy[], Sell[], BuyArrow[], SellArrow[]) and checks for alignment — if price and indicator are moving in opposite directions, that's your divergence signal. The MACD filter (FastMAPeriod=12, SlowMAPeriod=26, SignalMAPeriod=9) acts as a trend confirmation, so you're not taking divergence trades against the prevailing momentum.

Entry Strategies Explained

The EA has a single core strategy — divergence detection — but it applies it with two distinct signal types: regular divergence and hidden divergence. Both are filtered through the MACD and Stochastic levels to reduce false signals.

Regular Divergence (Primary Signal)

BUY Signal: Price makes a lower low while the indicator (RSI/Momentum/Stochastic combo) makes a higher low. The MACD histogram must be above its signal line, and the Stochastic must be below the Lower level (default 30). The EA places a buy order at market with the configured lot size.

SELL Signal: Price makes a higher high while the indicator makes a lower high. The MACD histogram must be below its signal line, and the Stochastic must be above the Upper level (default 70). The EA places a sell order at market.

Best For: Trending markets where price is making clear swing highs and lows — works especially well on H1 and H4 timeframes.

Hidden Divergence (Secondary Signal)

BUY Signal: Price makes a higher low while the indicator makes a lower low. This signals that the trend is still strong despite a pullback. The MACD must be bullish (above signal line) and Stochastic below 50 (not necessarily oversold).

SELL Signal: Price makes a lower high while the indicator makes a higher high. This indicates bearish momentum is intact. The MACD must be bearish (below signal line) and Stochastic above 50.

Best For: Strong trending markets where you want to re-enter after a retracement — ideal for trend-following strategies.

Step-by-Step Workflow

Step 1: Load the EA on a chart. Attach KnoxVille Divergence EA to any forex pair on M15, H1, or H4 timeframe. Make sure AutoTrading is enabled in MetaTrader.

Step 2: Configure indicator parameters. Set CandlesBack (default 30), RSIPeriod (21), MomentumPeriod (20), and Stochastic periods (K=70, D=10, Slowing=10). These control how the divergence is calculated — wider values catch bigger divergences but produce fewer signals.

Step 3: Set your trade direction. Choose "Both Directions" for normal use, or restrict to "Only Long" / "Only Short" if you have a directional bias.

Step 4: Configure grid settings. If you want loss recovery, enable the grid (ENABLE_GRID=true) and set Step Distance (default 10 pips) and Multiplier (default 1). The grid will add positions at each step if the market moves against you.

Step 5: Set risk parameters. Decide your Lot Size (0.2 default), Max Spread (20), and whether to use Risk-to-Lot sizing. If you're new, keep ENABLE_RISK_TO_LOT=false and use a fixed lot size.

Step 6: Enable alerts (optional). Turn on PopUp_Alert or Sound_Alert if you want to be notified when a divergence signal fires — useful if you're monitoring multiple charts.

Step 7: Run a backtest first. Before going live, test on at least 6 months of data with 90% modeling quality. Watch how the grid behaves during drawdowns — you'll want to adjust Step Distance and Multiplier based on the pair's average true range.


4. RISK MANAGEMENT FEATURES

The KnoxVille Divergence EA includes several built-in risk controls that work alongside the grid system to protect your account. Here's what each feature does in practice:

Feature Description
Max Spread Filter Blocks trade execution when the spread exceeds your set limit (default 20). Prevents you from entering trades during news spikes or low liquidity — especially important for grid systems where multiple entries compound spread costs.
Grid Step Distance Controls how far apart grid entries are placed (default 10 pips). Wider steps reduce the frequency of grid additions but increase the risk of missing the recovery zone. Narrower steps recover faster but add more positions in choppy markets.
Max Grid Step Limit Hard cap on the number of grid levels (default 15). Once reached, no more positions are added — this prevents unlimited drawdown. Essential for keeping margin requirements under control during prolonged adverse moves.
Average Stop Loss / Take Profit When using Cost Average mode, the EA calculates the average entry price across all grid positions and sets SL/TP based on that average. Default TP_AVG=20 pips means the whole grid closes when the average price is 20 pips in profit.
Risk-to-Lot Sizing When enabled, the EA calculates lot size based on account equity and a risk percentage (default 1.5%). This auto-adjusts position size as your balance changes — useful for compounding without manual recalculations.

Quick Start Guide

Follow these steps to get started in under 5 minutes:

  1. Download and install: Purchase the EA from the MQL5 Market, then download it from the "My Products" tab in MetaTrader. Drag it onto any forex chart (EURUSD H1 recommended for first test).
  2. Enable AutoTrading: Click the AutoTrading button in MetaTrader (it should turn green). If it's grey, check that Algo Trading is enabled in Tools > Options > Expert Advisors.
  3. Set your lot size: Change the Lot Size input from 0.2 to something smaller like 0.01 for testing. You can increase it later once you're comfortable with the behavior.
  4. Configure the grid: Leave ENABLE_GRID=false for your first few trades. Once you understand the divergence signals, enable it with Step Distance=15 and Multiplier=1 to start conservatively.
  5. Set a max spread: Keep MAX_SPREAD at 20 or lower. If your broker's spreads are usually under 2 pips, you can tighten this to 10 to avoid bad entries.
  6. Run a backtest: Open the Strategy Tester, select the EA, set date range to the last 6 months, and use "Every tick" modeling. Watch how the grid behaves during drawdowns — adjust Step Distance if needed.
  7. Go live on a demo: Run the EA on a demo account for at least 2 weeks. Monitor the trade journal for any slippage or spread-related rejections. Only then consider moving to a live account with small risk.


Installation Guide for MQL Products | Updating Purchased MQL Products on MT4/MT5 | General Troubleshooting Guide | Backtest and Set Files

Check all my products: https://www.mql5.com/en/users/biswait50/seller

Contact me for support: https://www.mql5.com/en/users/biswait50