Fix MT5 Indicator “SyncCrosshair”: Multi-chart time-synced scroll/zoom (click-to-align same time)

MQL5 Indicatori

Specifiche

1) Background
I have a custom MT5 indicator: SyncCrosshair.mq5.
It already synchronizes a “crosshair” across multiple charts using Terminal Global Variables (broadcasting time/price).
However, the scroll/zoom synchronization is broken or unstable.

Goal:
Within the same layout / same sync group (charts can be different symbols and different timeframes),
when I interact with any one chart, all other charts should automatically move so they show the same time point
(or the same visible time position) — true time-linked navigation.

2) Current Issues (must be solved)
In the current code:
- On source chart: CHARTEVENT_CHART_CHANGE triggers BroadcastIfNeeded()
- On target chart: ApplyScrollSync() tries to sync via CHART_FIRST_VISIBLE_BAR

Real behavior:
- Not following scroll: dragging or zooming the source chart does not move other charts, or moves them incorrectly.
- Time misalignment: even when targets move, they do not reliably align to the same time point.
- Random “jump far back”: sometimes it jumps to very old history (e.g., 2014), which is clearly wrong.

3) Expected Correct Behavior (core requirements)

A. Click-to-align (MOST IMPORTANT)
When I click once on any chart (or move crosshair with mouse), I define a time t at that cursor position:
- All charts in the same sync group must auto-scroll so they can see the same time t.
- That time t must appear at the same horizontal screen position on every chart
  (e.g., 60% from the left, controlled by AnchorPosition).

B. Drag / Mouse wheel / Keyboard navigation sync
When I operate the “source chart”:
- drag/pan left-right
- mouse wheel zoom (changes visible bars)
- keyboard navigation (Home/End/PageUp/PageDown, etc.)

All “target charts” should sync to the same time window, or at minimum:
- keep the same anchor time aligned to the same AnchorPosition
- keep visible range as close as possible
  (different symbols/timeframes may not match bars exactly, but time alignment must be correct).

4) Constraints (please fix on top of this codebase)
- Communication must remain via Terminal Global Variables (existing g_key_* structure can be reused).
- Do NOT delete/recreate drawing objects frequently; reuse existing objects for the crosshair lines.
- Can add new input parameters if needed, but keep the architecture: OnChartEvent + OnTimer driven.
- Must support different symbols/timeframes:
  for times not exactly available on target chart, must use nearest-bar logic
  (iBarShift exact=false fallback, etc.).

5) Implementation notes (suggestions, not mandatory)
Currently the broadcast contains: t, price, left_time, right_time.
Potential root causes:
- Wrong interpretation of CHART_FIRST_VISIBLE_BAR direction / indexing.
- Converting left_time/right_time to bar shifts is too error-prone across different timeframes.
- CHART_FIRST_VISIBLE_BAR alone may be insufficient; may need:
  - CHART_VISIBLE_BARS
  - anchor_shift -> left_shift calculation
  - or ChartNavigate() if it is more stable
- A stronger “sync protocol” may be required:
  broadcast anchor_time + visible_bars (and/or scale info) so targets can derive their window reliably.

6) Acceptance Tests (delivery must pass)
1) Open 4 charts in the same sync group (different symbols + different timeframes), e.g.:
   EURUSD M15, XAUUSD H1, BTCUSD M5, USDJPY H4.
2) Click any historical point on the source chart (e.g. a day in 2020):
   - all other charts must scroll to show the same time point
   - that time must appear at the same horizontal position (AnchorPosition=60 -> 60% from left).
3) Drag/pan source chart far left into older history:
   - target charts must follow smoothly without drifting/misalignment and without random jumps.
4) Zoom with mouse wheel:
   - target charts should sync zoom / visible bars if possible
     OR at least maintain anchor_time alignment with similar visible range.
5) Must NOT have:
   - jumping to unrelated old history (e.g., 2014)
   - severe jitter / oscillation
   - infinite broadcast loop between charts

7) Materials Provided

- Full source code of SyncCrosshair.mq5 (posted in this thread).

8) Deliverables
- Fixed SyncCrosshair.mq5 source code (compilable).
- Short explanation of what was changed and why the new scroll-sync logic is stable.
- Ideally, a brief description of key parameters (AnchorPosition, SyncMode behavior, etc.).

File:

ZIP
jcbl.zip
3.3 Kb

Con risposta

