Since I'm new here - I would like to get some help in annoying situation:
I'm developing in Python a trading robot and would like to check if a trade is profitable or not.
In the attached file, in the history section there are done trades - profitable and lose trades.
I already know how to connect to my EA and get the open trades with mt5.positions_get but
I couldn't find how to get the data of the closed trades including the profit of them.
Thanks for any help
This is probably:
Get the number of deals in trading history within the specified interval
Get deals from trading history with the ability to filter by ticket or position
Looks like history_deals_get is what I need
Thanks a lot !!!
import MetaTrader5 as Mt5
from datetime import datetime, timedelta
Mt5.history_deals_get((datetime.today() - timedelta(days=1)), datetime.now())[-1].profit
You can get the last deals in this way.
Also, if you have an interest, I have a library that helps integrate MQL5 to Python.
You can found it here:
Thank you João.
I'm starting now, could you tell me how to plot a simple average in Metatrader, by python,
just for example. (I don't know exactly how to "plot" I mean show the average on the graph)
Hi Mateus Lopes, how are you?
The main objective for the python code is to return only the numbers that you requested for. It is intended to be used in trading automation, where there is no need for visual information like a graph, the expert advisor/"robot" only need numbers. However, if you want to plot a graph using python, we can talk about it. I will send you a personal message.
But, if the idea is just visualization, you can use the graph directly through the Metatrader5.
I will send you a message.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.