Chart Line Trader
Planning a trade by dragging lines on the chart is a natural way to work, but turning three arbitrary line positions into a correct order is where it usually goes wrong. This EA reads the Entry, SL and TP lines when Buy or Sell is clicked and decides the order type itself: if Entry sits within a small tolerance of the current price it fires a market order; if Entry sits beyond price in the trade's favour it becomes a stop order; if it sits between price and the stop-loss side it becomes a limit order. The trader never has to remember which of BuyStop, BuyLimit, SellStop or SellLimit applies to a given line arrangement. The stop loss line is validated before anything is sent. If it is on the wrong side of Entry - above it for a Buy, below it for a Sell - the order is refused with a plain on-chart message rather than sent to the broker, who would reject it for a reason the trader cannot see from here, or worse, in a moment of confusion accepted the way you didn't mean. A take-profit line on the wrong side is treated differently: since giving up a target is not the kind of mistake that loses money, it is simply dropped rather than blocking the trade. Position size can come from a fixed lot input or a risk percentage of balance, sized off the actual price distance between the Entry and SL lines using tick value - not a Point-distance shortcut, which is silently wrong on JPY crosses, metals and indices. Notes and limitations - The SL and TP lines are shared by both directions. If you last set them up for a Buy and then click Sell without repositioning them, validation will very likely refuse the SL line (wrong side) rather than fire an inverted trade. - Line positions are only checked at the moment a button is clicked, not continuously while dragging - dragging a line into an invalid spot is not flagged until you click Buy or Sell. - A pending order whose Entry line is closer to price than the broker's stop level is refused; move the line further out or use the market band instead. - This EA only opens positions. It has no close, trail or breakeven function - pair it with a separate management EA if you want one. - On MQL5 netting accounts, an order from this panel can merge into an existing position on the same symbol - see MQL4 VERSUS MQL5 DIFFERENCES above.
Expert advisor · MT4 · v1.0 · Free
About Chart Line Trader
Chart Line Trader is an expert advisor (trading robot) for MetaTrader 4. It places pending buy/sell stop or limit orders and can size trades from your balance and risk percent. It has 14 settings, such as Fixed lots, Risk percent and Magic number. MQL source code included.
Files in the download: ChartLineTrader.ex4, ChartLineTrader.mq4, ChartLineTrader.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Fixed lots | 0.10 | Fixed lot size (used when risk % is 0) |
| Risk percent | 0.0 | Risk % of balance per trade, sized off the SL line distance (0 = use fixed lots) |
| Magic number | 20260103 | Magic number for orders opened from this panel |
| Slippage pips | 3 | Slippage tolerance for market orders, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Market tolerance pips | 2 | Entry line within this many pips of price counts as "at market" |
| Default stop pips | 20 | Initial SL line distance from price when the panel is created/reset |
| Default target pips | 40 | Initial TP line distance from price when the panel is created/reset |
| Color entry | clrDodgerBlue | Entry line colour |
| Color sl | clrTomato | Stop loss line colour |
| Color tp | clrLimeGreen | Take profit line colour |
| Panel x | 10 | Button panel X offset, pixels from corner |
| Panel y | 20 | Button panel Y offset, pixels from corner |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Pending Orders · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code