Error -2 'Invalid arguments'

 

I've been trying to solve this problem for days and days but I can't. I'm on the verge of a nervous breakdown!

I run the Script 'A.py' and every time the mt5.copy_rates_range function, with diffrent arguments, it always gives me the error -2 'Invalid arguments'.

The beauty is that, these same arguments, inserted in the same function in another Script 'B.py' always work perfectly.


Python Script 'A.py':

………………
# long Script preceding the following rows:
print("Symbol:",Symbol,"timeframe:",timeframe,"startTime:",startTime,"endTime:",endTime)
# Output on Screen:
# Symbol: BTCUSD  timeframe: 10  startTime: 1632044400  endTime: 1632062438
quote = mt5.copy_rates_range(Symbol,timeframe,startTime,endTime)
print(quote) # output is empty
print("Last Error:",mt5.last_error()) # Error: -2, 'Invalid arguments'
………………
# continue Script


Python Script 'B.py':

Symbol = "BTCUSD"
timeframe = 10
startTime = 1632044400
endTime = 1632062438
quote = mt5.copy_rates_range(Symbol,timeframe,startTime,endTime)
print(quote) # Here, it's ok! The dataframe is not empty!
Documentation on MQL5: Integration / MetaTrader for Python / copy_rates_range
Documentation on MQL5: Integration / MetaTrader for Python / copy_rates_range
  • www.mql5.com
copy_rates_range - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Ataros:

I've been trying to solve this problem for days and days but I can't. I'm on the verge of a nervous breakdown!

I run the Script 'A.py' and every time the mt5.copy_rates_range function, with diffrent arguments, it always gives me the error -2 'Invalid arguments'.

The beauty is that, these same arguments, inserted in the same function in another Script 'B.py' always work perfectly.


Python Script 'A.py':


Python Script 'B.py':

Is "Symbol" a string and not a class with __repr__ or __str__ methods? Also, are the rest of the variables numbers and not strings?
You can check their type with:

print(type(startTime))
 

Alexandre, thanks for answering me.

print(type(Symbol))    # -> <class 'str'>
print(type(timeframe)) # -> <class 'int'>
print(type(startTime)) # -> <class 'int'>
print(type(endTime))   # -> <class 'numpy.int64'>

What does a data type 'numpy.int64' mean?

And most importantly, how can I convert it to an 'int' data type?

 

Thanks again, Alexandre.

endTime = int(endTime)
Reason: