MetaTrader 5 Python User Group - how to use Python in Metatrader - page 79

 
Rashid Umarov:

Because the head() method(https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.head.html) returns an object, not a log output. To see the content, you need to explicitly send the object to print()

This anaconda for convenience outputs the objects as if print() was called.

Isuccessfully use the head method - without print - for various examples injupyter notebook. But this method does not work with the DataFrade object that MetaEditor creates. Therefore I asked - what is wrong with the object created by MetaEditor? Why does the head method work for all the examples, but not for the object created by MetaEditor?

 
Vladimir Karputov:

Isuccessfully use head method for different examples injupyter notebook - without print. But this method does not work for DataFrade object, which is created by MetaEditor. That's why I asked - what is wrong with the object created by MetaEditor? Why does it work for all of the examples, but not for the object created by MetaEditor?

IPython automatically outputs (understands what to print), the terminal apparently interprets it differently

 
Maxim Dmitrievsky:

IPython outputs automatically (understands what to print), the terminal apparently interprets it differently

So I'm not running the example in the terminal. All marked DataFrame objects successfully print five lines using head method, but not the object created in MetaEditor.

 
Vladimir Karputov:

This is how I run the example, not in the terminal. All marked DataFrame objects successfully print five lines using the head method, but not the object created in MetaEditor.

Well, then it's a mystery.

You have two duplicates of the code in the listing, by the way.
 
Maxim Dmitrievsky:

Well, then it's a mystery.

You have two duplicates of the code in your listing, by the way.

Thanks, copypast probably.

 

Hi.

I'm in trouble!

I can't figure out why there's an error.

Anyway.

  1. Installed anaconda.
  2. Did conda update conda, conda update anaconda
  3. Installed PyCharm.
  4. Created a new project pr1.
  5. ExitedPyCharm.
  6. In thepr1 environmentdid a pip install metatrader5
  7. StartedPyCharm
  8. Added import metatrader5 as mt5 - and here starts the problem....

WhilePyCharm is indexing something there I see following picture:


But, when the indexing ends and I run the code .... :


There is nometatrader5 module.How come? It's there in the project settings, it's there in Anaconda, but when I run it, it's not there!!!!

What's wrong?

 

My own answer.

importmetatrader5 as mt5 - wrong

Correct:import MetaTrader5 as mt5

 

How do I get a numpy array so that each value in it is incremented by 1?

As long as you needed a few elements, this number worked:

import numpy as np

X = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

but how do you do it if you need an array of 100 elements?

 
Vladimir Karputov:

How do I get a numpy array so that each value in it is incremented by 1?

As long as you needed a few elements, this number worked:

but how do I do it if I need an array of 100 elements?

np.arange(100)

np.array([xfor x inrange(100)] )
 

Another question from a newcomer.

The situation is as follows. I have an indicator. When I add it to the chart in "cold" mode, it takes 7-8 seconds to be calculated.

I have done the same in python. The difference is that python saves the data in a .csv file.

Calculation in both cases is from 01.01.2019

Now the question: why can this happen?


Python has been working on the task for two and a half hours! It's just a shame to stop it... What if it's already over...


Just a little something to add. It's all tied up at

copy_ticks_range

Requesting ticks for one day.



Finished... Almost three hours. What's to think? <<<<< that means 2:58.




I understand connection losses to MT5, other overheads.... But, 8 seconds vs 3 hours..... ???????? HOW ???????????