Hi I was created a thread about static datetime in here: https://www.mql5.com/en/forum/362972 and successfully working on it. The code from the previous thread detect and make the EA to works only once a bar since I put it on the first of the strategy. Now, I want to use the newbar variable in the previous thread to works with the tick.
In my EA I use multiple timeframe to do the strategy. I want to detect the new bar in the higher timeframe and do something in the lower timeframe but I still want to have the higher timeframe to works on the tick. The problem is when I use the code on the higher timeframe, the ability to detect tick changes is gone. I want the higher timeframe to have the ability to detect new bar but also doesn't want to remove the ability to detect tick, is there a way to code that way?
//Detect a new bar
static datetime preTime=0,curTime;
I don't understand what your problem is.
You have the bool newBar so the stuff that you want to do only if a new bar is done when the bool is true. Stuff that you want done every tick ignores the bool.
//New bar code
//Every tick code
Sorry got a little bit confuse also. My code is consist of M5, M15, M30, H1 and H4. when my chart is M5 then the higher timeframe is M30, if my chart is M15 then my higher timeframe is H1. What I want to do is detecting newbar on the higher timeframe.
The EA works on lower timeframe as entry position and higher timeframe as a code trigger. Since my chart is M5 and I want to get the new bar on the M30 so it can perform open position based on the M5 timeframe. Since my chart is M5, the new bar code will working on the M5 timeframe and not the M30. A workaround of this problem is to reversing the code using M30 chart and instead of higher timeframe I use the lower timeframe. But there's a problem in here, since my multi timeframe consist of 4 to 6 times factor from the current timeframe, M15 doesn't have a lower timeframe if I use the 4 to 6 times factors. it can only be 5 factors which is 3 minutes.
The only solution that I can think of is to make the new bar code working on the M30 timeframe from M5 chart or creating new timeframe script for the 3 minutes timeframe?
PS: I don't know if creating new timeframe is possible in mql4 and it if possible I don't have the ability to do so.
Recoding to use iTime and here is my code:
static datetime preTimeHTF=0,curTimeHTF;
on your reply you gave me a link to GetTickCount64 function, I believe it doesn't exist on mql4 though. I never encounter GetTickCount before and I don't really know what it can do, can you tell me more about GetTickCount64 function has any to do with my problem?
I have never linked to GetTickCount64.
Oh really? My screen showed that this is a link. Ok then. Thank you
Yes, unfortunately, it is a "feature" of the forum that creates auto links. I guess that it searches for key words.
It is really annoying and often creates unrelated links such as in this case.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.