Long Short RR Box with Lot Size and Order
- Utilities
-
Kazuma Uezono
MQL5 / MQL4 / Pine Script v6 developer and active trader.
Seller on the MQL5 Market (indicators for MT4/MT5).
Services:
- TradingView Pine Script to MT5/MT4 conversion (bar-by-bar matching, with tester report)
- MT4 to MT5 migration - Version: 1.2
- Activations: 5
This utility Expert Advisor for MetaTrader 5 draws a long/short position tool on your chart, similar to the long and short position drawing tools known from TradingView. You drag the entry, stop loss and take profit lines, and the tool shows the risk/reward ratio, the distance to SL and TP, the money at risk and the lot size that matches the risk you choose. An optional order button sends the planned order with the same SL and TP.
What it is not: it gives no buy or sell signals and makes no trading decisions; it is a planning and order-entry aid. It never opens, changes or closes anything unless you press its order button twice. It only sends its own new orders (with its own magic number) and never touches your existing positions or orders. No profit is promised.
THE TOOL ON THE CHART
- Three lines: entry (gray), stop loss (red) and take profit (green), with a loss box and a profit box. The box colors are mixed with the chart background, so the candles stay visible (opacity adjustable).
- The lines are selected from the start, so you can grab and drag them at once without a double-click. Drag the middle of the entry line to move the whole tool; drag the middle of the SL or TP line to change that price; drag the end of a line to change that price and the box width.
- The Long > Short button flips the direction. Up to 3 tools per chart (buttons 1, 2, 3 on the panel), each with its own risk value.
- Labels on the chart: direction, lot, prices, distance, money at risk and profit at TP (can be turned off).
- Size of a new tool: SL distance = ATR(14) of the chart, or a fixed number of pips; TP distance = SL distance x the default R:R (2.0).
PANEL
- Order type and price, lot, R:R, risk in account currency and % of balance, SL and TP prices with distance and money.
- Distance: pips on FX symbols, price difference on other symbols (gold, indices, crypto and so on).
- Risk field: type a new value for the selected tool.
- Buttons: Long/Short, Order, New, Reset (to the current price), Delete, collapse. English or Japanese (automatic from the terminal language, or chosen).
HOW THE LOT IS CALCULATED
- Risk mode: % of balance (default 1%), % of equity, or a fixed amount in account currency.
- Lot = risk money / loss of 1 lot from the entry to the SL, rounded DOWN to the lot step of the symbol, then limited to the broker maximum and your Maximum lot.
- It is never rounded up to the minimum lot. If even the minimum lot would risk more than your setting, the panel shows "risk too small" with the money of one minimum lot, and no order can be sent.
- The loss of 1 lot is converted to the account currency, also for metals, index CFDs and crypto CFDs. If a symbol cannot be converted, the panel says so and shows no lot.
- Because of rounding down, the money shown is usually a little below your setting. The % shown is always relative to the balance, also in equity mode.
ORDER BUTTON (two clicks)
- The first click only arms the button ("Click again: ..."). A second click within 3 seconds (adjustable) sends the order; after that the arming expires.
- The order type is chosen from the entry line and the current price: a market order if the entry is within 2 spreads (adjustable) of the price, otherwise a limit or stop order. SL and TP are the tool's lines.
- Checks before sending: SL and TP on the correct side, SL at least 3x the current spread, broker stop and freeze levels, lot limits, free margin, trading session, Algo Trading allowed. If it does not send, the panel shows the reason.
- If the server does not answer, the tool looks at the orders and positions for 15 seconds and tells you whether the order was accepted. Do not click again during this time.
- Orders carry magic number 20261110 (adjustable) and the comment "PositionTool #1" (#2, #3). Pending orders are GTC when the symbol allows it, otherwise day orders.
SAVED POSITION
- The tools stay where you left them after a timeframe change, a restart of the terminal or the computer, and a forced shutdown of the terminal (tested).
- If you apply a template to a chart of another symbol, the old prices are not used: the tool is created again at the price of the new symbol.
- "Create tool #1 when attached" works only the first time the EA runs on that chart, so a tool you deleted does not come back after a timeframe change or a restart.
MEASURED IN OUR TESTS (demo account, account currency JPY)
- On 9 symbols (FX pairs and CFDs), the actual loss at the SL divided by the risk money set was 0.98 to 1.02.
- Lines dragged with the real mouse, two-click orders opened with the tool's SL and TP, tools restored after a forced shutdown.
Your results depend on your broker, the symbol specifications and the market.
LIMITS YOU SHOULD KNOW BEFORE BUYING
- Delete key: the tool's lines are always selected, so pressing Delete to remove one of your own drawings also deletes them. The first time, the tool redraws its lines and shows "To delete Position Tool press 'Delete' on the panel". If you press Delete again within 15 seconds, the tool and its saved data are deleted. To remove a tool, use Delete on the panel.
- The lot shown after the first click can differ from the lot that is sent. For a market order the lot is calculated again with the price at the moment of the second click; the risk money stays as set.
- The actual loss at the SL can differ from the risk by a few % because of slippage, gaps, spread changes and lot steps. A stop loss is not guaranteed to fill at its price.
- Commission and swap are not included in the risk money.
- For a market order the entry is the current price, so R:R and distances can change slightly from the drawn entry.
- The tool works on the chart symbol only. To plan another symbol, attach the EA to a chart of that symbol.
- To send orders, Algo Trading must be ON (toolbar button) and allowed in the EA settings. With it off, the tool still draws and calculates.
- Strategy Tester: clicks cannot be simulated there, so the EA runs a demonstration. It places the tool and sends minimum-lot market orders, long and short in turn, every 24 bars when it has no position. If even the minimum lot would risk more than half of the equity (small deposit), no demo order is sent and the report shows 0 trades. Demo trades are not a trading result.
- Tested on hedging demo accounts. Netting accounts have not been tested.
SETUP
1. Attach the EA to a chart of the symbol you want to plan. Tool #1 appears at the current price.
2. Set the risk in the inputs or type it in the panel, then drag the lines.
3. To send the order: turn on Algo Trading, click the order button, check the panel, and click again within 3 seconds. Try everything on a demo account first.
INPUTS (28)
- Risk and lot: risk mode, risk value, maximum lot, points per pip.
- New tool: direction, default SL in pips (0 = ATR), default R:R, box width in bars, number of tools (1-3), create tool #1 when attached.
- Order button: show, seconds for the second click, market zone in spreads, magic number, slippage, comment.
- Display: language, panel corner, X/Y offset, font size, profit/loss/entry colors, box opacity, chart labels.
- Strategy Tester: demonstration on/off, demonstration interval.
IMPORTANT
- What to trade, where to place SL and TP and how much to risk are your decisions. The tool does not tell you when or what to trade.
- TradingView is a trademark of TradingView, Inc. This product is not affiliated with, endorsed or sponsored by TradingView.
- Support through MQL5 messages, reply within 3 business days: installation, settings and bug reports. Questions about what to trade, where to place SL/TP or how much to risk cannot be answered.
