The problem is having object created in a TF (e.g the 4H TF) to be displayed on the the 4H TF and lower TF,.
but getting it to display multiple objects created from different TF is somewhat is hard to solve.
Just set the display mask from the current TF and store. What's so hard?
Not compiled, not tested, just typed.
int periodToDisplay(ENUM_TIMEFRAME period=PERIOD_CURRENT{ if(period == PERIOD_CURRENT) period=_Period; const static int conv[9][2]={ PERIOD_M1, OBJECT_PERIOD_M1, PERIOD_M5, OBJECT_PERIOD_M5, ⋮ PERIOD_MN1, OBJECT_PERIOD_MN1 } int obj_per = 0; for(int i=8; i >= 0; --i) if( PeriodSeconds(conv[i][0]) <= PeriodSeconds(period) ) obj_per |= conv[i][1]; return obj_per; }
Not compiled, not tested, just typed.
Just set the display mask from the current TF and store. What's so hard?
it won't be hard, would probably need to learn bit masking and Dynamic programming (was doing some research from your reply that what I came across), I have not used such before. Thanks
Just set the display mask from the current TF and store. What's so hard ?
No willingness to assist
I posted working code; OP was grateful. What did you do?
I posted working code; OP was grateful. What did you do?
The following would work if you are looking at only the default TF(monthly, weekly ... 1H, 30M, 15M ... 1M)
Note: For all Timeframe you could change the code to set all bits of TF that are lower than the current period
int periodToDisplay(ENUM_TIMEFRAMES period=PERIOD_CURRENT) { //--- using a 9 by 2 to hold the values of the TF, and the bit value of the TF in question const static int conv[9][2] = { {PERIOD_M1, OBJ_PERIOD_M1}, {PERIOD_M5, OBJ_PERIOD_M5}, {PERIOD_M15, OBJ_PERIOD_M15}, {PERIOD_M30, OBJ_PERIOD_M30}, {PERIOD_H1, OBJ_PERIOD_H1}, {PERIOD_H4, OBJ_PERIOD_H4}, {PERIOD_D1, OBJ_PERIOD_D1}, {PERIOD_W1, OBJ_PERIOD_W1}, {PERIOD_MN1, OBJ_PERIOD_MN1} }; //--- the value of the Timeframe when the object would be displayed int obj_per = 0; for (int i =8; i>=0; i--) //--- Check the TF if it is less or equal to the period in question if(conv[i][0] <= period) obj_per |= conv[i][1]; // if it true, add the value of TF to obj_per return obj_per; }
Hope it helps, just another option ( I prefer smaller codes)
int periodToDisplay(string &name, ENUM_TIMEFRAMES &period) { //--- Obj_Period to be returned long obj_per = 1; //--- Rather than using PERIOD_M1, you could use "1", I used that to make more readable for (int i = period; i>= PERIOD_M1; i/=2) obj_per |= (obj_per << 1); return obj_per; }
Note: You will need to do one or two modifications in the above code, to get the results you would be after, I could add it, but where the fun in that, post your modification lets see... cheers
No willingness to assist
Yeah, sometimes it feels that way, but imagine if he didn't or no one responded at all, he is not obliged to respond, no one is, what ever the reason someone decides to respond, it is cool to be thankful and move on, cause at the end of the day, you won't be asking for it if you don't need it, that is how I see it

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The problem is having object created in a TF (e.g the 4H TF) to be displayed on the the 4H TF and lower TF, anything greater than the 4H TF it won't display. I know using
OBJ_PERIOD_D1|OBJ_PERIOD_H4 // would get you to display the Object on only the 4H and Daily TF and nothing else
but getting it to display multiple objects created from different TF is somewhat is hard to solve with that, as a single function is creating all objects
but looking at the visualization tab, when the object is displaying, everything is marked, when the timeframe is changed to a TF it is not suppose to display, nothing is marked. Am asking if there is a better way to get my desire result. thanks