Anil Varma:
Dear Fellows
Please help me to rectify the below code to get correct IsNewSession value when a new session has started.
I failed to resolve it.
Thanks in advance and happy weekend.
I am not sure what you are trying to achieve.
If the code were copy/paste to an mq5 file, I would maybe check it.
But this way, I have issues to go through and would like to point you to this thread:
Is that what you have been looking for??
Hi Dominik
I personally felt that, there was requirement of another for..loop inside the main loop to check TimeCross at [ith] index of main loop in say 120 counts, and return true if found AND continue to look for i-1th index in main loop.
I tried this, and current problem is RESOLVED. The revised code is as below, may be someone finds it useful.
bool CiVPBase::IsNewSession() { #define _HoD(t) ((int)(((t)%86400)/3600)) // Hour of Day 2018.02.03 17:55:56 => (int) 17 #define _MoH(t) (int(((t)%3600)/60)) // Minute of Current Hour string vMethod = "[" + mSymbol + "," + TimeToString(TimeCurrent()) + "] " + __FUNCTION__; datetime vCurrCross = TimeCurrent(); for(int i = ArraySize(TimeFxOpen)-1; i >= 0; i--) { // We need first PERIOD_M1 bar for TimeFxOpen[i] which is on PERIOD_H1. For Asian session and tSVR it starts at 01:01 Hrs int idx = iBarShift(mSymbol,PERIOD_M1,TimeFxOpen[i]); datetime vPrevTime = iTime(mSymbol,PERIOD_M1,idx-1); for(int j = 0; j <= 120; j++) { int vHour = _HoD(TimeCurrent()); // Hour value of CurrentTime int vMinute = _MoH(TimeCurrent()); // Minute value of CurrentTime datetime vCurrTime = StringToTime(""+(string)YoY(TimeFxOpen[i])+"."+(string)MoY(TimeFxOpen[i])+"."+(string)DoM(TimeFxOpen[i])+" "+(string)vHour+":"+(string)vMinute); if(cATS.checkTimeCross(vHour,vMinute,vCurrTime,vPrevTime)) { if(mPrevCross != vCurrCross) { if(HoD(vPrevTime) == vHour) { vCurrCross = vCurrTime; mPrevCross = vCurrCross; return(true); } } } } } return(false); } // End of method IsNewSession()
Thanks for your support and time. Regards.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Dear Fellows
Please help me to rectify the below code to get correct IsNewSession value when a new session has started.
I failed to resolve it.
Thanks in advance and happy weekend.