Show profit and loss values
-
Does anyone here have any example of how to display profit or loss over a period of time on the screen?
What I exactly want is to show in dollarsProfit so far on the current day
Profit so far in the current week
Earnings so far in the current monthLoss so far in the current day
Loss so far in the current week
Loss so far in the current monthIf it is possible to show me some project example in Fxdreema?
-
@ontradingx Hello,
Here is an example of how to show the profit equity so far per day. From that example you will have an idea of how to do it per week or month.
Create a variable that on the start of each day gets set to your accounts equity. After that create a formula that subtracts the current equity from it and display it on the comment block.
Keep in mind that by using these blocks run per tick and if your broker stops trading the price movements at midnight, then the block that sets the equity will not pass as I have set it in the example to 00:00. What I would do is just place a (once per bar) block and set the time frame to D1 so that with the open of each daily candle, the variable will be set no matter what time the broker start showing prices.
There may be a simpler way that others can share, but that's the way I know.

-
@ontradingx If you want to display the profit of closed trades, then that's a simpler story. Here is how to do it.

-
https://fxdreema.com/shared/PO7lWT8ye

Thanks for helping.
I've been trying this way and what happened is it doesn't show on the screen what I need. See the image above.What I need is for the block to search for information on trades already closed, each one of the trades has to be computed in the gains or losses.
I'm trying different ways and I don't see anything being written to the variable.What I want is that when the EA is put on the chart it checks all closed trades and separates them by day, week, month and year.
With this, each new closed trade will keep these balances updated.
If I graphed the EA now, then it should get these values:
Daily gain - When placing the EA on the chart, it should check if there was any trade on the same day, if there was it shows its total value, if not it will show the value 0, if I open and close the trade it should show the value from this negotiation and only reset the next day and every day repeat this same routine.
Weekly gain - When placing the EA on the chart, get the values we already have of gain for the week, from Sunday (when the market starts) and sum up the profits and losses for the entire week until Friday (when the market closes).
Every Sunday this balance must be reset.Monthly gain - When placing the EA on the chart it must obtain the sum of all gains and losses from the first day of the month to the last day of the month, this value must always be reset to zero on the first day of the following month.
Annual gain - When placing the EA on the chart it should get and update the sum value of all gains or losses from the first day of the year to the last day of the year.
Always reset the information on the first day of the following year.This is the project I'm testing.
https://fxdreema.com/shared/PO7lWT8ye -
@ontradingx Are you sure the WHOLE history of closed trades is available on your MT4. You are requiring your EA to search for a lot of trades.
-
@l-andorrà Yes, I need to get information about these negotiations, I need them to be displayed on the screen, I want to look at the present and the past at all times.
-
@ontradingx Then you need something like this:
https://fxdreema.com/shared/KOgbxxzac
The first block tree searches for ope trades right now and the second one for the closed ones. You need to add the appropriate time filter onc each tree and you will need as many trees as requested searching periods, of course.
-
@ontradingx In my two examples, one shows the profit loss of live trades and the other shows the profit/loss of closed trades. I see that you used the closed trades version but expected it to work on live trades. Use the other method.