kkb01:
Is there an EA or Script or maybe is it possible to create one where you have two separate MT4 window open with the same symbols but when you switch the charts on one MT4 window the script or EA reads and switches the symbol of the other window automatically.
I hope I am asking my question clear enough.
Thanks in advance for any comments or ideas.
I have no idea if anything like that exists.
But I do know it is very doable, so... with some time on hand, I created this indicator that should do what you want. Just load it into the corresponding charts in different MT4s. It uses a text file, stored in the common data folder, for synchronisation.
//+------------------------------------------------------------------+//| ChartSync.mq4 |//| Copyright 2019, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2019, MetaQuotes Software Corp."#property link "https://www.mql5.com"#property version "1.00"#property strict#property indicator_chart_windowinputstring IDofChartGroup = "Chart Group 1"; inputint SyncInterval = 2; string currSymb = "", newSymb = ""; int currTF = 0, newTF = 0; datetime fPrevLastChanged = 0; //+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit() { EventSetTimer(SyncInterval); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total, constint prev_calculated, constdatetime &time[], constdouble &open[], constdouble &high[], constdouble &low[], constdouble &close[], constlong &tick_volume[], constlong &volume[], constint &spread[]) { return(rates_total); } //+------------------------------------------------------------------+//| ChartEvent function |//+------------------------------------------------------------------+voidOnChartEvent(constint id, constlong &lparam, constdouble &dparam, conststring &sparam) { //--- } //+------------------------------------------------------------------+voidOnTimer() { if (LocalChartChanged() || fPrevLastChanged==0) ChangeRemoteChart(); if (RemoteChartChanged()) ChartSetSymbolPeriod(ChartID(),newSymb,newTF); } bool LocalChartChanged() { bool result = false; if (currSymb!=_Symbol || currTF!=_Period) { if (currSymb!="") result = true; currSymb = _Symbol; currTF = _Period; } return result; } void ChangeRemoteChart() { int fHandle = FileOpen(IDofChartGroup, FILE_WRITE|FILE_CSV|FILE_ANSI|FILE_COMMON); if (fHandle==INVALID_HANDLE) Print ("File ", IDofChartGroup, " cannot be opened for write. Error - ", GetLastError()); else { FileWrite(fHandle,currSymb,currTF); fPrevLastChanged = datetime(FileGetInteger(fHandle,FILE_MODIFY_DATE)); FileClose(fHandle); } } bool RemoteChartChanged() { bool result = false; if (!FileIsExist(IDofChartGroup,FILE_COMMON)) return result; int fHandle = FileOpen(IDofChartGroup, FILE_SHARE_READ|FILE_CSV|FILE_ANSI|FILE_COMMON); if (fHandle==INVALID_HANDLE) { Print ("File ", IDofChartGroup, " cannot be opened for read. Error - ", GetLastError()); return result; } datetime fLastChanged = datetime(FileGetInteger(fHandle,FILE_MODIFY_DATE)); if (fPrevLastChanged!=fLastChanged) { newSymb = FileReadString(fHandle); newTF = int(FileReadString(fHandle)); fPrevLastChanged = fLastChanged; result = true; } FileClose(fHandle); return result; }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Is there an EA or Script or maybe is it possible to create one where you have two separate MT4 window open with the same symbols but when you switch the charts on one MT4 window the script or EA reads and switches the symbol of the other window automatically.
I hope I am asking my question clear enough.
Thanks in advance for any comments or ideas.