Strategy P/L and the Open P/L was completely different

Questions about MultiCharts and user contributed studies.
jmoreno127
Posts: 1
Joined: 01 Aug 2017
Location: Bogotá, Colombia
Has thanked: 1 time
Contact:

Strategy P/L and the Open P/L was completely different

Postby jmoreno127 » 20 Jan 2020

Hi!

Here is my situation:

I have a system that opened two positions as we can see next:
Screen Shot 2020-01-20 at 12.14.57 PM.png
(87.61 KiB) Not downloaded yet
The first position was at @0.89680 and the second was at @0.89671. I already have implemented the function "From !Broker to !Strategy" to Sync the Orders as I need to take care of certain positions on the Broker (LMAX NZ) Web Service. I closed the second position on LMAX NZ Web Service as it can be seen on the next screenshot, but in the Platform, the Sync Order was generated for the First Position.
WhatsApp Image 2020-01-20 at 12.16.16 PM.jpeg
(50.81 KiB) Not downloaded yet
It leads to a big error since the strategy P/L and the Open P/L was completely different since the Broker showed me CAD-7.02, the chart showed me CAD1.22. Due to I have a take profit in place, the strategy closed the whole position thinking that the P/L was CAD1.22 while the actual P/L was CAD-7.02.

How can I deal with it if I have to keep this semi-automated framework for my work? How can I have from a Powerlanguage Keyword the Open P/L (from Broker) or How can I fix that the sync order is made on the actual trade and not in the first trade of the open position?

Thanks in advance for your help!

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: Strategy P/L and the Open P/L was completely different

Postby Svetlana MultiCharts » 24 Jan 2020

By default, From Broker To Strategy MP Synchronizer attaches the exit order to the first opened position.
In LMAX you can choose which position to close, while you cannot choose it in MultiCharts — the order is attached to the first position.
For example, if you close the first position in LMAX, the Synchronizer will send the Exit order attached to the first position, and there will be no difference between the Strategy P/L and the Open P/L.
If you close the second position in LMAX, the Synchronizer will send the Exit order attached to the first position, and there will be a difference between the Strategy P/L and the Open P/L, as different positions were closed in LMAX and MC.

The possible solutions are:
— Close positions in LMAX in that order in which they were opened.
— Modify the Synchronizer’s script so that is flattens all positions in the chart and opens the rest part of the position. To do it replace the following code string:

Code: Select all

ChangeMarketPosition(broker_mp - inner_mp, _exit_price, "Sync Order");
By:

Code: Select all

ChangeMarketPosition(-inner_mp, close, " SinchronizerCloseAllPosition "); ChangeMarketPosition(broker_mp, AvgEntryPrice_at_Broker, " SinchronizerOpenSharePosition ");
The modified From Broker To Strategy MP Synchronizer is attached.
From Broker To Strategy MP Synchronizer.pla
(9.53 KiB) Downloaded 108 times


Return to “MultiCharts”