KimIV's excellent indicator i-sessions does not allow adjustment for DST on sessions. I am trying to modify it for my needs/preferences.
...The original doesn't do it because it's not possible to do it correctly.
To do it correctly you would need to know the broker server DST, if any. Maybe you can get this information from your broker and do it for your own usage.
Beside that, if you want coding help you should post clear code, what you posted is a mess.
The original doesn't do it because it's not possible to do it correctly.
To do it correctly you would need to know the broker server DST, if any. Maybe you can get this information from your broker and do it for your own usage.
Beside that, if you want coding help you should post clear code, what you posted is a mess.
I apologize for the coding "mess". I have never posted on this forum before so I am uncertain how to best present my problem. The coding is by another author who has several very good custom indicators and I presumed that his coding was not a "mess". Let me try to re-phrase my question.
1) The program flow is like this (I believe)
OnCalculate()
- Iterate through NumberOfDays
- DrawRectangle(datetime dt, string NameOfRectangle(i), SessionOpenTime, SessionEndTime, SessionColor, SessionHigh, SessionLow)
- Decrement datetime value dt function decDateTradeDay(dt)
- test while day_of_week Mon-Fri (1-5) true
2) I don't really understand the iteration of the draw function. I believe that on each iteration, a rectangle is drawn for the bar by the paramenters SessionOpen, SessionClose, SessionHigh, and SessionLow. I believe each bar is iterated going from the current bars backwards to the furthest bay represented by NumberOfDays. Is each rectangle (each bar) parameters independent of the previous iteration? If that is true, why could the parameters change for bars 50-60 from the parameters for bars 0-49?
3) Finally, you say the original doesn't do it because its not possible. I don't understand why representing the changed time values for half of the year can not be represented in a chart. The broker (Oanda) is using a GMT+2 server (a MetaQuotes Demo server). If the server time changes with DST, then I guess no adjustment is needed for the sessions which also change to DST (London and NY for instance). But then what about Tokyo which does not use DST? I have been presuming that this server is always GMT+2 but perhaps it is now GMT+3. This is what I am trying to understand.
I am sincerely trying to find a solution from others who have expertise. I am sorry if I have offended you.
Dennis
- www.mql5.com
I apologize for the coding "mess". I have never posted on this forum before so I am uncertain how to best present my problem. The coding is by another author who has several very good custom indicators and I presumed that his coding was not a "mess". Let me try to re-phrase my question.
1) The program flow is like this (I believe)
OnCalculate()
- Iterate through NumberOfDays
- DrawRectangle(datetime dt, string NameOfRectangle(i), SessionOpenTime, SessionEndTime, SessionColor, SessionHigh, SessionLow)
- Decrement datetime value dt function decDateTradeDay(dt)
- test while day_of_week Mon-Fri (1-5) true
2) I don't really understand the iteration of the draw function. I believe that on each iteration, a rectangle is drawn for the bar by the paramenters SessionOpen, SessionClose, SessionHigh, and SessionLow. I believe each bar is iterated going from the current bars backwards to the furthest bay represented by NumberOfDays. Is each rectangle (each bar) parameters independent of the previous iteration? If that is true, why could the parameters change for bars 50-60 from the parameters for bars 0-49?
3) Finally, you say the original doesn't do it because its not possible. I don't understand why representing the changed time values for half of the year can not be represented in a chart. The broker (Oanda) is using a GMT+2 server (a MetaQuotes Demo server). If the server time changes with DST, then I guess no adjustment is needed for the sessions which also change to DST (London and NY for instance). But then what about Tokyo which does not use DST? I have been presuming that this server is always GMT+2 but perhaps it is now GMT+3. This is what I am trying to understand.
I am sincerely trying to find a solution from others who have expertise. I am sorry if I have offended you.
Dennis
Offended ? Not at all.
It can't be coded for all brokers because the DST/GMT can be different for each broker and there is no coding way to know the DST of the server.
It can be coded if you know the server GMT/DST. You said Oanda is GMT+2 but what about DST ? I see a lot of assumptions in your post, but it's not nothing you can "understand", it's something you need to know and the only way to know it is to ask to your broker.
ONLY when you know the server GMT/DST what you want to do will be codable reliably. It then becomes trivial to apply the different time shift
according to the sessions GMT/DST.
Offended ? Not at all.
It can't be code for all brokers because the DST/GMT can be different for each broker and there is no coding way to know the DST of the server.
It can be coded if you know the server GMT/DST. You said Oanda is GMT+2 but what about DST ? I see a lot of assumptions in your post, but it's not nothing you can "understand", it's something you need to know and the only way to know it is to ask to your broker.
ONLY when you know the server GMT/DST what you want to do will be codable reliably. It then becomes trivial to apply the different time shift
according to the sessions GMT/DST.
I have read articles on time functions and daylight saving time and other related articles since your last response. I understand now the difficulties and obstacles in my question. Thak you for giving me direction. Yes I can do it under limits of my brokers server but it won't apply on another server with different time. I was hoping for an easy answer and there isn't one apparently, Thank you for your time.
Dennis
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
KimIV's excellent indicator i-sessions does not allow adjustment for DST on sessions. I am trying to modify it for my needs/preferences.
I am doing this in MQL5.
the indicator draws colored rectangles on the chart highlighting the trading session from session opn to session close and at hieght of session low to session high. The input parameters are session begin time and session end time. The original code allows for 8 different market sessions. I only wnat 3 sessions. And i am using this for back testing and analysis so I need the seesion open time charted to be corrected for Daylight Savings Time (or Summertime/Wintertime) as the case maybe. End result is I should see the shift in time on the chart at any given date (so around Mar 30 the London session open would change from 8:00 GMT to 7:00 GMT and so forth for NY Session as well).
I modified and added input variables in the original code to suit my needs. (Changed variable S1Begin to TKYBegin; Added TKYBeginDST, for instance). I tested my alterations no problem.
Next I altered the program to use my new input variable in place of the original variable. I am just testing London only in my code. So rather than using LDNBegin (London session open time) I substituted LDNBeginDST (London Summertime Open). It functioned as expected so that the full history on the charts (up to 500 bars) showed London session open at 7:00 GMT. Thus I knew that I was inserting my variable values successfully.
Next I created a test on the date. I believe that KimIV the original author of the indicator decrements (decreases) the variable "dt" with each iteration in OnCalculate(). First iteration "dt" is TimeCurrent(). Then each bar shift "dt" is set back by the date/time value of the bar by the function decDateTradeDay(). I reasoned that I did not need to alter any of his functions but rather I could just run a test on the value "dt" in each iteration to see whether it was during DST period (Summertime) or regular time. If DST time then I would change the session open time.
My code compiles successfully but the rectangles drawn do not change for the sessions during DST. Could someone look at the code attached and see what I am missing?
I don't really know this language well but I have coded in c++ and other languages (JavaScript, Basic and others). I'm not completely following the programming flow and I had hoped to be able to insert a quick test and change. My new code compile but the session rectangles do't appear to change for dates affected by DST.
Could some one please identify what I have done wrong?
Thank you in advance.
Dennis
traderdjid@gmail.com