MetaTrader 5 Python User Group - how to use Python in Metatrader - page 76
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Thank you, Maxim!
I'm already trying it out. The cycle has started, but the file is not opening yet. I will leave the loop in operation and wait.
Regards, Vladimir.
P.S. Pardon! Didn't pay attention at once to what stands hour. I changed it to minute EUR_USD_QUOTE.csv file was opened but I got this message in Run tab of Pycharm:
�訡��: �� 㤠���� ���� ����� "excel.exe".
Then after another minute or so, the file closed and reopened, but in Exel a tab appeared on the left side of the spreadsheet asking me to save the previously opened text. I waited a bit longer to see what would happen next, but then the cycle stopped and a message like this appeared:
�ᯥ譮: ����� "EXCEL.EXE", � �����䨪�� 4208, � �����襭.
�ᯥ譮: ����� "EXCEL.EXE", � �����䨪�� 3168, �� �����襭.
Traceback (most recent call last):
File "C:/Users/Vladimir/PycharmProjects/My_Python_Project/9.py", line 37, in <module>
get_data(save_file='EUR_USD_QUOTE.csv')
File "C:/Users/Vladimir/PycharmProjects/My_Python_Project/9.py", line 23, in get_data
with open(save_file, 'w') as save:
PermissionError: [Errno 13] Permission denied: 'EUR_USD_QUOTE.csv'
This is the result so far, but I already made progress!
Sincerely, Vladimir.
Maybe Excel didn't have time to close and was trying to access the file already, then
Add a 5-10 second delay here, and the program will wait for Excel to close
I have not decided what to do with the window on the left )
I want to learn how to take quotes on the Internet using the language Python to watch them not in the terminal, but in some file, for example, csv. I thought it was the most basic task, but it turned out that it wasn't. Maybe I'm on the wrong track, but the one who is not looking for anything, he finds nothing.
Now I'll move on to the code you've proposed. After the code was launched, a message appeared in the Pycharm development environment :
Traceback (most recent call last):
File "C:/Users/Vladimir/PycharmProjects/My_Python_Project/10.py", line 25, in <module>
main()
File "C:/Users/Vladimir/PycharmProjects/My_Python_Project/10.py", line 13, in main
eurusd_bid = soup.find('td', 'pid-1-bid').text.replace(',', '.')
AttributeError: 'NoneType' object has no attribute 'text'
Process finished with exit code 1
What do I need to change to see how the code works?
Respectfully, Vladimir.
The reason why it's not working is because this site has blocked you from sending requests. The fact that you had to fake a user agent must have been a hint that you were doing something they didn't want you to do. Web scanning is way beyond the scope of this topic, so we should stop talking about it and get back to the subject at hand. Do you have any questions about using the MetaTrader5 package?
It may not have time to close Excel and is trying to access the file, then
add a 5-10 second delay, the program will wait for Excel to close
I have not yet decided what to do with the left window )
Maxim, thank you very much for the code, which you have helped me to improve. The left panel is of little concern at the moment. I will add your new code later, most likely at the weekend, as I have been completely swamped at work today and need a rest. I will let you know as soon as I get new results.
Regards, Vladimir.
On which offset does the MT5 library return the time of open orders?
But in the terminal it is a different time
How do I correctly synchronize the time in the python program with the time of orders (positions)?
On which offset does the MT5 library return the time of open orders?
But in the terminal it is a different time
How do I correctly synchronize the time in the python program with the time of orders (positions)?
First you need to know the exact time zone of the trade server. Then create a time zone object using pytz. Finally, pass the time zone object to a method.
https://stackoverflow.com/questions/13866926/is-there-a-list-of-pytz-timezonesFirst you must know the exact time zone of the trade server. Then create a time zone object using pytz. Finally, pass the time zone object to the method.
https://stackoverflow.com/questions/13866926/is-there-a-list-of-pytz-timezonesThanks, I'll try it like this
I would like to synchronise the time automatically as the trading server may changethanks, I'll try this
I would like to synchronize the time automatically, because the trade server may changeUNIX timestamps are timezone agnostic so you need to know the broker timezone to give the timestamp timezone aware context. The only way to do that is to know the trade-server's timezone setting. I don't think that there is any way to obtain that information programmatically. What you can do is create a config file to map the different trade servers that you may be using to timezone. Example:
config.json
UNIX timestamps are timezone agnostic so you need to know the broker timezone to give the timestamp timezone aware context. The only way to do that is to know the trade-server's timezone setting. I don't think that there is any way to obtain that information programmatically. What you can do is create a config file to map the different trade servers that you may be using to timezone. Example:
config.json
well... yes
easier way without pytz:
Also we can open one pending order far from the price, before starting EA. And compare difference in hours between 'pt' anddatetime.utcnow()
to automatically offset timewell ... yes
easier way without pytz:
Also we can open one pending order far from the price, before start EA. And compare difference in hours between 'pt' and to automatically offset timeI thought the same thing but then I remembered that the order time is stored in a UNIX timestamp which does not have a timezone. In other words, you cannot extrapolate the broker timezone from the order timestamp because timestamps are the same no matter the timezone. If you want to know the GMT offset you have to know the current terminal (broker) time and there's currently no way to use python to get the current terminal time or GMT offset.
It may not have time to close Excel and is trying to access the file, then
you may add a 5-10 second delay, the program will wait for Excel to close
I have not decided what to do with the window on the left )
Hello Maxim!
I promised you earlier that at the weekend I would check the variant with delay code addition. I have checked it, but the delay has not affected anything. I have no problems with the left tab, because I simply do not pay attention to it.
Once again, thank you very much for your assistance. I will not ask any more questions in this thread.
Regards, Vladimir.