Download MetaTrader 5

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

To add comments, please log in or register
Nathan Moss
721
Nathan Moss  
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.
honest_knave
Moderator
2342
honest_knave  

Not really.

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

Nathan Moss
721
Nathan Moss  
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
Nathan Moss
721
Nathan Moss  
Yes, the indicator works independently to the EA. I want the EA to control the indicators calculation period to new bar calculation only
honest_knave
Moderator
2342
honest_knave  
Why don't you use iCustom calls to your indicators from within your EA... which your EA only makes once per bar?
Nathan Moss
721
Nathan Moss  
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
Nathan Moss
721
Nathan Moss  
the issue would be the EA uses ontick, but I see your point
honest_knave
Moderator
2342
honest_knave  
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;
     }
  }


 

Nathan Moss
721
Nathan Moss  
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 :))
To add comments, please log in or register