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

Correlation-Aware Lot Size Calculator - MetaTrader 5용 스크립트

ali rajput
게시자:
Ali Akbar
Ali Akbar
  • MQL5 Developer & Algorithmic Trading Specialist 에  Freelance
  • 파키스탄
  • 1664
Hi, I'm Ali. 24 years old, trading for around 5 years, and developing MQL5/MQL4 tools. I mainly work on automating manual strategies, fixing broken EA logic, and building clean indicators. I care more about clean architecture and proper risk management than over-complicated code. Always down to talk
조회수:
827
평가:
(2)
게시됨:
업데이트됨:
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

Correlation-Aware Lot Size Calculator

I got tired of position size calculators that only look at the trade you're about to open and ignore everything else sitting on your account. If you're already long EURUSD and you open GBPUSD too, most calculators will happily size that second trade using your full risk % again — even though the two pairs move together most of the time and you've basically doubled your bet on the dollar without realizing it.


This script tries to fix that. Before you open a new trade, it:

- Works out the normal risk-based lot size from your balance, risk %, and stop loss in points
- Goes through every position you currently have open, on any symbol
- Calculates the actual correlation between each of those symbols and the one you're about to trade, using real recent price history (not a fixed correlation table that's already outdated by the time someone publishes it)
- Checks direction too — same-direction trades on correlated pairs stack risk, opposite-direction trades on correlated pairs usually offset each other
- Adds up how much risk is already sitting in correlated positions, and shrinks your new lot size if you're close to (or past) a basket risk limit you set yourself

Everything gets printed to the Experts/Journal tab — which positions got flagged, why, and what lot size it recommends instead of your "normal" one.

A few things worth knowing before you use it:

- If a correlated position has no stop loss set, the script can't know its real dollar risk, so it warns you instead of guessing
- Correlation is calculated from the last N bars (you pick the timeframe and how many), so it reflects current market behavior — but it's still a backward-looking number and can shift over time
- This is read-only. It doesn't open, modify, or close anything on your account

Inputs:
- InpTargetSymbol — symbol you're about to trade (leave blank to use the current chart)
- InpNewTradeIsBuy — direction of the new trade
- InpRiskPercent — risk % for the new trade
- InpStopLossPoints — stop loss distance in points
- InpMaxBasketRiskPercent — max combined risk you're willing to carry across correlated positions
- InpCorrelationThreshold — how strong a correlation needs to be before it counts
- InpCorrelationBars / InpCorrelationTimeframe — controls how correlation is measured

I built this after catching myself stacking correlated pairs a few too many times without noticing until the drawdown showed up. If you only ever trade one pair at a time it won't do much for you — but if you run multiple positions across majors/minors together, it should catch things a plain lot calculator won't.

Free to use, modify, and adapt.
Prop Firm Rule Checker Prop Firm Rule Checker

Checks your trade history against common prop-firm challenge rules — profit target, max daily loss, max drawdown, consistency rule, and minimum trading days — with a clear PASS/FAIL report.

GDS Renko Donchian Demo EA GDS Renko Donchian Demo EA

A small educational Expert Advisor showing how a classic Donchian breakout can be applied directly to completed Renko bricks.

Risk-Based Lot Size Calculator Risk-Based Lot Size Calculator

A simple MQL5 script that calculates the correct lot size for a trade based on your account risk percentage and stop loss distance in pips, so every trade risks a consistent, controlled amount of your balance.

Server Time Offset: the three clocks in MQL5 and how timestamps shift on export Server Time Offset: the three clocks in MQL5 and how timestamps shift on export

A datetime in MQL5 is seconds since 1970 - but server time (TimeCurrent, bar times, deal times) is the broker's wall clock stored AS IF it were UTC. Export it to CSV, read it in Python or a spreadsheet with a "seconds since 1970 UTC" parser, and every timestamp shifts by the server's UTC offset. On a UTC-3 broker that is three hours: the daily bar dated 00:00 reads as 21:00 of the previous day, and "yesterday's session" silently becomes "today's, half formed". That happened to a morning report of mine before this script existed. The script prints TimeTradeServer, TimeCurrent, TimeGMT and TimeLocal, the three offsets between them, the tick lag, and this chart's last bar time in server time and in real UTC - then states the rule: export server timestamps as wall-clock text, or export the epoch together with the offset, and never let the consumer apply its own timezone.