Neuro Nirvaman MQ4 Strategy
Overview
The Neuro Nirvaman MQ4 Strategy is a faithful port of the MetaTrader 4 expert advisor NeuroNirvaman.mq4. The original robot combines a custom Laguerre filter applied to the +DI component of the ADX indicator with a SilverTrend breakout detector. Three perceptrons evaluate these inputs and a supervisor decides whether to buy or sell. The StockSharp version mirrors that workflow and executes one position at a time, recalculating its logic only on fully closed candles.
How the strategy works
- Market data feed – The strategy subscribes to a single candle series defined by
CandleTypeand processes onlyFinishedcandles. It does not evaluate intrabar events, replicating theTime[0]check used in MT4. - Laguerre +DI smoothing – Four
AverageDirectionalIndexindicators provide +DI values which are sent through a Laguerre filter (LaguerrePlusDiState) using the original gamma of 0.764. The filter yields oscillator values in the[0, 1]range and each stream has its own ADX period and neutral zone width (Laguerre*Distance). - SilverTrend port – Two
SilverTrendStateobjects reproduce theSv2.mq4logic. They track the highest high and lowest low forSSPcandles, shrink the channel with the constantKmax = 50.6, and return1for an uptrend or-1for a downtrend. The lookback depths are controlled bySilverTrend1LengthandSilverTrend2Length. - Perceptrons –
- Perceptron #1 mixes the first Laguerre activation with the first SilverTrend swing using weights
X11 - 100andX12 - 100. - Perceptron #2 combines the second Laguerre activation with the second SilverTrend swing and weights
X21 - 100andX22 - 100. - Perceptron #3 evaluates the third and fourth Laguerre activations weighted by
X31 - 100andX32 - 100. Each Laguerre activation is quantised to-1,0or1depending on its distance from the 0.5 equilibrium level.
- Perceptron #1 mixes the first Laguerre activation with the first SilverTrend swing using weights
- Supervisor (
Pass) – The supervisor reproduces the MQLSupervisor()function:Pass = 3: requiresPerceptron #3 > 0. If alsoPerceptron #2 > 0, the strategy buys using the second TP/SL set; otherwise ifPerceptron #1 < 0, it sells using the first TP/SL set.Pass = 2: a positivePerceptron #2opens a long with the second TP/SL set, while any non-positive value opens a short with the first set.Pass = 1: a negativePerceptron #1opens a short, otherwise a long is opened. Both branches use the first TP/SL set.
- Order and risk management – Entries are sent with
BuyMarketorSellMarketusingTradeVolume. Take-profit and stop-loss levels are calculated asentry ± points * PriceStep. Because StockSharp places pure market orders, protective exits are simulated by checking candle highs and lows, exactly like broker-side TP/SL orders would trigger in MT4.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
CandleType |
DataType |
15-minute time frame | Candle type processed by the strategy. |
TradeVolume |
decimal |
0.1 | Order volume in lots. |
SilverTrend1Length |
int |
7 | Lookback length for the first SilverTrend calculation (SSP). |
Laguerre1Period |
int |
14 | ADX period for the first Laguerre stream. |
Laguerre1Distance |
decimal |
0 | Neutral zone width (percent) around 0.5 for Laguerre stream #1. |
X11, X12 |
decimal |
100 | Weights used inside perceptron #1 (the code subtracts 100 before applying them). |
TakeProfit1, StopLoss1 |
decimal |
100 / 50 | Protective distances in points for the first risk profile and all short trades. |
SilverTrend2Length |
int |
7 | Lookback length for the second SilverTrend calculation. |
Laguerre2Period |
int |
14 | ADX period for the second Laguerre stream. |
Laguerre2Distance |
decimal |
0 | Neutral zone width (percent) around 0.5 for Laguerre stream #2. |
X21, X22 |
decimal |
100 | Weights used inside perceptron #2. |
TakeProfit2, StopLoss2 |
decimal |
100 / 50 | Protective distances in points for the second risk profile. |
Laguerre3Period, Laguerre4Period |
int |
14 | ADX periods for the third and fourth Laguerre streams. |
Laguerre3Distance, Laguerre4Distance |
decimal |
0 | Neutral zone widths (percent) for the third and fourth Laguerre streams. |
X31, X32 |
decimal |
100 | Weights used inside perceptron #3. |
Pass |
int |
3 | Supervisor branch that selects which perceptrons can trigger trades. |
Usage notes
- Default weights of
100neutralise the corresponding perceptron input. Move weights away from 100 to create meaningful signals. - SilverTrend starts returning
±1once enough candles are collected. Until then, perceptron outputs may stay at zero, emulating the MT4 behaviour whereiCustomreturns zero before buffers are ready. - Take-profit and stop-loss checks rely on candle extremes; if intra-candle spikes occur between bars, the simulation may diverge slightly from broker-side execution.
- Only one position can exist at a time. A new signal is ignored until the current position is closed either by TP, SL or an opposite decision.
- Adjust
CandleTypeto mirror the chart period used by the original MT4 setup (for example M15 or H1) to keep indicator scaling consistent.