Hi,
How can I stop the strategy processing furrther when the markets are closed? And when are the markets closed? I know weekends but what about Christmas, NYE, Easter, Japanese holidays etc? I need it to return once the markets are closed and VOLUME = 0. Is it valid to just code as directly below or must I also use
askBar.getVolume()?
double inVolume = bidBar.getVolume();
if (inVolume <= 0.0)
return;
I have these 2 snippets of code. I know the 2nd one (green) works, but I'm not sure the 1st one does. If the strategy encounters volume = 0.0 and O=C=H=L, e.g. 2/02/2018 22:00 87.237 87.237 87.237 87.237 0, it stops due to caught exception.
1.
long timeOfLastTick = myHistory.getLastTick(instrument).getTime();
if (myIDataService.isOfflineTime(timeOfLastTick))
return;
2.
if (!timeAllowsTrades(instrument, bidBar.getTime(), myBeginTime, myEndTime))
return;
...
private boolean timeAllowsTrades(Instrument instrument, long barTime, int beginHour, int endHour) throws JFException{
boolean allowsTrades = false;
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cal.setTimeInMillis(barTime);
int sysDay = cal.get(Calendar.DAY_OF_WEEK);
int sysHour = cal.get(Calendar.HOUR_OF_DAY);
if (sysHour >= beginHour && sysHour < endHour)
allowsTrades = true;
if ((sysDay == 6 && sysHour >= 20) || sysDay == 7 || sysDay == 1) // Saturday == 7 || Sunday == 1
allowsTrades = false;
return allowsTrades;
}
I tried searching wiki, but got no definitive answer.
Thanks,
Chrysos.