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

ATS Trade Management Library - break-even, trailing stop and partial closes for any EA - MetaTrader 5용 라이브러리

조회수:
160
평가:
(1)
게시됨:
업데이트됨:
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

A small include file that looks after the positions an EA, a trader or another EA has already opened. It only moves stops and closes part or all of a position. It never opens a trade.

What it does

  • Break-even: moves the stop to the entry (plus an offset) once the position is far enough in profit. The trigger is set in R (multiples of the initial stop), in ATR or in points.
  • Trailing stop: a fixed distance behind the price, or behind the lowest low / highest high of the last N closed candles on the timeframe you choose. The stop only moves in your favour, in steps you set.
  • Two partial closes: a share of the position at the first level, a share of the ORIGINAL position at the second, with an optional move to break-even after the first. The lot of a partial close is floored to the volume step and never leaves less than the minimum lot.
  • A stop and a target for positions that have none (for example trades opened from a phone): a stop at ATR multiples or a number of points, a target at a number of R.
  • Every symbol or one symbol, every magic number or a list (0 = trades opened by hand).

How it works

  • "R" is the distance between the entry and the stop the position had when the library first saw it. A position without a stop has no R: the rules set in R skip it, so use ATR or points (or the automatic stop) for those.
  • What was already done on a position (break-even moved, partial closes made) is saved in GlobalVariables, so a restart of the terminal does not repeat it.
  • Stops that are closer to the price than the broker's stop level are not sent; the library tries again on the next pass.
  • The calculations are plain functions with no terminal data, so they can be tested with fixed numbers: the included self-test runs 36 checks.

Use

#include "ATS_TradeMgmtLib.mqh"
CAtsTradeMgmt mgmt;
SAtsMgmtConfig cfg;  mgmt.DefaultConfig(cfg);
cfg.useBreakEven = true;  cfg.beUnit = ATS_UNIT_R;  cfg.beTrigger = 1.0;
cfg.trailMode = ATS_TRAIL_CANDLES;  cfg.trailBars = 3;  cfg.trailStart = 1.5;
mgmt.Init(cfg, "", "");           // every symbol, every magic number
// in OnTimer(): mgmt.ManageAll();

The package: ATS_TradeMgmtLib.mqh (the library), ATS_TradeMgmt_Demo.mq5 (an example EA, a trade manager in a few lines), ATS_TradeMgmt_SelfTest.mq5 (36 checks of the calculations, run it as a script).

Good to know

  • It does not give signals and promises no result. A stop can be filled at a worse price in a fast market, as with any stop.
  • The terminal and the EA must be running when the price moves.
  • Tested in the Strategy Tester (positions opened every day, break-even, both partial closes, trailing stop and the automatic stop and target all acted as expected) and on a demo account, on hedging accounts. It works on netting accounts too: partial closes act on the position.

Session Reality Auditor Session Reality Auditor

Checks the broker's session table against the M1 history. For every minute of the week it counts on how many of the last N days the symbol really has a bar, and sets that next to SymbolInfoSessionQuote and SymbolInfoSessionTrade: declared minutes that are usually empty (rollover holes), bars in minutes the table calls closed, trade and quote tables that disagree, and one-off outages such as an early holiday close. Prints the real sessions per weekday, writes every finding to CSV and prints its own arithmetic. Read only: no trade function, no DLL, no network.

Advanced Prop-firm Trade Panel based on S-R Advanced Prop-firm Trade Panel based on S-R

A manual trading panel with a built-in prop-firm risk guard and a hidden Support/Resistance finder for MetaTrader 5.

CajasTF – Integrated Multi-Timeframe Side Panel for MT5 CajasTF – Integrated Multi-Timeframe Side Panel for MT5

Real-time multi-timeframe side panel mini-chart with smart color matching, independent price scale, and candle countdown timer.

Session Levels - Asian range, PDH/PDL, VWAP, swings and round numbers Session Levels - Asian range, PDH/PDL, VWAP, swings and round numbers

Session Levels draws the reference levels intraday traders watch most: Asian range, London and New York sessions, previous day and week high/low, daily VWAP, swing points and round numbers. Hover any level to read what it is and why it matters. Optional alerts when price breaks the Asian range or the previous day high/low.