Nika EA V1.28 — Complete Documentation, Technical Analysis & Quick Reference
Nika EA is a multi-strategy Expert Advisor for MetaTrader 5 built around a proprietary oscillator engine that uses least-squares linear regression on price deviation — not price itself — to generate directional signals. This article explains how that signal engine works, how the modular rule system processes those signals, and how the 15-layer risk management stack controls trade exposure from entry to exit.
The Trading Problem
Most oscillator-based EAs apply a smoothing function directly to price — a moving average, RSI, or stochastic value — and trigger entries when that value crosses a threshold or a second line. The problem is that raw price carries noise and scale. An indicator tuned for EURUSD will produce entirely different magnitude values on XAUUSD or NAS100, requiring constant re-parameterization per instrument.
A second problem affects trend-following strategies specifically: raw price momentum indicators tend to trigger entries late because they lag directional change. By the time a moving average crossover fires, a significant portion of the move has already occurred.
Nika EA was designed to address both of these problems — scale dependency and lag — at the signal calculation level rather than through post-hoc filtering.
How the Signal Engine Solves It
The core idea is to measure where price sits relative to a dynamically computed structural midpoint, and then apply linear regression to that deviation series. Instead of asking "is price moving up?", the engine asks "is price's position within its own structure trending upward?" The output is a normalized oscillator that represents momentum in structural terms, not price level terms.
Because the output is normalized on the first bar using a global scale multiplier, the same parameter set — lookback period, average period, signal threshold — can operate across instruments with very different price levels. A length-13, period-3 configuration means the same thing on gold at $2900 as it does on EURUSD at 1.08.
Technical Explanation: The Five Computation Steps
The signal calculation runs in five sequential steps per bar. Understanding each step is necessary to understand why the output behaves the way it does.
Step 1 — Dynamic Midpoint
Over the lookback window, the engine finds the highest high and lowest low. Their average is calculated, then averaged again with a running EMA of price. This produces a midpoint that adapts to both range and trend conditions — wider ranges push the midpoint lower or higher, while the EMA component prevents the midpoint from being purely mechanical.
Step 2 — Deviation Series
The close price (or Heiken Ashi close if HA pre-processing is enabled) is subtracted from the dynamic midpoint. This produces a centered deviation value that represents price's position within its current structure. When price is above the midpoint, the deviation is negative. When price is below, it is positive. The series is zero-centered and instrument-agnostic.
Step 3 — Least-Squares Linear Regression
Over the full lookback window, the engine computes the standard least-squares regression of the deviation series. The slope is derived as:
slope = (N × sumXY − sumX × sumY) / (N × sumX² − sumX²)
The intercept is computed as (sumY − slope × sumX) / N. The regression endpoint — the value at the final bar — is used as the signal line output. An optional bar offset shifts the endpoint, allowing the signal to reference a slightly earlier regression state, which can reduce false triggers on fast-moving instruments.
Step 4 — Scale Normalization
On the first calculated bar, if the signal line value is non-zero, a global scale multiplier is set as abs(10 / signal_line_value). All subsequent signal values are multiplied by this factor. This means the oscillator output stays within a consistent numeric range regardless of the instrument's price magnitude — critical for using fixed threshold levels across multiple symbols without re-tuning.
Step 5 — Average Line Smoothing
The signal line output is passed through a configurable moving average — SMA, EMA, WMA, or T3 — to produce the average line. The crossover between the signal line and its average line forms the primary trigger used in the default signal mode. The choice of MA type affects how responsive or smooth the average line is, which directly determines the frequency and lag of crossover signals.
Heiken Ashi Pre-Processing
Before the deviation calculation runs, an optional Heiken Ashi transformation is applied to the price data. Open, high, low, and close are recalculated using the standard HA formulas — HA close is the average of OHLC, HA open is the average of the previous HA open and close, HA high is the maximum of the real high, HA open, and HA close, and HA low is the minimum of the real low, HA open, and HA close.
The resulting smoothed OHLC values replace raw price in both the midpoint range scan and the deviation subtraction. The practical effect is that the deviation series becomes less responsive to individual bar spikes. Wicks caused by news, spread widening, or low-liquidity moments have reduced influence on the regression output. This is a design choice that trades some responsiveness for cleaner signal behavior on instruments with volatile intrabar movement like XAUUSD or crypto.
The Histogram Oscillator
A separate histogram module runs in parallel with the signal line calculation. It computes an EMA of price, then measures two buffers: the distance between the bar's high and the EMA (the bull buffer), and the distance between the EMA and the bar's low (the bear buffer). Both buffers are independently EMA-smoothed and combined into a final histogram series.
This histogram quantifies the vertical spread between price extremes and the central EMA — a measure of momentum range rather than direction alone. It can expand during strong directional moves and contract during consolidation. It is available as an independent signal source in four of the twelve signal modes, and can be combined with the main signal line via the rule system for entry confirmation or filtering.
The 12 Signal Types
The signal engine exposes twelve distinct signal modes, each using the same underlying calculations in a different logical form:
- Nika Signal Crosses Average — signal line crosses its own smoothed average; the default and most commonly used mode
- Nika Signal Line Level Cross — signal line crosses a user-defined numeric threshold, useful for zero-line or overbought/oversold logic
- Histogram Level Cross — histogram crosses a defined level, triggering on momentum range expansion
- Histogram Moving Up or Down — directional change of the histogram across consecutive bars, acting as a slope trigger
- MA Crossover — standard dual moving average crossover on price, available as an independent rule within the same framework
- Close Above or Below MA — price close relative to a single moving average, useful as a trend filter
- Two Nika Signal Lines Crossover — two independently configured signal line instances cross each other, allowing fast/slow signal comparison
- Two Nika Signals Cross Average — both signal instances must cross their respective averages simultaneously
- Nika Signal Crosses Two Averages — signal line must cross two distinct averages, requiring stronger confirmation before triggering
- Nika Signal Line Moving Up or Down — directional slope trigger on the signal line itself, without requiring a crossover
- Nika Average Line Moving Up or Down — slope trigger on the smoothed average line
- Signal and Average Lines Moving Together — both lines must be moving in the same direction simultaneously, a consensus confirmation mode
The Modular Rule System
Three independent rule slots each support any of the twelve signal types. Each slot has its own timeframe setting, independent of the chart timeframe the EA is attached to. Each slot is assigned a role: Entry Trigger or Entry Filter.
Entry Control determines how multiple enabled rules combine. In ALL mode, every enabled rule must agree before an entry fires. In ANY mode, a single rule agreement is sufficient. The same logic applies independently to exit signals via the Exit Control parameter. This allows a wide range of strategy structures — a fast signal triggering with a slow signal confirming, two independent confirmation filters combined with ANY logic, or a pure multi-timeframe alignment system using ALL control across three timeframes.
The 15-Layer Risk Management Stack
Each layer is independent and optional. They operate in the following categories:
- Stop Loss — three methods: Fixed Pips, ATR Multiplier (with configurable timeframe, period, and multiplier), or Price Promille (a percentage of average recent price, self-scaling to instrument level)
- Take Profit Ladder — up to 10 TP levels, each defined as an RRR multiplier relative to the stop loss, with a partial close percentage per level; this allows graduated exits that lock in gains while leaving a portion running
- Breakeven — automatic stop advancement to entry price after the position reaches a configurable profit threshold
- Stop Loss Steps — progressive stop ratcheting that advances the stop in defined increments, independent of the trailing stop
- Trailing Stop — RRR-based step trailing or fixed percentage trail, configurable start distance, step size, and offset
- Daily Account Trailing — equity curve trailing stop at the session level; once daily profit reaches a start threshold, the trailing level advances with equity and blocks trading if equity drops below the current trail level
- Daily Loss Limit — pauses trading for the session on breach; auto-resumes at a configurable hour the following day
- Daily Profit Limit — locks in daily gains by stopping new entries after reaching a target; auto-resumes the next day
- Weekly Loss Limit — extended period cap with configurable resume day and hour
- Weekly Profit Limit — weekly gain protection with the same resume scheduling
- Maximum Entries Per Day — caps the number of new entries within a single session
- Maximum Open Lot — volume cap per symbol or across all symbols on the account
- Spread and Commission Compensation — adjusts TP and SL distances to account for real execution costs; requires accurate commission input per lot for the target instrument
- Direction Filter — Long Only, Short Only, or Both; can be changed at any time without restarting the EA
- Trade Cooldown — bar-count cooldown per entry type (main, re-entry, scale-in) that prevents repeated entries within a defined number of bars after a signal
Re-Entry and Scale-In Systems
After a trade closes, the re-entry system can open a new position in the same direction for a configurable series count — a fixed number, zero to disable, or -1 for infinite re-entries. Each re-entry respects the full signal and filter logic, so it only triggers when conditions still align. Re-entries use a separate magic number for clean position tracking and are subject to their own cooldown setting.
The scale-in system supports up to 10 independent levels, each defined by an RRR trigger distance from the current price and a position size percentage. Scale entries add to a running position as it moves in the intended direction, building exposure in a structured way rather than at arbitrary intervals. Scale entries also use a dedicated magic number and cooldown setting.
Additional Operational Features
The live news filter integrates with an external economic calendar CSV feed. High, medium, and low impact events can be filtered independently, each with configurable pause windows in seconds before and after the event. When a news event is active, the EA pauses new entries and can optionally close open positions. Visual lines are drawn on the chart for each upcoming event with configurable color and style per impact level.
The session hours filter restricts trading to a defined start and end time, with timezone and DST offset options. Trading can optionally close all positions at the end hour, either every day or on Fridays only. The weekday filter enables or disables trading on individual days of the week. The dashboard provides a real-time chart overlay showing signal states for each rule slot, daily and weekly P&L, active filter states, and a running log of the most recent trade actions.
Strategy Tester Integration
Nika EA exposes six custom optimization criteria for the MT5 Strategy Tester, allowing the optimizer to rank parameter sets using compound metrics rather than raw profit alone. The available criteria include result divided by maximum drawdown squared, result multiplied by recovery factor, combinations of drawdown and recovery factor, result divided by drawdown multiplied by Sharpe ratio, and win rate. This allows optimization sweeps to be targeted at risk-adjusted performance profiles rather than nominal return maximization.
Practical Setup Sequence
The recommended setup sequence is as follows: attach the EA to any MT5 chart, enable at least one rule slot with a signal type and timeframe, configure the stop loss method and at least one TP level or trailing mode, enable daily loss limit and maximum open lot as a minimum risk baseline, and run a backtest in the Strategy Tester before deploying to a live or prop account. The EA requires a hedging account type, market order execution, and for the news filter, the calendar URL must be added to the allowed URLs list in Terminal Options.
Translations are available on request. If needed, this article can be translated into Russian, Spanish, Portuguese, or Chinese.


