Draw objects dictated by dynamic external source on one timeframe while viewing another timeframe?

 

I have a csv file with dynamically changing information in it.  I have an indicator that reads the file and converts the data into parameters to draw objects. While I initially had separate market windows open with each different time frame of interest, this became inconvenient as more markets were added over time.  I have tried to use only one window per market but even when I filter the objects to only appear on a specific timeframe, the objects in question are not actually being drawn unless the target timeframe is the active timeframe.


Take for example the EURUSD market.  I have the EURUSDM15 chart open and the indicator is attached.  Is it possible for me to draw an object that only displays on the M30 timeframe of that market chart all while keeping focus on the M15?  Keep in mind that said objects are only to be displayed on specific timeframes.. i.e the M30 object should not be visible on any other timeframe.


I am currently using ObjectCreate("ObjName") to create the object and ObjectSet("ObjName",OBJPROP_TIMEFRAMES,) to filter which timeframe the object should be visible on.  The timeframe filter works but only if the line drawn is on the active timeframe.  If I am viewing the M15 timeframe and the csv holds data to instruct a draw order to the M30 timeframe, it seems that no object is drawn.  After leaving the chart running for some time, i see all the objects for the active timeframe building up on the chart, but when i switch the timeframe to M30, it is blank, even though there were supposed to be several unique objects drawn to that timeframe during the running time.

Am I missing something or is what I am trying to achieve possible?

 
22Degrees:

I have a csv file with dynamically changing information in it.  I have an indicator that reads the file and converts the data into parameters to draw objects. While I initially had separate market windows open with each different time frame of interest, this became inconvenient as more markets were added over time.  I have tried to use only one window per market but even when I filter the objects to only appear on a specific timeframe, the objects in question are not actually being drawn unless the target timeframe is the active timeframe.


Take for example the EURUSD market.  I have the EURUSDM15 chart open and the indicator is attached.  Is it possible for me to draw an object that only displays on the M30 timeframe of that market chart all while keeping focus on the M15?  Keep in mind that said objects are only to be displayed on specific timeframes.. i.e the M30 object should not be visible on any other timeframe.


I am currently using ObjectCreate("ObjName") to create the object and ObjectSet("ObjName",OBJPROP_TIMEFRAMES,) to filter which timeframe the object should be visible on.  The timeframe filter works but only if the line drawn is on the active timeframe.  If I am viewing the M15 timeframe and the csv holds data to instruct a draw order to the M30 timeframe, it seems that no object is drawn.  After leaving the chart running for some time, i see all the objects for the active timeframe building up on the chart, but when i switch the timeframe to M30, it is blank, even though there were supposed to be several unique objects drawn to that timeframe during the running time.

Am I missing something or is what I am trying to achieve possible?


You do write the code like this right ?

ObjectSet ("Object Name", OBJPROP_TIMEFRAMES, OBJ_PERIOD_M5);

And NOT like this

ObjectSet ("Object Name", OBJPROP_TIMEFRAMES, PERIOD_M5);

How many object you draw on chart and where it's drawn - main chart or sub chart ?

 

Yes I write the code like this:

ObjectSet ("Object Name", OBJPROP_TIMEFRAMES, OBJ_PERIOD_M5);


As I said, the drawing is dynamic, there could be 1 or 2 objects per hour or some hours there can be as many as 8.  When you say main chart or sub chart, what exactly do you mean by sub chart? Currently I have 1 window per market and all markets are maximized. Apologies if I'm not familiar with some terminology.



 
22Degrees:

Yes I write the code like this:


As I said, the drawing is dynamic, there could be 1 or 2 objects per hour or some hours there can be as many as 8.  When you say main chart or sub chart, what exactly do you mean by sub chart? Currently I have 1 window per market and all markets are maximized. Apologies if I'm not familiar with some terminology.




A. Sub chart - or I should say, a separate chart - is a chart like where RSI or MACD or CCI is displayed.

B. There's another user bug report, but I think its different from your case https://www.mql5.com/en/forum/142071

C. Let me get this correctly : you open one chart - say EURUSD 15 minutes - and attach the CI (Custom Indicator) that draw objects on 15 minutes timeframe and 30 minutes timeframe, The objects for 15 minutes timeframe are drawn but when you switch this chart from 15 minutes to 30 minutes timeframe , there are no object for 30 minutes timeframe.

1. Am I correct so far ?

2. Right click that 30 minutes chart and select Object list (or just press Ctrl + B) . Are there any object listed over there ?

3. Does your CI  has some delete object function - like in deinit() or init() ?, and therefore those drawn objects is missing when you switch timeframes.

D. Actually I have several CIs that draw about more than 100 objects one one chart - seriously - some actually reading from .txt file - I hate .csv file. However all those CIs only draw on that current chart timeframe. If I switch timeframe then those CIs would have to draw those object all over again. Can you modify your CI to work like that ?

E. BTW, what build MT4 you using ?. 

 

Ok beg your pardon, yes I am drawing to both main and subs.


C. 1 - Yes correct so far

    2 - When I switch to M30 chart and right click, only the objects with the M15 specific ID are listed.  The same applies when i start with M30 and then switch to M15, only the objects with M30 specific ID are listed

    3 - There are some cleanup delete codes but even though I created them myself and the logic is structured, I disabled all and still no change.


D.  As far as modifying the the CI to reDraw all in the history, this is something I have set in motion but not something that can be accomplished within the indicator itself.  The indicator reads a list of instructions from the external file and draws all objects based on those instructions.  The instructions themselves are generated with another program which I have much better knowledge of than MT4 code.  I was hoping there was something I could adjust regarding the creating and setting of the objects to solve the problem as it is much more efficient all round to draw half a dozen objects an hour per market timeframe than what would turn out to be hundreds by the end of a session.

