Hi there,
I have an EA that determines trend and at certain points, it draws a row of dots above (short) or below (long) pullbacks in the trend. At the close of each bar, if the trend is maintained, another dot is added to the end of the row of dots at the last price level. If there is a subsequent pullback in the same direction of the trend, the line of dots are moved up below the higher high, or above, the lower low. Pretty standard stuff.
However (and there's always a "but" ...), whilst this works most of the time, occasionally, I get what I can only describe as "orphaned" dots. If I remove the EA, the "known" dots are removed, leaving the orphans behind. There are only two ways of adding dots and they are public methods on the CDotManager. Each dot is a CDot instance which creates and wraps the dot screen object. I have looked for days to see why this might be happening but right now, I'm out of ideas. I've included the sources for the Manager and Dot instance classes. If anyone could take a look at this code or might have a general idea of what could be causing these "orphans", I greatly appreciate it! :)
I would derive from CChartObjectsArrow and implement a static int to create a unique id for the object name.
class CDot : public CChartObjectArrow { static int s_instances; int m_instance; public: CDot(){ m_instance = ++s_instances;} bool Create(datetime time,double price) { string name = "__dot_"+string(m_instance)+"__"; if(!CChartObjectArrow::Create(0,name,0,time,price,(char)159)) return false; } }; int CDot::s_instances=0;
I would derive from CChartObjectsArrow and implement a static int to create a unique id for the object name.
Hi @nicholishen - thanks for your comments and code sample. Are you thinking that it's possibly the naming of the arrows that are contributing to the issue I'm seeing?
Hi @nicholishen - thanks for your comments and code sample. Are you thinking that it's possibly the naming of the arrows that are contributing to the issue I'm seeing?
Not sure. I just know that MQL has already implemented the proper chart object handling in the std lib, so no need to reinvent the wheel....
Not sure. I just know that MQL has already implemented the proper chart object handling in the std lib, so no need to reinvent the wheel....
Hey @nicholishen - updated my code with the suggestions and so far so good. You are absolutely right - I've been able to remove quite a bit of code that just isn't needed now. Feels cleaner and more precise. Fingers crossed! :)
Thanks again.
Not sure. I just know that MQL has already implemented the proper chart object handling in the std lib, so no need to reinvent the wheel....
Hi @nicholishen - just an update to say that I managed to sort the problem. The new uniquely named dot objects didn't actually fix the problem but they allowed me to solve it. There was a bug in my code that was printing one dot too many on each iteration of a new bar loop. Because it was printing dots in the same places, it was using the same names down to my original naming structure. I got the same issue with the new style dots but, they all disappeared when the collection cleared, instead of leaving "orphans". Knowing this, I was able to track the error in my code. All good now! :)
Thanks again. --G
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
I have an EA that determines trend and at certain points, it draws a row of dots above (short) or below (long) pullbacks in the trend. At the close of each bar, if the trend is maintained, another dot is added to the end of the row of dots at the last price level. If there is a subsequent pullback in the same direction of the trend, the line of dots are moved up below the higher high, or above, the lower low. Pretty standard stuff.
However (and there's always a "but" ...), whilst this works most of the time, occasionally, I get what I can only describe as "orphaned" dots. If I remove the EA, the "known" dots are removed, leaving the orphans behind. There are only two ways of adding dots and they are public methods on the CDotManager. Each dot is a CDot instance which creates and wraps the dot screen object. I have looked for days to see why this might be happening but right now, I'm out of ideas. I've included the sources for the Manager and Dot instance classes. If anyone could take a look at this code or might have a general idea of what could be causing these "orphans", I greatly appreciate it! :)