I am looking to synchronize support and resistance levels on different timeframes, i.e. support added on one time frame appears on all the other timeframe charts
Hello,
How you have added resistance levels on chart? Like horizontal line or rectangle box?
Is there a way to choose to clone only certain types of objects and ignore the rest? Also, how would I clone the objects visibility properties as well because it seems the the cloned objects visibility setting is not copied over and must be manually set again on the other charts.
Many thanks
Is there a way to choose to clone only certain types of objects and ignore the rest? Also, how would I clone the objects visibility properties as well because it seems the the cloned objects visibility setting is not copied over and must be manually set again on the other charts.
Many thanks
Hello, yousurfer.
If you want select objects by some of property you can add it in this function
string CCopyObject::CreateMessage(long chart) { string result = NULL; int total = ObjectsTotal(chart, 0); for(int i=0;i<total;i++) { string name = ObjectName(chart, i, 0); // // if(!( check object property to copy) ) // if you don't want to copy this object // continue; // go to next object // switch((ENUM_OBJECT)ObjectGetInteger(chart,name,OBJPROP_TYPE)) { case OBJ_HLINE: result+="{NAME="+name+"|TYPE="+IntegerToString(OBJ_HLINE)+"|"+HLineToString(chart, name)+"}"; break; case OBJ_VLINE: result+="{NAME="+name+"|TYPE="+IntegerToString(OBJ_VLINE)+"|"+VLineToString(chart, name)+"}"; break; case OBJ_TREND: result+="{NAME="+name+"|TYPE="+IntegerToString(OBJ_TREND)+"|"+TrendToString(chart, name)+"}"; break; case OBJ_RECTANGLE: result+="{NAME="+name+"|TYPE="+IntegerToString(OBJ_RECTANGLE)+"|"+RectangleToString(chart, name)+"}"; break; } } return result; }
Regards,
Dmitriy.
With 8 open charts of one instrument with different TF, the indicator slows down noticeably and hangs MT, for example, a freshly drawn square comes to other charts with a 5-10 second delay. What can be the reason?
Thanks!
Could you make one for MT4? Preferably with a filter on objects (clone only horizontal or trend...) There is a similar one for MT4, but the code is closed, the filter cannot be added.
To use it on MT4 it is enough to change the indicator file extension from mq5 to mq4 and recompile the indicator.
To add filtering of objects you need to add the parameters
sinput bool CloneHLine = true; sinput bool CloneVLine = true; sinput bool CloneTrend = true; sinput bool CloneRectangle = true;
and correct OnChartEvent with the addition of the CheckToClone function.
//+------------------------------------------------------------------+ //| ChartEvent function| //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- string message1=NULL; string message2=NULL; int total=0; //--- switch(id) { case CHARTEVENT_OBJECT_CHANGE: case CHARTEVENT_OBJECT_CREATE: case CHARTEVENT_OBJECT_DRAG: if(!CheckToClone(sparam)) return; message1=CloneObjects.CreateMessage(l_Chart,sparam,0); message2=CloneObjects.CreateMessage(l_Chart,sparam,1); total=ArraySize(ar_Charts); for(int i=0;i<total;i++) { EventChartCustom(ar_Charts[i],(ushort)id,0,0,message1); EventChartCustom(ar_Charts[i],(ushort)id,0,0,message2); } break; //--- case CHARTEVENT_OBJECT_DELETE: if(!CheckToClone(sparam)) return; total=ArraySize(ar_Charts); for(int i=0;i<total;i++) EventChartCustom(ar_Charts[i],(ushort)id,0,0,sparam); break; //--- case CHARTEVENT_CUSTOM + CHARTEVENT_OBJECT_CHANGE: case CHARTEVENT_CUSTOM + CHARTEVENT_OBJECT_CREATE: case CHARTEVENT_CUSTOM + CHARTEVENT_OBJECT_DRAG: CloneObjects.DrawObjects(l_Chart,sparam); ChartRedraw(l_Chart); break; //--- case CHARTEVENT_CUSTOM + CHARTEVENT_OBJECT_DELETE: if(!CheckToClone(sparam)) return; ObjectDelete(l_Chart,sparam); ChartRedraw(l_Chart); break; } } //+------------------------------------------------------------------+ //|| //+------------------------------------------------------------------+ bool CheckToClone(string name) { bool result = false; if(l_Chart>=0 && ObjectFind(l_Chart,name)==0) { switch((ENUM_OBJECT)ObjectGetInteger(l_Chart,name,OBJPROP_TYPE)) { case OBJ_HLINE: result=CloneHLine; break; case OBJ_VLINE: result=CloneVLine; break; case OBJ_TREND: result=CloneTrend; break; case OBJ_RECTANGLE: result=CloneRectangle; break; } } return result; }
With 8 open charts of one instrument with different TF, the indicator slows down noticeably and hangs MT, for example, a freshly drawn square comes to other charts with a 5-10 second delay. What can be the reason?
Thank you!
Good afternoon.
The point is that indicators work in one thread and a large number of any indicators in the terminal can really slow down its work. Moreover, working with graphical elements is quite labour-intensive for the terminal. For use on a large number of charts, I would recommend reformatting the programme into an Expert Advisor without any loss of functionality. But it will work only if you do not use Expert Advisors at the same time with analysis. Because the terminal has a restriction of no more than one Expert Advisor per one chart.
To use it on MT4, just change the indicator file extension from mq5 to mq4 and recompile the indicator.
Thank you for your quick reply and help. ChartIndicatorGet, CloneAllObjects and other functions are not supported in mq4. In general, 9 errors during compilation. I am zero in programming. Please help me.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article Synchronizing several same-symbol charts on different timeframes has been published:
When making trading decisions, we often have to analyze charts on several timeframes. At the same time, these charts often contain graphical objects. Applying the same objects to all charts is inconvenient. In this article, I propose to automate cloning of objects to be displayed on charts.
The indicator operation can be divided into two blocks.
Author: Dmitriy Gizlyk