i attach a test of a strategy Btested with data from EST07 and GMT+1 DST US.
on a simple H1 strategy that is a big issue, becouose if someone of us have 2 or 3 brokers on different Timezone, can not use the strategy.
Description changed:
i attach a test of a strategy Btested with data from EST07 and GMT+1 DST US.
on a simple H1 strategy that is a big issue, becouose if someone of us have 2 or 3 brokers on different Timezone, can not use the strategy.
it is like the highest from 2 AM TO 0:30 AM next day. So I am afraid if you shift from UTC + 2 2 AM to 0:30 AM to UTC + 1 which will be 1 AM to 23:30 PM previous day the level will be very different. You might try to alter the shift [2] to correct that and use the same prices Hope this might help or let me know if you have any issues still Sincerely, Tomas Matejka StrategyQuant Team
It's a bug, this should all be accounted for in the code. I can show you how to do it if you can't figure it out, I have a similar start time end time function in my own EA which does not have this problem.
OK I explain what I mean in the universal language of code. This should work but I didn't compile it. Anyways, I'm sure you can see what we need to do now.
Should do this:
-allows start time to be greater than end time without breaking
-adjusts for all timezones automatically.
private void calculateSessionTimes(long currentTime) { long dayStart = SQTime.correctDayStart(currentTime); long startTime = dayStart + (startHours * 60 + startMinutes) * 60000; // very nice work! you made the times to be timezone insensitive by incorporating dayStart! long endTime = dayStart + (endHours * 60 + endMinutes) * 60000; // if(startHHMM >= endHHMM) ;{ // endTime += DAY_MILLIS; //} NO! don't do this here! This would cause the end time to be the end of the day SERVER TIME.
// Why go through all the trouble of making the times be timezone insensitive and then do this? We will
// account for when end time is lower than begin time elsewhere in the snippet
// if(currentTime < (endTime - DAY_MILLIS)) ;{
// startTime -= DAY_MILLIS; // endTime -= DAY_MILLIS; // } // else if(currentTime > endTime || endTime == sessionEndTime) { // startTime += DAY_MILLIS; // endTime += DAY_MILLIS; // } Lets just get the timezone adjusted start and end times simply? Because I think whatever you're
// trying to do here isn't working we can account later for when start and end times are reversed...
// Account for wrap around times and get the proper times of the triggers if (startTime >= DAY_MILLIS) startTime -= DAY_MILIS;// result should be 0 to 23xx if (endTime >= DAY_MILLIS) endTime -= DAY_MILIS;// result should be 0 to 23xx
sessionStartTime = startTime; sessionEndTime = endTime; } }
private void calculate() throws TradingException { long currentTime = Chart.Time(dataShift);
calculateSessionTimes(currentTime);// We need to adjust the sessiontimes for the timezone differences here before the other logic if((sessionStartTime < sessionEndTime && currentTime >= sessionEndTime) ||
(sessionStartTime >= sessionEndTime && (currentTime < sessionStartTime && currentTime >= sessionEndTime))) { if(!sessionClose.isEmpty()) { sessionClose.set(0, Chart.Close(dataShift + 1)); long prevTime = Chart.Time(dataShift + 1); if(prevTime >= sessionStartTime && prevTime < sessionEndTime) { sessionHigh.set(0, Math.max(Chart.High(dataShift + 1), sessionHigh.get(0))); sessionLow.set(0, Math.min(Chart.Low(dataShift + 1), sessionLow.get(0))); } } // calculateSessionTimes(currentTime); // I'mpretty sure we need to call this before all the time check logic.... waitingForSession = true; } if((sessionStartTime < sessionEndTime && currentTime >= sessionStartTime) ||
(sessionStartTime >= sessionEndTime && (currentTime < sessionEndTime || currentTime >= sessionStartTime))) {
if(waitingForSession) { waitingForSession = false; sessionOpen.add(0, Chart.Open(dataShift)); sessionHigh.add(0, Chart.High(dataShift)); sessionLow.add(0, Chart.Low(dataShift)); sessionClose.add(0, Chart.Close(dataShift)); } else { sessionHigh.set(0, Math.max(Chart.High(dataShift), sessionHigh.get(0))); sessionLow.set(0, Math.min(Chart.Low(dataShift), sessionLow.get(0))); sessionClose.set(0, Chart.Close(dataShift)); } }