1
Sviluppatore 1
Valutazioni
(75)
Progetti
110
51%
Arbitraggio
25
28% / 52%
In ritardo
9
8%
In elaborazione
2
Sviluppatore 2
Valutazioni
(16)
Progetti
20
10%
Arbitraggio
8
38% / 38%
In ritardo
3
15%
In elaborazione
3
Sviluppatore 3
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
4
Sviluppatore 4
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
5
Sviluppatore 5
Valutazioni
(64)
Progetti
77
55%
Arbitraggio
4
0% / 50%
In ritardo
1
1%
In elaborazione
Pubblicati: 6 codici
6
Sviluppatore 6
Valutazioni
(4)
Progetti
4
0%
Arbitraggio
0
In ritardo
0
Gratuito
7
Sviluppatore 7
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
8
Sviluppatore 8
Valutazioni
(1)
Progetti
1
0%
Arbitraggio
3
0% / 100%
In ritardo
1
100%
Gratuito
9
Sviluppatore 9
Valutazioni
(265)
Progetti
280
55%
Arbitraggio
0
In ritardo
5
2%
Gratuito
10
Sviluppatore 10
Valutazioni
(1)
Progetti
1
0%
Arbitraggio
0
In ritardo
0
Gratuito
Pubblicati: 1 codice
11
Sviluppatore 11
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
12
Sviluppatore 12
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
13
Sviluppatore 13
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
Ordini simili
I already have a fully developed MT5 Expert Advisor with all required prop firm features, including: Risk management Daily loss & max drawdown limits Spread & slippage filters News filter Trade management system The EA structure is complete. 👉 What I need is a professional developer to replace ONLY the entry logic with a high-quality, rule-based trading strategy. 🚨 STRICT REQUIREMENT (READ CAREFULLY): I am NOT
Trade summary Plugin 200 - 500 USD
We are looking for a Plugin/ Dashboard for our Meta 5 which will act as a Risk Management/ information tool. the system will require to give real time summary of trades and P/L for certain groups
Looking for a Proven Non-Repainting Gold Indicator (XAUUSD) – High Accuracy & Ready-Made Solutions Only 📌 Project Description: I am looking for a high-quality, non-repainting indicator specifically for XAUUSD (Gold) that is already developed and tested. ⚠️ Important: I am NOT looking for a new indicator to be built from scratch. I want an existing, proven system that you have already created and are confident in. 🎯
The Advisor should stop trading if the spread exceeds a selected value. Source code is unavailable. Decompilation may be necessary or any other suggested working solution may be acceptable. Testing should be thorough with proven demonstrable results
Convert Time Range Breakout Indicator to Strategy (Pine Script) I have an existing Time Range Breakout indicator on TradingView. I need a developer to convert it into a fully functional strategy with proper trade execution logic. Strategy Logic: Time Range: Define a specific time range (e.g., 03:00 – 04:30) During this time, the indicator marks the High and Low range Entry Conditions Buy when price touches the range
Hello, I’m looking for an experienced MQL4 developer to build a custom MT4 Expert Advisor based on a Koncorde-style indicator strategy. Here are the main requirements: 🔹 General Overview The EA must be a master EA , running on a single chart and managing multiple currency pairs simultaneously No need to attach EA to each chart Must support a configurable list of symbols 🔹 Indicator Requirement Develop a custom
I want to find a Developer to perform this work and settle payments in this Application. I undertake not to communicate with Applicants anywhere else except this Application, including third-party
Hi guys I’m looking for a coder who’s experienced in one script. The candidate must be familiar with fractals and self similarity. If you can’t code self similarity, please don’t bother contacting me ( respectfully). I just don’t want us to waste each others time. My budget is 100$. If that’s too low for you please, don’t contact me. Only contact me if you can code self similarity and can accept 100$. I will provide
I hope to acquire a profitable and existing expert advisor (EA) from the gold market, with complete source code, to add to our client portfolio. you can WECHAT: Faca7898 Please note EA when adding friends. It should be clarified that this does not require you to formulate or design new strategies. If you already have a verified, consistent, and production-ready EA, I am willing to purchase it immediately and engage
Core Requirements: Platform: MetaTrader 5 (MT5). Symbol: XAUUSD (Gold). Timeframes: M1 and M5 (user selectable). Trading Style: Scalping with controlled risk (not aggressive or high-risk strategies) -> adjustable, even better. Execution: Fast execution, optimized for gold market conditions. Frequence = adjustable, but there should be 10-20 trades per day. Strategy Logic: Use a reliable and conservative strategy

Informazioni sul progetto

Budget
30+ USD

Cliente

(3)
Ordini effettuati16
Numero di arbitraggi0