Making EA recognize trading Index Overnight?

 

Hi,

I'm in the UK and I have an EA that will trade the Australian 200 Index.

This means that the Index opens 23:00 and closes 05:00, which is confusing my EA, because if I open the MT4 platform at say 22:00, it thinks the trading day has already been and gone (finished at 05:00 that morning rather than starting in an hour's time at 23:00).

How do I get the code to recognize the timing correctly?

 

As far as I can see you don't seem to consider the time difference of the broker (and Australia, and USA, and ...)

I would suggest you to normalize all your times on GMT considering the different DST of USA, London, Australia and you broker there is a lot to add and/or to subtract!

 
Carl Schreiber:

As far as I can see you don't seem to consider the time difference of the broker (and Australia, and USA, and ...)

I would suggest you to normalize all your times on GMT considering the different DST of USA, London, Australia and you broker there is a lot to add and/or to subtract!

The broker time is the same as mine (UK GMT). So in the case of the Aus200, the market opens at 11:00pm GMT and closes at 5:00am. I believe that's where the EA is getting confused.

If I open the MT4 platform at say 10:00pm (1 hour before the open), it thinks the trading day has already been and gone (because Australia finished at 5:00am that morning rather than about to start in an hour's time at 11:00pm GMT).

I think its the fact that the market hours are across 2 calender days that makes it complicated. 

 
aaja: If I open the MT4 platform at say 10:00pm (1 hour before the open), it thinks the trading day has already been and gone (because Australia finished at 5:00am that morning rather than about to start in an hour's time at 11:00pm GMT).

I think its the fact that the market hours are across 2 calender days that makes it complicated. 

  1. 1 hour before open is correct, the day has ended and hasn't stated a new.
  2. What is complicated? If you trade [5..23] you test time >= 5 && time < 23. If you trade [23..5] test time >= 23 || time < 5.
 
whroeder1:
  1. 1 hour before open is correct, the day has ended and hasn't stated a new.
  2. What is complicated? If you trade [5..23] you test time >= 5 && time < 23. If you trade [23..5] test time >= 23 || time < 5.
As this was coded for me (the coder I've lost contact with), I Haven't a clue how to amend it. I just tried pasting your bit of code somewhere in the file but it won't compile, so I must have put it in the wrong place. This is the part of the attached mq4 from the OP that pertains to time:
        {
                _orderTime = _startTime;
                _orderTime.AddMins(InitCandlestickLength * Period());
                
                CTime timeNow(TimeCurrent());
                if ((timeNow >= _startTime) && !ForcePlaceOrder) _ordersPlaced = true;
                if (timeNow >= _stopTighteningTime) _stopTightened = true;
                
                ReadHolidays();
        }      
        
        void DoTick()
        {
                Date todaysDate(TimeCurrent());
                
                // check the day of the week.
                if ((todaysDate.GetDayOfWeek() == dayofweek_saturday) || (todaysDate.GetDayOfWeek() == dayofweek_sunday))
                {
                        return;
                }
                
                if (!_init)
                {
                        NewDay();
                        _init = true;
                }
                
                // first check if we are on to a new day...
                if (todaysDate.NotEquals(_pCurrentDate.Val)) NewDay();
                
                if (_noTradeToday) return;
                
                // are we past end of trading time?
                CTime timeNow(TimeCurrent());
                if (!_tradesClosed && (timeNow >= _endTime))
                {
                        _log.Write(INFO,"We have reached the end of trading - closing all positions.");
                        pTradeManager.Val.RemoveOrdersAndCloseTrades(Magic);
                        
                        _tradesClosed = true;
                }
 
aaja I Haven't a clue how to amend it.
Top of every page is Freelance
 
whroeder1:

Top of every page is Freelance
If I can't figure this out, I might have to go there.