MT5 MetaEditor: How to code displaying an indicator on specific time frames only?

 

Hi to all!

Searched the forum and did not find the answer... So need an advice please:

Is it possible to add some coding to any indicator to display it on specific time frames only ? Let's say, whenever I add indi to the chart I need it to be displayed on H6 and H8 automatically (not selecting them manually)

I.e. indicator should not to be displayed on all timeframes by default, but on coded timeframes only?

Thanks for your time!

Files:
 

You put indicators on charts. You do not put charts on indicators. You seem to want the later.

If the period isn't your H6/H8, you can:

  1. return fail from OnInit. Nothing gets displayed, indicator is removed. Changing TF back won't add it back.
  2. return from OnCalculate. A blank sub-window gets displayed (assuming separate window indicator.) You can also put a text message in it as to why.
  3. call ChartSetSymbolPeriod in OnCalculate. TF changes. I suggest you print a message to the log as to why.
 

Do not double post.

Your other topic has been deleted.

 
William Roeder:

You put indicators on charts. You do not put charts on indicators. You seem to want the later.

If the period isn't your H6/H8, you can:

  1. return fail from OnInit. Nothing gets displayed, indicator is removed. Changing TF back won't add it back.
  2. return from OnCalculate. A blank sub-window gets displayed (assuming separate window indicator.) You can also put a text message in it as to why.
  3. call ChartSetSymbolPeriod in OnCalculate. TF changes. I suggest you print a message to the log as to why.

Thanks!

'You do not put charts on indicators' - yes, I know. 

As I mentioned earlier - 'whenever I add indi to the chart'. It definitely means that you do not put charts on indicators...

 
Keith Watford:

Do not double post.

Your other topic has been deleted.

Thanks!

Perhaps it's good idea to create coding thread to avoid duplication?

Reason: