거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
Experts

Risk Lot Line: lot size from a draggable stop loss - MetaTrader 5용 expert

Bayram Erhan Partal
Bayram Erhan Partal
  • MQL5 / MQL4 Developer 에  MQL5 Freelance
  • 터키
  • 248
MQL5 / MQL4 developer: Expert Advisors, indicators, Pine Script to MT5.
I deliver code that matches your specification, and I show the proof.
With every job you get
- Source code (.mq5/.mq4) and the compiled file, inputs named as in your spec
조회수:
92
게시됨:
RiskLotLine.mq5 (10.26 KB) 조회
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

A common way to size a position is risk divided by stop distance times tick value. On forex majors that usually works. On some brokers' metal and index CFDs, or on symbols quoted in a currency other than your account currency, the reported tick value can be stale or set for a different contract, and the lot comes out wrong without any warning.

This utility asks the trade server instead. It calls OrderCalcProfit for one lot from your entry to your stop, so contract size, quote currency and account currency are all handled by the same function the terminal uses for real orders. Then it divides your risk by that loss and rounds down to the symbol's volume step.


XAUUSD H1: 100 USD risk, stop 1678 points away, 0.05 lots, take profit at 2R

How to use it

Attach it to a chart. A red line appears below the price: that is your stop. Drag it. Below the price means a buy (entry at Ask), above means a sell (entry at Bid). The panel updates while you drag and on every tick.

What the panel shows

  • Direction, entry and stop price, and the distance in points
  • Lots: the largest size that stays within your risk, rounded down to the volume step
  • At risk: the money you really lose at the stop with that rounded size, which is usually a little less than what you asked for
  • Loss per 1 lot from entry to stop, so you can check the number yourself
  • Margin for that size from OrderCalcMargin
  • Take profit at your R multiple, drawn as a dashed green line, with the money it would make

If even the minimum lot risks more than you asked, the size and the risk turn orange and the panel says so.

Input parameters

  • Risk is measured as: % of balance, % of equity, or a fixed amount in the account currency.
  • Risk: the percent or the amount.
  • Take-profit at R multiple: 2 means the target is twice the stop distance. 0 hides it.
  • First SL distance: where the line starts, in % of the price.
  • Colours, panel corner, font size: for dark and light charts.

Notes

It is an Expert Advisor only because MetaTrader 5 does not allow OrderCalcProfit inside indicators (error 4014). It never opens, changes or closes a trade. It runs on demo and live accounts; on a chart that already has an EA, open a second chart of the same symbol. Spread and commission are not part of the loss at the stop. Removing it deletes its objects; changing the timeframe or the inputs keeps your stop line where you left it.


Import Ticks CSV - a tick file into a custom symbol for real-tick tests Import Ticks CSV - a tick file into a custom symbol for real-tick tests

A script that reads a tick CSV into a custom symbol and builds its M1 bars, so the Strategy Tester can run "Every tick based on real ticks" over a period the broker's server does not keep. It finds the columns by name and moves UTC times to server time.

Tick Depth Probe - how far back your broker keeps real ticks Tick Depth Probe - how far back your broker keeps real ticks

A script that shows how far back your broker's server keeps real ticks for a symbol. It samples a few short windows over the last four years, asks for each one until its ticks arrive or the time is up, and prints the oldest one that has ticks.

Safe Pyramiding - add to winning trades only when they are risk free Safe Pyramiding - add to winning trades only when they are risk free

Decides if you can add to a running winner: only when all open trades in that direction are on break-even and the newest one is in profit. The open risk is never more than one add. Hedging accounts only.

EzoO Candle Timer - time left on the candle, live spread and today's range EzoO Candle Timer - time left on the candle, live spread and today's range

Shows the time left on the current candle, the live spread and today's range next to the price or in a chart corner. Works on every timeframe.