Unisciti alla nostra fan page
- Visualizzazioni:
- 65
- Pubblicato:
-
Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance
EMA Cross Demo EA (MetaTrader 5)
A small, clearly-structured demo Expert Advisor built to show a reliable EA development method, not a trading edge.
Logic (evaluated once per new bar, on CLOSED bars only - no repainting):
- BUY signal: fast EMA crosses above slow EMA
- SELL signal: fast EMA crosses below slow EMA
- On an opposite signal the open position is closed and the new one opened on the next tick of the new bar
Risk handling:
- Stop-loss = entry minus/plus ATR x InpSLATRMult
- Take-profit = stop distance x InpRewardRisk
- Stop/TP levels are pushed out to the broker's minimum stop distance where needed
- Lot size is normalized to the symbol's volume step, min and max
- Entries are skipped when spread is wider than InpMaxSpreadPoints
Works on both hedging and netting accounts (position lookup is done by magic number and symbol, not by netted position type).
Inputs: fast/slow EMA period, ATR period, SL ATR multiplier, reward:risk, lot size, max spread in points, magic number, slippage in points.
This is a deliverable example meant to show structure and method: closed-bar signals, a spread filter, lot normalization, and hedging/netting-safe position handling. It is not a trading recommendation. The attached equity chart is from a synthetic price series used only to exercise the code (gross P/L is positive, net P/L after commission is negative on this synthetic run) - it demonstrates the backtesting approach, not a profitable strategy.
A Python reference implementation of the same signal and backtest logic (for parity testing) is available on request.
Update: fixed a stop-distance issue where the ATR-based SL/TP could sit inside the broker's minimum stop distance on fast timeframes, causing order rejections. The distance is now floored at the stops/freeze level and checked against the correct closing-side price (Bid for a BUY, Ask for a SELL) instead of the entry price.
Update 2: the EA now checks available margin with OrderCalcMargin() before sending an order, and skips (with a log line) instead of sending an order the account cannot afford. This avoids broker-level "not enough money" rejections on very small test balances.

Session TWAP: time weighted average price from the cash open, with deviation bands
Time weighted average price of the running session, anchored at the cash open of Frankfurt, London, New York or Tokyo with automatic daylight saving. Every second counts the same, minutes without a tick carry the last price, and two bands show the time weighted standard deviation around the line.
PropSpread: time-weighted spread monitor with ATR context, alert and CSV log
Panel that samples the spread once per second and shows it in points and in the symbol's natural unit (pips on FX, index points on index CFDs), with rolling min/avg/median/max, a session statistic since server midnight, the spread as percent of ATR, a hold-time alert and an optional CSV log. It never sends an order.
ATR Trailing Stop (Pine Script Port)
MQL5 port of a Pine Script ATR trailing-stop indicator: nLoss = ATR-multiple, the stop ratchets under price in an uptrend and over price in a downtrend, and flips (with a buy/sell arrow) when price closes through it. Includes a Python reference port and a parity test that checks both agree with a literal, bar-by-bar transcription of the Pine semantics (na/nz/series history).
Trade Reporter Lite - Telegram trade notifications
Posts your MT5 opens and closes to a Telegram chat: side, symbol, entry, stop and target in pips, lots, and on close the result, pips, R-multiple and time held. Retry queue, restart-safe, never trades. Free version of Trade Reporter Telegram and Discord.