MetaTrader 5 Python User Group - Comment utiliser Python dans Metatrader - page 21

 

https://www.mql5.com/ru/docs/integration/python_metatrader5/mt5copyratesrange_py

L'exemple utilise une fonction différente, une erreur :

# obtenir des barres avec USDJPY M5 à partir du 01.04.2019 dans le fuseau horaire UTC
rates=MT5CopyRatesFrom("USDJPY",MT5_TIMEFRAME_M5,utc_from, utc_to)

attendu : MT5CopyRatesRange()

Документация по MQL5: Интеграция / MetaTrader для Python / MT5CopyRatesRange
Документация по MQL5: Интеграция / MetaTrader для Python / MT5CopyRatesRange
  • www.mql5.com
# создадим объекты datetime в таймзоне UTC, чтобы не применялось смещение локальной таймзоны                             MT5Rate(time=datetime.datetime(2019, 4, 1, 0, 0),  open=110.994, low=110.994, high=110.966, close=110.966, tick_volume=12, spread=22, real_volume=0...
 

Pour convertir la date dans un fuseau horaire spécifique, l'aide suggère d'utiliser datetime UTC

Cependant, cela ne change rien. Lorsque vous définissez un fuseau horaire, l'heure du terminal est prise en compte (dans mon cas, c'est GMT+2).

 
Rashid Umarov:
Quel est le numéro de fabrication?

pip install --upgrade MetaTrader5

Exigence déjà à jour : MetaTrader5 dans c:\works\mt_websocket_server\.env\lib\site-packages (5.0.8)



 
peut-on tout déplacer en un seul endroit?
MetaTrader 5 Python User Group - как использовать Python в Метатрейдере
MetaTrader 5 Python User Group - как использовать Python в Метатрейдере
  • 2019.11.25
  • www.mql5.com
Мы готовим модуль MetaTrader 5 для Python, аналогичную R...
 
Maxim Dmitrievsky:
Peut-on tout regrouper en un seul endroit?

Laquelle ? Tout le fil de discussion ?

 
Дмитрий Прокопьев:

C'est lequel ? Tout le fil de discussion ?

Ouais, pour avoir tout le truc python en un seul endroit.

Les modérateurs le déplaceront.

 
Maxim Dmitrievsky:

Oui, pour avoir tout sur Python en un seul endroit.

Les modérateurs le déplaceront.

Ok, s'ils peuvent le déplacer, qu'ils le fassent. Re-créer, pas vraiment ...
 

Forum sur le trading, les systèmes de trading automatisé et les tests de stratégies de trading

La librairie python de MetaTrader5 et MT5CopyRatesFrom - bizarrerie ou bug ?

Dmitry Prokopyev, 2019.11.30 10:59

Bonjour à tous.

Je suis tombé sur cette bizarrerie dans les données retournées par MT5CopyRatesRange et d'autres fonctions.

from datetime import datetime
from MetaTrader5 import *
import pandas as pd
import json

from pytz import timezone
utc_tz = timezone('Etc/UTC')
 
MT5Initialize()
MT5WaitForTerminal()

# rates = MT5CopyRatesRange("EURUSD", MT5_TIMEFRAME_H1, datetime(2018,4,3), datetime(2018,4,4))
rates = MT5CopyRatesFrom("EURUSD", MT5_TIMEFRAME_H1, datetime(2018,4,3,17, tzinfo=utc_tz), 5)

MT5Shutdown()
rates_frame = pd.DataFrame(rates, columns=['time', 'open', 'low', 'high', 'close', 'tick_volume', 'spread', 'real_volume'])
print(rates_frame)
print(rates)

Tout est trivial, mais la sortie que nous avons :

                 time     open      low     high    close  tick_volume  spread  real_volume
0 2018-04-03 13:00:00  1.23073  1.23154  1.22861  1.22882         5090       1            0
1 2018-04-03 14:00:00  1.22882  1.23057  1.22863  1.23018         6112       1            0
2 2018-04-03 15:00:00  1.23018  1.23149  1.22919  1.22957         6691       1            0
3 2018-04-03 16:00:00  1.22957  1.22989  1.22557  1.22580        11956       1            0
4 2018-04-03 17:00:00  1.22580  1.22746  1.22536  1.22730        10275       1            0
(MT5Rate(time=datetime.datetime(2018, 4, 3, 13, 0), open=1.2307299999999999, low=1.23154, high=1.22861, close=1.22882, tick_volume=5090, spread=1, real_volume=0), 
MT5Rate(time=datetime.datetime(2018, 4, 3, 14, 0), open=1.22882, low=1.23057, high=1.2286299999999999, close=1.23018, tick_volume=6112, spread=1, real_volume=0), 
MT5Rate(time=datetime.datetime(2018, 4, 3, 15, 0), open=1.23018, low=1.23149, high=1.22919, close=1.22957, tick_volume=6691, spread=1, real_volume=0), 
MT5Rate(time=datetime.datetime(2018,4, 3, 16, 0), open=1.22957, low=1.22989, high=1.22557, close=1.2258, tick_volume=11956, spread=1, real_volume=0), 
MT5Rate(time=datetime.datetime(2018, 4, 3, 17, 0), open=1.2258, low=1.22746, high=1.22536, close=1.2273, tick_volume=10275, spread=1, real_volume=0))

Je veux attirer votre attention sur :

MT5Rate(time=datetime.datetime(2018,4, 3, 16, 0), open=1.22957, low=1.22989, high=1.22557, close=1.2258, tick_volume=11956, spread=1, real_volume=0)

aller au terminal, voir bas/haut pour ce cadre :

Nous voyons que lebas = 1.22557, lehaut = 1.22989.

Question : s'agit-il d'un bug ou les touches du MT5Rate sont-elles configurables ?


MetaTrader 5 Python User Group - как использовать Python в Метатрейдере
MetaTrader 5 Python User Group - как использовать Python в Метатрейдере
  • 2019.11.25
  • www.mql5.com
Мы готовим модуль MetaTrader 5 для Python, аналогичную R...
 
Déplacé maintenant dans ce fil.
Raison: