I have a MetaTrader 5 custom indicator named NIKA_Backtest.mq5 , which calculates a smoothed signal using linear regression and EMA smoothing.
This indicator is used in Strategy Tester alongside RunwiseFX, and its logic depends entirely on the crossing of two values:
The white line → linear regression result ( IndicBuffer[] )
The orange line → smoothed EMA of the white line ( SmaIndicBuffer[] )
The strategy does not need live tick updates. Signals only matter after a bar closes, so all logic should be optimized to run only on closed bars ( i ≥ 1 ).
Deliver 5 progressively optimized versions of the indicator, each with faster execution in Strategy Tester — while always preserving signal accuracy and compatibility with RunwiseFX's CaptureBuffer(...) .
Use only closed-bar values ( i >= 1 , skip i == 0 )
Keep both white and orange lines fully functional
Output buffers must be usable in RunwiseFX
Compile cleanly in MetaEditor (MT5 2024+)
Avoid ObjectCreate() unless specifically required
Remove iCustom(..., "Heiken_Ashi")
Re-implement Heiken Ashi calculations inline inside OnCalculate()
Keep all existing chart visuals and rectangles
Runs once per closed candle only
💡 Why faster: Removes nested iCustom() calls and reduces inter-indicator overhead
Based on Version 1
Remove all ObjectCreate() , rectangles, and subwindow visuals
Only keep the two signal plots: white and orange lines
💡 Why faster: Skips all chart object creation and rendering logic that slows Strategy Tester
Based on Version 2
Replace iMA() with inline EMA formula (no indicator handles)
Remove redundant array resizing and avoid excessive memory use
Simplify smoothing logic while maintaining output
💡 Why faster: Eliminates overhead from iMA() handles and reduces RAM operations
Based on Version 3
Fully implement prev_calculated logic
Process only new bars ( start = prev_calculated > 1 ? prev_calculated - 1 : 1 )
Optimize all loop ranges and minimize floating-point operations
💡 Why faster: Avoids recalculating old bars; dramatically speeds up long backtests
Remove Heiken Ashi completely
Remove all non-essential buffers and visuals
Use only:
IndicBuffer[] (white)
SmaIndicBuffer[] (orange)
Keep prev_calculated and inlined math
Use DRAW_NONE if needed to disable visual overhead
100% RunwiseFX-compatible
💡 Why fastest: Only the critical logic is calculated, with minimal code per bar and near-zero memory waste — optimized for 100k+ combinations and 128-thread servers
EXTRA: (SEE SCREENSHOT)
PLEASE NOTE THAT VERSION 4 and 5
I want an extra version with different price scale
So 1 version 4. with old scale
1 version with new scale
Same for version 5