EA-149 · Trend Following

ima_expert

This EA trades based on the rate of change of a custom moving average indicator (ima). It opens buy positions when the MA's relative slope exceeds a threshold and sell positions when it drops below a negative threshold, using a fixed stop-loss in ticks and a trailing stop for profitable positions. Lot sizing is dynamically calculated based on account free margin and risk parameters.

Open the interactive view (equity curve, symbol switch)

Key facts

RiskHigh risk
Rating★★☆☆☆
TypeTrading EA
TimeframesM15, H1, H4
IndicatorsCustom MA (ima)
AuthorVladimir M.

Backtest results (H1, about 1 year)

Not backtested yet — this EA could not be converted automatically.

Strategy analysis

The strategy concept is based on capturing trend momentum through the rate of change of a custom moving average indicator (ima). Entry conditions: when no position is open and a new bar forms, the EA calculates the relative rate of change k1=(aIMA[0]-aIMA[1])/|aIMA[1]| from the ima indicator buffer; a buy signal triggers when k1>=k and a sell signal when k1<=-k. Exit conditions are twofold: a trailing stop mechanism that moves the stop loss to maintain a 'take' point distance from current price when the position is profitable and has moved beyond 'take' points, and a loss cutoff that forcefully closes the position when the calculated loss in ticks exceeds the 'drop' threshold. Position sizing dynamically calculates lot size as FreeMargin*r/drop/TickValue, rounds down to the nearest minimum lot step, then iteratively reduces until FreeMarginCheck passes, with additional caps at max_lots and SYMBOL_VOLUME_MAX. Money management uses the risk ratio parameter r to control exposure per trade, but has a critical flaw—positions are opened with zero stop loss price (sl=0 passed to PositionOpen), relying entirely on the OnTick loop to detect and close losing positions, which creates severe risk during disconnections or price gaps.

Strengths

  • Dynamic lot sizing based on account free margin automatically adjusts position size to control risk exposure per trade
  • Trailing stop mechanism locks in profits by moving the stop loss as price moves favorably
  • New bar detection prevents repeated entries on the same bar, reducing overtrading
  • FreeMarginCheck validation adds a safety layer ensuring sufficient margin before opening positions

Weaknesses

  • Positions are opened with zero stop loss (sl=0), relying entirely on OnTick monitoring to close losers—disconnections or price gaps could cause catastrophic losses
  • The loss cutoff uses profit amount divided by tick value rather than actual price distance, which may be inaccurate when tick value fluctuates
  • Signal flags f_buy/f_sell are only cleared by fdrop() after position open, but stale signals could persist across ticks if no new position is opened
  • Depends on a custom indicator 'ima' with no fallback; initialization fails outright if the indicator is missing
  • The 'take' parameter conflates trailing stop distance and take-profit distance, creating confusing logic with no actual TakeProfit price set on orders

Possible improvements

  • Set a real stop loss price on PositionOpen (converting drop to price distance) instead of relying on OnTick loop monitoring, ensuring server-side SL is always active
  • Separate trailing stop distance and take-profit distance into independent parameters and set a proper TakeProfit price on order placement
  • Add a spread filter to avoid opening positions during high-spread periods, improving trade execution quality

Risk assessment

Overall risk: High risk

  • Zero stop loss on position open means no server-side protection—entirely dependent on client-side OnTick monitoring
  • Trailing stop only activates on profitable positions; losing positions have no server-side SL safeguard
  • Signal flags may persist across ticks causing unintended entries

Evaluation scores

Code quality2.0
Strategy logic3.0
Risk management1.0
Robustness2.0
Innovation2.0
Documentation1.0
Overall1.8

Parameters

ParameterDefaultDescription
n5Moving average period
take50Take profit / trailing stop in points
drop1000Stop loss threshold in points
k0.5Signal threshold (MA change rate trigger level)
r0.01Risk ratio (1% of free margin)
max_lots1Maximum lot limit (0 = unlimited)

Similar Trend Following EAs

Backtests are historical simulations and do not guarantee future results. Not financial advice.

Get the weekly Arena report

One email a week: ranking changes, new signals and new research. No spam; unsubscribe any time.