Code for MTF visualised in only a specific TF

To add comments, please log in or register
rosspet6
73
rosspet6  

Hi guys,

A coding question.

Is it possible to make an MTF indicator, for example the one attached, do the following (with only 1 attached indicator to the chart):
on a M15 chart show only the H1 lines; on a H1 chart show only the H4 lines; on a H4 chart show only the D1 lines; on a D1 chart show only the W1 lines, and on a W1 chart show only the Monthly lines?

I do this by attaching several times the indicator and making each instance visible in only one timeframe; for example, I would make the indicator showing H1 lines being visible only on the M15 chart; I would make the indicator showing H4 lines being visible only on the H1 chart; etc. This works, however, I need to attach several instances of the same indicator in order to cover all timeframes. If I combine this with some more instances of the same indicator (but with a different period; for example, 14 and 7 periods), then I easily double the amount of this same indicator....

See as an example the H4 chart with an MTF Stochastic for the D1 period and the D1 chart of the same pair with an MTF Stochastic for the W1 period. To cover only these 2 periods (H4 and D1), I have to attach 4  MTF Stochastic indicators in the same window… You can easily see that their number will grow exponentially in order to cover all the other timeframes.

This slows down the platform.

This is the reason I would be interested to know whether some clever coding could potentially reduce the amount of attached indicators.

Another question of a lesser importance is whether there is a snip of code which could automate the visualisation check-boxes; i.e. instead of manually checking the relevant box for a specific timeframe, could I insert a little code which would make the indicator show only in a specified timeframe?

For those of you who might be wondering why I am doing this, look at the coloured boxes on the 2 charts: I am trying to identify large gaps/differences between the current timeframe Stochastic and the next higher timeframe stochastic. Very often the price would try to “close” this gap. According to this strategy the AUDCAD should start coming down this afternoon (August 8); this downtrend will probably continue for another 2-3 days, at least until August 12-13 (but please don't take this as a reliable forecast, let me lose my own money, not yours... )

Thanks for any help/idea how to make this with less attached indicators.



Files:
William Roeder
19412
William Roeder  
rosspet6: Is it possible to make an MTF indicator,

Of course. For the current TF, find the next higher and use that as a data source.

rosspet6
73
rosspet6  
William Roeder:

Of course. For the current TF, find the next higher and use that as a data source.

Thanks for responding. Is this not what I am already doing; if you look at the 2 files that I attached and the images I posted? Or maybe I misunderstand your idea... What I am trying to find out is whether this would be possible via changes in the existing code of the indicator; and if yes, what would be these changes/additions to the existing code...

Seng Joo Thio
937
Seng Joo Thio  
rosspet6:

Thanks for responding. Is this not what I am already doing; if you look at the 2 files that I attached and the images I posted? Or maybe I misunderstand your idea... What I am trying to find out is whether this would be possible via changes in the existing code of the indicator; and if yes, what would be these changes/additions to the existing code...

What you have now is:

extern int TimeFrame=1440;

Change it to something like:

extern int TFOffset=1;

Then, in your code, you can find the next 'TFOffset' higher timeframe... e.g. if TFOffset is 2, and you run your indicator on H1, you'll use D1, and the same indicator loaded on H4 will be using W1, and so on.


Reference: https://www.mql5.com/en/forum/123500

Next Timeframe
Next Timeframe
  • 2010.01.28
  • www.mql5.com
I need a function to calculate the next timeframe up from the current chart. So if I'm trading on a 30 tf I'd want it to return 60. Thanks...
rosspet6
73
rosspet6  
Seng Joo Thio:

What you have now is:

Change it to something like:

Then, in your code, you can find the next 'TFOffset' higher timeframe... e.g. if TFOffset is 2, and you run your indicator on H1, you'll use D1, and the same indicator loaded on H4 will be using W1, and so on.


Reference: https://www.mql5.com/en/forum/123500

@Seng Joo Thio,


Thanks a lot man. Your idea would probably work in the hands of somebody who is more intelligent than me... Do you mind modifying the code I attached to the original  post, incorporating your idea, and post back the modified code? I hope this is not too much to ask. Thanks in advance.

Seng Joo Thio
937
Seng Joo Thio  
rosspet6:

Thanks a lot man. Your idea would probably work in the hands of somebody who is more intelligent than me... Do you mind modifying the code I attached to the original  post, incorporating your idea, and post back the modified code? I hope this is not too much to ask. Thanks in advance.

Attached.

As in all free codes - there is no thorough error check and no support 😆😆😆

Files:
rosspet6
73
rosspet6  
Seng Joo Thio:

Attached.

As in all free codes - there is no thorough error check and no support 😆😆😆

Everything seems to be working great :-)  I checked all timeframes, various charts... all GOOD.

Thank you SO MUCH again !! Much appreciated !!

I wish you a profitable next week ;-)

To add comments, please log in or register