Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Indicators

Trade Cost Meter - indicator for MetaTrader 5

Views:
13
Published:
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Every trade pays the spread and often a commission. On a daily chart this is nothing, but on low timeframes the stop is small, and the same costs can take a large part of the risk of every trade. A strategy that looks fine before costs can lose money after them. This indicator shows the numbers for the current symbol directly on the chart.

It measures the spread (now, average and maximum over the last ticks), adds the commission you enter, shows the swap for one night and the day of the triple swap, and calculates the cost of a round trip for 1 lot. Then, for every timeframe from M1 to D1, it compares this cost with a typical stop of N x ATR and shows which share of the risk (R) the costs take.

Trade Cost Meter on XAUUSD H1

How to read it

  • Green: costs take less than 3% of R (by default). The timeframe is cheap to trade.
  • Orange: between 3% and 10% of R. Costs are noticeable; the strategy needs a real edge to pay them.
  • Red: more than 10% of R. A large part of every trade goes to the broker.

Example from the picture (XAUUSD, demo account, spread 0.15): with a stop of 1.5 ATR the costs take 6.2% of R on M1, 2.4% on M5 and only 0.5% on H1. On a wider spread or with a commission the numbers on low timeframes grow quickly.

Input parameters

  • Commission per 1 lot per side, in account currency (0 if your account has no commission). Brokers show it in the account conditions.
  • Stop distance, x ATR (default 1.5) and ATR period (default 14): the typical stop used for the estimate.
  • Ticks for the average and maximum spread (default 5000).
  • Red and green thresholds in % of R.
  • Panel corner.

Notes

  • Spread and swap are converted to money with the symbol's tick value, so the panel works for Forex, metals, indices and CFDs. Swaps in interest modes are shown as an approximation.
  • Comparing two account types of the same broker (with and without commission) is a typical use: enter the commission and look at the round-trip cost.
  • The panel refreshes every 5 seconds, also when there are no ticks. The indicator does not trade.
LotFromRisk: position size from risk, stop and commission LotFromRisk: position size from risk, stop and commission

An include file for calculating the size of a position to be opened. It turns a risk figure (percent of the balance, percent of the equity or money), a stop and a commission per lot into a lot size whose loss at the stop never goes over that risk. The lot is always rounded down to the volume step and a risk below the minimum volume returns 0 lots with a reason.

Dashboard Panel Dashboard Panel

A clean information card for your EA or indicator: rows, progress bars and a status pill on one anti-aliased CCanvas bitmap, light or dark to match the chart, and foldable with a click.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.