I still haven't figured out how to get adequate information from DayOfWeek. It gives the correct value on the day the robot starts and in some other cases (sometimes). It seems to me that it gives out a correct value when I open orders. If you don't open anything, it will give you the weather.
I have solved the problem this way:
...
int realDay=DayOfWeek();
int curHour=TimeHour(TimeLocal());
while(!IsStopped())
{
if (TimeHour(TimeLocal())<curHour) realDay++;
curHour=TimeHour(TimeLocal());
if (realDay==7) realDay=0;
...
I still haven't figured out how to get adequate information from DayOfWeek. It gives the correct value on the day the robot starts and in some other cases (sometimes). It seems to me that it gives out a correct value when I open orders. If you don't open anything, it will give you the weather.
Ihor Herasko: In this way you will only get the permission status of the instrument to trade. If the instrument is traded, you will get true for it any day of the week.
Alert("Trade allowed by MarketInfo: ", bool(MarketInfo(Symbol(),MODE_TRADEALLOWED)));
Alert("Trade allowed by IsTradeAllowed: ", bool(IsTradeAllowed()));
Alert("Trade allowed by IsTradeAllowed 2-nd version: ", bool(IsTradeAllowed(Symbol(), TimeLocal())));
Result:
2015.12.2016:41:21.196 Test EURUSD,H1: Alert: Trade allowed by IsTradeAllowed 2-nd version: false2015.12.2016:41:21.196 Test EURUSD,H1: Alert: Trade allowed by IsTradeAllowed: true2015.12.2016:41:21.196 Test EURUSD,H1: Alert: Trade allowed by MarketInfo: true
On my computer the time is GMT+2.
That's why I don't understand how you managed to get false in the first case. Perhaps, you took an instrument that is not traded in principle.
The following are the conclusions:
The first and second options are essentially indentical. They only point to the fact that autotrading for the instrument is enabled and there is free trade flow.
The third variant is just what we need. It allows you to know the permission to trade on an instrument with reference to its working schedule.
It is therefore not clear how you managed to get false on the first option. Perhaps, you took an instrument that is not traded in principle.
The following are the conclusions:
The first and second options are essentially indentical. They only point to the fact that autotrading for the instrument is enabled and there is free trade flow.
The third variant is just what we need. It allows you to know the permission to trade on an instrument given its work schedule.
Indeed, this broker has the result of the script above:
2015.12.2017:19:18.685 Test GBPUSD,H4: Alert: Trade allowed by IsTradeAllowed 2-nd version: false2015.12.2017:19:18.685 Test GBPUSD,H4: Alert: Trade allowed by IsTradeAllowed: false2015.12.2017:19:18.685 Test GBPUSD,H4: Alert: Trade allowed by MarketInfo: false
2015.12.2017:18:14.339 Test EURUSD,M314: Alert: Trade allowed by IsTradeAllowed 2-nd version: false2015.12.2017:18:14.339 Test EURUSD,M314: Alert: Trade allowed by IsTradeAllowed: false2015.12.2017:18:14.339 Test EURUSD,M314: Alert: Trade allowed by MarketInfo: true
Broker A***i:
2015.12.2017:20:40.372 Test EURUSD,M15: Alert: Trade allowed by IsTradeAllowed 2-nd version: false2015.12.2017:20:40.372 Test EURUSD,M15: Alert: Trade allowed by IsTradeAllowed: true2015.12.2017:20:40.372 Test EURUSD,M15: Alert: Trade allowed by MarketInfo: true
Broker I***a F***x:
2015.12.2017:21:38.663 test GBPUSD,H1: Alert: Trade allowed by IsTradeAllowed 2-nd version: false2015.12.2017:21:38.663 test GBPUSD,H1: Alert: Trade allowed by IsTradeAllowed: false2015.12.2017:21:38.663 test GBPUSD,H1: Alert: Trade allowed by MarketInfo: false
My first test today was on A*****l M*****s.
Thus, we get that not all brokers have correctly working IsTradeAllowed (first version) and MODE_TRADEALLOWED. And on the other hand, the second version of IsTradeAllowed works correctly everywhere. So, it is better to use it.
Indeed, this broker has the result of the script above:
Started checking other brokers. Broker G**X:
Broker A***i:
Broker I***a F***x:
My first test today was on A*****l M*****s.
Thus, we get that not all brokers have correctly working IsTradeAllowed (first version) and MODE_TRADEALLOWED. And on the other hand, the second version of IsTradeAllowed works correctly everywhere. So, it is better to use it.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I still haven't figured out how to get adequate information from DayOfWeek. It gives the correct value on the day the robot starts and in some other cases (sometimes). It seems to me that it gives out a correct value when I open orders. If you don't open anything, it will give you the weather.
I have solved the problem this way:
But I haven't tested it yet )))) It should work.
I still haven't figured out how to get adequate information from DayOfWeek. It gives the correct value on the day the robot starts and in some other cases (sometimes). It seems to me that it gives out a correct value when I open orders. If you don't open anything, it will give you the weather.
I have solved the problem this way:
But I haven't tested it yet ))) It should work.
It's easier - use TimeDayOfWeek:
In this way you will only get the permission status of the instrument to trade. If the instrument is traded, you will get true for it any day of the week.
Alert(bool(MarketInfo(Symbol(),MODE_TRADEALLOWED));
false
Alert(bool(MarketInfo(Symbol(),MODE_TRADEALLOWED));
false
My version is as follows:
Result:
On my computer the time is GMT+2.
That's why I don't understand how you managed to get false in the first case. Perhaps, you took an instrument that is not traded in principle.
The following are the conclusions:
My version is this:
Result:
On my computer the time is GMT+2.
It is therefore not clear how you managed to get false on the first option. Perhaps, you took an instrument that is not traded in principle.
The following are the conclusions:
EURUSD fxOpen
Indeed, this broker has the result of the script above:
Started checking other brokers. Broker G**X:
Broker A***i:
Broker I***a F***x:
My first test today was on A*****l M*****s.
Thus, we get that not all brokers have correctly working IsTradeAllowed (first version) and MODE_TRADEALLOWED. And on the other hand, the second version of IsTradeAllowed works correctly everywhere. So, it is better to use it.
Indeed, this broker has the result of the script above:
Started checking other brokers. Broker G**X:
Broker A***i:
Broker I***a F***x:
My first test today was on A*****l M*****s.
Thus, we get that not all brokers have correctly working IsTradeAllowed (first version) and MODE_TRADEALLOWED. And on the other hand, the second version of IsTradeAllowed works correctly everywhere. So, it is better to use it.
And today
IsTradeAllowed(Symbol(), TimeCurrent())
it shows cowardly
By the way, why do you have Local time?
And today
IsTradeAllowed(Symbol(), TimeCurrent())
shows cowardly
By the way why do you have Local time?
It's a holiday weekend, so it's hard.
The fact is that none of the recognition functions work 100%.