run every 15 min on quarter-hourly data

 

Hi everybody,

First of all, thanks in advance for your help. I really appreciate it.

I was given a system to automate, and I've had a long tough time of it. I put it all in Excel, but was having trouble automating the data entry and would still have had to make trades by hand, so I started up with MetaTrader. The thing is, the system is based on quarter-hourly data. Right now we get that from GFT of all places, by hand. A friend of a friend showed me how to use iOpen with PERIOD_M15 to get 15 minutes worth of data, but the data is aggregated over the last 15 minutes from the last tick, right? The people who shared their system with me stress that it was finely tuned for being run on data on the quarter hours.

That part is probably not a huge deal, I can see later if it makes a difference, it could be better. If someone knows how to easily lock a given Period into being from, say, 11:00 to 11:15 and 11:15 to 11:30 instead of t-30 to t-15 and t-45 to t-30, that would be great.

The bigger problem is that I need to make MQL run when I tell it to instead of every tick. Part of the system is econometric lag terms, M_n=M_n-1+P_n or something similar wherein the current value of the lag term is based on the previous value. If I do this calculation every time there's a tick I'll get a very different value after just a few seconds than I'm expecting, since normally I do the calculation every 15 minutes. Can I do something like having a script run every 15 minutes instead of an EA? I thought that the sleep function would work but it's not exact enough.

 

You have made some incorrect assumptions.

a) MT4 start() is called for each tick, but on a M15 chart, it creates a new bar each 15 minutes. Only the 2 most recent bars might change (usually 1, but 2 if tick straddles bar boundary).
i.e. it is not a sliding 15 minutes

b) to avoid calculating each tick, when info for current bar can change, then either just use Open price (which is the one of O-H-L-C that will never change for a bar) or else just calc on first tick of bar. maybe both

 

callowschoolboy:

That part is probably not a huge deal, I can see later if it makes a difference, it could be better. If someone knows how to easily lock a given Period into being from, say, 11:00 to 11:15 and 11:15 to 11:30 instead of t-30 to t-15 and t-45 to t-30, that would be great.

The bigger problem is that I need to make MQL run when I tell it to instead of every tick.

  1. The M15 bars are 11:00 to 11:15. Just run on the M15. To compute T-30 to T-15, you'd have to generate the data from the M1 chart, must harder.
  2. On the M15
    int start(){  static datetime Time0;
    if (Time0 == Time[0]) return; Time0 = Time[0];
    // Here once at the start of a new bar.

 

Thanks ya'll. Part 2 of Roeder's post is what I need I think, I'm gonna try it and let ya'll know.

thanks for explaining that to me brewmanz, I didn't understand part a before and now I do. I should clarify about part b, it's not about what price to use but that I really don't want it to run every time a price comes in. I think Roeder's part 2 might do it, although won't I have to make a complicated condition, Time0 in range Time[delta]-Time[epsilon]?

 

callowschoolboy:

Time[delta]-Time[epsilon]?

huh? Time[0] changes once every 15 minutes on the M15 chart.
Reason: