Combine multiple profit values within the same bar to form an added numerical value in the chart.
-
Good evening,
Every time I close a trade, I want to see the respective profit / loss on the chart as a numerical value. That works fine too. But only if only one trade per bar is closed. If multiple trades are closed in the same bar, only the value of one of the closed trades in this bar can you see. How can I change this? It would be best if the profit values of all trades that were closing in a bar would be added to a single numerical value.
In the two attached screen shots you can see what I mean. How can I solve this best?
Many thanks for your help
Rupprecht!


-
@rupp I think you have everything you need. Just store the "orderprofit" in a variable and add the profit off all trades in that candle. if candle closes you reset that variable and start again from 0 on the next candle.
-
Thank you, TraderPhillips,
Can you help me a little further, because I have never done anything like this?
Maybe with an example? So how do I save all orderprofits of a candle in a variable?
Do I have to do this in "onTick" or "onTrade?
And how to reset that variable and start again from 0 on the next candle? -
@rupp Sorry to say, it looked easier as it is. Maybe @miro1360 could have a look as he is more experienced with order and order history than me.
What I tried to do is to loop through the order history and calculate the candle time of the order close for each trade. Afterwards I wanted to sum all profits from the last close trade (on trade tab).
However, I didn't find a function that supports me calculating the candle time (which should be the candle open time) or candle ID from an order close time. So maybe there is a different approach. -
Many thanks @trader.philipps
I'll ask @miro1360 if he can help here.
Rupprecht -

-
Thank you very much Miro,
that was exactly what I was looking for. It works very well.
The only small note: The two blocks must be placed in "on Trade" and not in "on Tick".
Hopefully it will benefit another user.