EA Calculates at different time frames simultaneously- How to?

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
Hello,

To anyone who can assist, I am trying to understand how I can run parts of my dashboard/EA based on the timeframe that I am trying to analyze. For example, I would like my EA to rest on the M15 chart, but calculate H1/H4/D1 data - not on every new M15 bar, but on the bars that correlate.

Off the start, I believe I can use some thing like:

if(TimeHour(TimeCurrent()) == 01 && TimeMinute(TimeCurrent()) == 00)

Well this would allow me to commence a script or some code at the top of the hour.

Major drawbacks:
  1. the obvious bulky code that could ensue to do this for multiple timeframes
  2. The bigger one - if the code concludes before minute is able to increment to ':01' will it run again?
I suppose another idea is iBarShift to analyze higher timeframes. My biggest worry here is that if I am not mistaken, iBarShift can repaint.
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
That’s a novel idea. I guess I’d have to admit I don’t know enough about iBars to know how that would work.

If you open up a chart at M15, and never open the 240, will the client register any bars for the 240 if it hasn’t ‘seen’ and initialized the data into bars in the first place?

Apologies if I’m talking in circles.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,606
1,366
144
Odesa
www.earnforex.com
That’s a novel idea. I guess I’d have to admit I don’t know enough about iBars to know how that would work.

If you open up a chart at M15, and never open the 240, will the client register any bars for the 240 if it hasn’t ‘seen’ and initialized the data into bars in the first place?

Apologies if I’m talking in circles.
That's something you could easily test :).
 

TradeChaser

Active Trader
May 12, 2020
161
6
34
32
So, I checked that script by trying to print random pairs and timeframes, and they print out in the terminal, which is great.

so, that being said, would I hide that in it's own function?

the dream here is that it would be part of the program, so I wouldn't want to 'return' and terminate the program.

perhaps I need to make a bool function
that is checked by that test...
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,606
1,366
144
Odesa
www.earnforex.com
So, I checked that script by trying to print random pairs and timeframes, and they print out in the terminal, which is great.

so, that being said, would I hide that in it's own function?

the dream here is that it would be part of the program, so I wouldn't want to 'return' and terminate the program.

perhaps I need to make a bool function
that is checked by that test...
Yeah, why not? You could return true/false instead of a bare return. You would need to have a separate Prev_Bars for each timeframe.