Is this possible? EA code to limit ontick from indicators..

 
Is this possible? Can an EA limit ontick function for indicators so that the indicators on chart recalculate on new candle only.

For example: EMA and MACD on D1, EA recalculates indicators on new D1 candle. H4, freeze all indicators on candle open, recalculate on new candle H4, H1 Freeze chart indicators on candle open price, recalculate indicators on new H1 candle... 

Does this make sense? I would like to include a code in my EA to freeze all indicators on all time frames on the candle open price. Recalculate on new candle only.
 

Not really.

Your indicators and EAs should be independently-coded to work on a new bar (if that is what you want). 

 
honest_knave:

Not really.

Your indicators and EAs should be independently-coded to work on a new bar (if that is what you want). 

Honest answer ;) I do not have the source code to change the indicator function so I was hoping there would be a solution to use an EA code. thank you
 
Yes, the indicator works independently to the EA. I want the EA to control the indicators calculation period to new bar calculation only
 
Why don't you use iCustom calls to your indicators from within your EA... which your EA only makes once per bar?
 
honest_knave:
Why don't you use iCustom calls to your indicators from within your EA... which your EA only does once per bar?
Good suggestion, I will need to get help from a programmer with that :) Thanks for the input
 
the issue would be the EA uses ontick, but I see your point
 
priceactiontrader:
the issue would be the EA uses ontick, but I see your point

That is very easy to "fix"

void OnTick()
  {
   static datetime last_bar = 0;
   datetime this_bar = Time[0];
   if(last_bar != this_bar)
     {
      // do stuff here only once per bar
      last_bar = this_bar;
     }
  }


 

 
honest_knave:

That is very easy to "fix"

void OnTick()
  {
   static datetime last_bar = 0;
   datetime this_bar = Time[0];
   if(last_bar != this_bar)
     {
      // do stuff here only once per bar
      last_bar = this_bar;
     }
  }


 

Thank you, it looks quite straight forward. I will give it a go after reviewing the code :))
Reason: