Get the current bar using python and MT5

 

Hi all, could you give me a tip on how to get the current bar in python using the MetaTrader5 library?

I'm trying prices = mt5.copy_rates_from("EURUSD", mt5.TIMEFRAME_M5, today, 10)

but this doesn't return the current bar, as it seems to have a delay of 2 hours.

how could i do day trade without this information ?

or maybe i must to create the code and develope a robot operation with meta editor ?

thank for your support

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Muriloxavier123: Hi all, could you give me a tip on how to get the current bar in python using the MetaTrader5 library?


I'm trying prices = mt5.copy_rates_from("EURUSD", mt5.TIMEFRAME_M5, today, 10)

but this doesn't return the current bar, as it seems to have a delay of 2 hours.

how could i do day trade without this information ?

or maybe i must to create the code and develope a robot operation with meta editor ?

Use copy_rates_from_pos instead.

start_pos

[in]  Initial index of the bar the data are requested from. The numbering of bars goes from present to past. Thus, the zero bar means the current one. Required unnamed parameter.

Documentation on MQL5: Python Integration / copy_rates_from_pos
Documentation on MQL5: Python Integration / copy_rates_from_pos
  • www.mql5.com
copy_rates_from_pos - Python Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

i would like to thank you!

very kind, thank you