E. Version 4.00  Build 445


Thanks for your help, I appreciate it.

 
22Degrees:

Ok beg your pardon, yes I am drawing to both main and subs.


C. 1 - Yes correct so far

    2 - When I switch to M30 chart and right click, only the objects with the M15 specific ID are listed.  The same applies when i start with M30 and then switch to M15, only the objects with M30 specific ID are listed

    3 - There are some cleanup delete codes but even though I created them myself and the logic is structured, I disabled all and still no change.


D.  As far as modifying the the CI to reDraw all in the history, this is something I have set in motion but not something that can be accomplished within the indicator itself.  The indicator reads a list of instructions from the external file and draws all objects based on those instructions.  The instructions themselves are generated with another program which I have much better knowledge of than MT4 code.  I was hoping there was something I could adjust regarding the creating and setting of the objects to solve the problem as it is much more efficient all round to draw half a dozen objects an hour per market timeframe than what would turn out to be hundreds by the end of a session.

E. Version 4.00  Build 445


Thanks for your help, I appreciate it.

That point C. 2. is strange. Does all the objects for M30 have the same name with all the objects for M15 ?. If object name for M30 is different with M15, then it should be drawn.
 

Exactly, it should be drawn.  If I remove the Timeframe filters:

ObjectSet(objID,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M30);

Then all objects now appear in the list:


Example:

As you can see from the ID name, they are unique with TF identifier, string identifier, and numerical identifier for later cleanup.


But with that line of code included (TimeFrame Filter), I only get the active timeframe's objects in the list.

 
22Degrees:

Exactly, it should be drawn.  If I remove the Timeframe filters:

Then all objects now appear in the list:


Example:

As you can see from the ID name, they are unique with TF identifier, string identifier, and numerical identifier for later cleanup.


But with that line of code included (TimeFrame Filter), I only get the active timeframe's objects in the list.


This is the codes that I used to test your case, it seem that I don't have problem running it in 445. From what the broker you using this MT4 and can you show your CI code, some of them or all of them if you don't mind.

BTW, if you're not using proxy, I think its very early morning in your place - go get some sleep dude. There's other moderator who live not far from where you live :)

  ObjectsDeleteAll();
  int success;string name = "AAAA";
  success = ObjectCreate( name, OBJ_TREND, 0, Time [3], High [3], Time [1], Low [1]);

  ObjectSet (name, OBJPROP_TIME1,  Time [5]);
  ObjectSet (name, OBJPROP_PRICE1, High [5]);
  ObjectSet (name, OBJPROP_TIME2,  Time [1]);
  ObjectSet (name, OBJPROP_PRICE2, High [1]);
  ObjectSet (name, OBJPROP_WIDTH,  2);
  ObjectSet (name, OBJPROP_BACK,   true);
  ObjectSet (name, OBJPROP_COLOR,  Red);
  ObjectSet (name, OBJPROP_TIMEFRAMES, OBJ_PERIOD_M1);
  WindowRedraw();
  //return(0);
  name = "BBBB";
  success = ObjectCreate( name, OBJ_TREND, 0, Time [8], High [8], Time [3], Low [3]);

  ObjectSet (name, OBJPROP_TIME1,  Time [8]);
  ObjectSet (name, OBJPROP_PRICE1, High [8]);
  ObjectSet (name, OBJPROP_TIME2,  Time [3]);
  ObjectSet (name, OBJPROP_PRICE2, High [3]);
  ObjectSet (name, OBJPROP_WIDTH,  2);
  ObjectSet (name, OBJPROP_BACK,   true);
  ObjectSet (name, OBJPROP_COLOR,  Red);
  ObjectSet (name, OBJPROP_TIMEFRAMES, OBJ_PERIOD_M5);
  WindowRedraw();
 

:$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$

Somehow multiple :embarrassed: smileys don't express how embarrassed I feel right now.. Back when I first created the CI, I had every timeframe open in separate windows.. What I had since forgotten was, In the section of code that I was not looking in because logic dictated that the issue wasn't there, lay a devilish little filter than only processed the data from the current external source's line, if the TimeFrame in said line matched the Period().

It was a Sherlock Holmes moment after reading back over our discussion this morning (If you eliminate all the impossible.. whatever remains, no matter how improbable..) that lead me to look over the file reader code.  However I would not have considered it had you not been able to confirm for me that everything I was doing "should" have achieved what I was aiming to achieve, therefore thank you for helping me to sort the issue and I sincerely apologize for wasting your time.

:$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$

 
22Degrees:

:$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$

Somehow multiple :embarrassed: smileys don't express how embarrassed I feel right now.. Back when I first created the CI, I had every timeframe open in separate windows.. What I had since forgotten was, In the section of code that I was not looking in because logic dictated that the issue wasn't there, lay a devilish little filter than only processed the data from the current external source's line, if the TimeFrame in said line matched the Period().

It was a Sherlock Holmes moment after reading back over our discussion this morning (If you eliminate all the impossible.. whatever remains, no matter how improbable..) that lead me to look over the file reader code.  However I would not have considered it had you not been able to confirm for me that everything I was doing "should" have achieved what I was aiming to achieve, therefore thank you for helping me to sort the issue and I sincerely apologize for wasting your time.

:$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$  :$

Great, glad that I can help and it's solve now, and btw, you're not wasting my time.
Reason: