Bugs
- SYMBOL_TRADE_STOPS_LEVEL used as a constant — it's an enum identifier for SymbolInfoInteger , not a value. You need SymbolInfoInteger(Symbol(), SYMBOL_TRADE_STOPS_LEVEL) .
- ChartSetInteger(0, CHART_COLOR_GRID, false) — false is 0 which sets the grid to black (invisible on black background, but not "no grid"). To hide the grid, use CHART_SHOW_GRID : ChartSetInteger(0, CHART_SHOW_GRID, false) .
- Range box never updates its time anchors — when the range is still forming, rangeHigh / rangeLow change but the rectangle's time coordinates are only set at creation. The else branch updates prices but not times, so if the object was created with stale price corners the first tick, it stays malformed.
- int d = 0; unused variable inside OnTick.
- No symbol filter on position close — PositionClose at end-of-day closes ALL positions on the account, not just this EA's/symbol's. Add if(pos.Symbol() == Symbol()) .
- No magic number — multiple EAs on the same account will conflict. Use trade.SetExpertMagicNumber() and filter positions by magic.
- SL/TP validation is one-sided — for Buy you check ask - rangeLow > stops_level but don't check tp - ask > stops_level . Same gap on the Sell side for TP distance.
- minLot initialized at global scope — SymbolInfoDouble may not return valid data before OnInit . Move it inside OnInit .
Improvements
- Add an input for magic number and lot size.
- Filter positions by magic + symbol on close.
- Add spread filter — if spread is wider than X% of range, skip the trade.
- The range is recalculated every tick even after it's finalized (after RangeTimeEnd ). Cache it once.
- Typo: TrandingEndTime → TradingEndTime .
Ivan Privalov #:
Thanks for the feedback, I'll add them ASAP.
Bugs
- SYMBOL_TRADE_STOPS_LEVEL used as a constant — it's an enum identifier for SymbolInfoInteger , not a value. You need SymbolInfoInteger(Symbol(), SYMBOL_TRADE_STOPS_LEVEL) .
- ChartSetInteger(0, CHART_COLOR_GRID, false) — false is 0 which sets the grid to black (invisible on black background, but not "no grid"). To hide the grid, use CHART_SHOW_GRID : ChartSetInteger(0, CHART_SHOW_GRID, false) .
- Range box never updates its time anchors — when the range is still forming, rangeHigh / rangeLow change but the rectangle's time coordinates are only set at creation. The else branch updates prices but not times, so if the object was created with stale price corners the first tick, it stays malformed.
- int d = 0; unused variable inside OnTick.
- No symbol filter on position close — PositionClose at end-of-day closes ALL positions on the account, not just this EA's/symbol's. Add if(pos.Symbol() == Symbol()) .
- No magic number — multiple EAs on the same account will conflict. Use trade.SetExpertMagicNumber() and filter positions by magic.
- SL/TP validation is one-sided — for Buy you check ask - rangeLow > stops_level but don't check tp - ask > stops_level . Same gap on the Sell side for TP distance.
- minLot initialized at global scope — SymbolInfoDouble may not return valid data before OnInit . Move it inside OnInit .
Improvements
- Add an input for magic number and lot size.
- Filter positions by magic + symbol on close.
- Add spread filter — if spread is wider than X% of range, skip the trade.
- The range is recalculated every tick even after it's finalized (after RangeTimeEnd ). Cache it once.
- Typo: TrandingEndTime → TradingEndTime .
Sow how to play metatrader 5 using demo
Metaquotes provides a free Beta MT5 platform, free demo accounts, and free demo price feeds:
Download the MetaTrader 5 trading platform for free
- www.metatrader5.com
MetaTrader 5 offers a wide variety of functions for the modern forex and exchange market trader: Full set of trading orders for flexible Forex, Stocks and other securities trading Two position accounting systems: netting and hedging Unlimited amount of charts with 21 timeframes and one-minute history of quotes; Technical analysis with over 80...
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Easy Range Breakout EA - MT5:
This EA implements a range breakout trading strategy. It calculates a price range between start and end times defined by the user, draws a visual rectangle on the chart to mark the high and low of that range, and then monitors price action after the range closes. If the market breaks above the range high, it opens a buy trade; if it breaks below the range low, it opens a sell trade.
Author: Osmar Sandoval Espinosa