warning "invalid date"

 

Hi

Please help me how to avoid this warning message 'invalid date'

void CDrawObject::ExchangeOpen(void)
  {
    MqlDateTime day;
    string WeekDay[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    datetime openLondon = D'09:00:00';
    datetime openNYork  = D'15:00:00';
    VLine(WeekDay[day.day_of_week] + " | UK Open",openLondon,true,clrSnow,1,STYLE_DASHDOTDOT,false);
    VLine("NY Open",openNYork,true,clrSnow,1,STYLE_DASHDOTDOT,false);
  }

Thanks in advance

 
Anil Varma:

Hi

Please help me how to avoid this warning message 'invalid date'

Thanks in advance

it's in the documentation

https://www.mql5.com/en/docs/basis/types/integer/datetime

Documentation on MQL5: Language Basics / Data Types / Integer Types / Datetime Type
Documentation on MQL5: Language Basics / Data Types / Integer Types / Datetime Type
  • www.mql5.com
Datetime Type - Integer Types - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Paul Anscombe:

it's in the documentation

https://www.mql5.com/en/docs/basis/types/integer/datetime

Thanks for reply Paul.

 
Paul Anscombe:

it's in the documentation

https://www.mql5.com/en/docs/basis/types/integer/datetime

Hi Paul

I am still getting invalid date error though modified the Code to include the date. Any idea what is wrong ?

void CTradeState::Set_TradeState()
  {
  //--- FRIDAY, no new position to open after 20.00 Hrs
    Set_TradeState(D'2021.01.01 20:00', D'2021.01.01 23.59', FRIDAY, TRADE_NO_NEW_ENTRY);
  //--- Asian Session Position Open NOT Allowed
    Set_TradeState(D'2021.01.01 00:00', D'2021.01.01 06:59', ALL_DAYS_OF_WEEK, TRADE_WAIT);
  //--- London, UK Opening Session Position Open allowed
    Set_TradeState(D'2021.01.01 07:00', D'2021.01.01 09:59', ALL_DAYS_OF_WEEK, TRADE_BUY_AND_SELL_UKExchange);
  //--- London, UK General Session Position Open allowed
    Set_TradeState(D'2021.01.01 10:00', D'2021.01.01 15:44', ALL_DAYS_OF_WEEK, TRADE_BUY_AND_SELL);
  //--- New York Session Position Open allowed
    Set_TradeState(D'2021.01.01 15:45', D'2021.01.01 19:59', ALL_DAYS_OF_WEEK, TRADE_BUY_AND_SELL_USExchange);
    Set_TradeState(D'2021.01.01 20:00', D'2021.01.01 23:39', ALL_DAYS_OF_WEEK, TRADE_BUY_AND_SELL);
  //--- FRIDAY, last trading day of week. EA switches to trade_STOP mode at 23.40 to close all open positions
    Set_TradeState(D'2021.01.01 23:40', D'2021.01.01 23:59', FRIDAY, TRADE_STOP);
    Set_TradeState(D'2021.01.01 00:00', D'2021.01.01 23:59', SATURDAY, TRADE_WAIT);
    Set_TradeState(D'2021.01.01 00:00', D'2021.01.01 23:59', SUNDAY, TRADE_WAIT);
  }
 
Anil Varma:

Hi Paul

I am still getting invalid date error though modified the Code to include the date. Any idea what is wrong ?

Please be more careful, the separator between hour and minute is a ":" not a dot "."