Cancelled "Sent" and "Submitted" Orders Repopulate

Questions about MultiCharts and user contributed studies.
pmw
Posts: 8
Joined: 21 Aug 2023
Has thanked: 2 times

Cancelled "Sent" and "Submitted" Orders Repopulate

Postby pmw » 31 Aug 2023

Hello,

I am trading an automated strategy that sends stop loss orders and take profit orders immediately on entry of a trade. The stop loss is "Sent" and the take profit is "Submitted" (this is their state in the Order and Position Tracker -> Orders tab).

Sometimes I need to close a position before price hits the stop loss or profit target. Closing the position is no problem but the Sent and Summitted orders need to be cancelled manually.

When I right click on the orders in the Order and Position Tracker -> Orders tab the orders cancel but automatically and immediately repopulate.

Does anyone understand this behavior and why it happens?

Thanks,
Philip

User avatar
Kate MultiCharts
Posts: 596
Joined: 21 Oct 2020
Has thanked: 9 times
Been thanked: 148 times

Re: Cancelled "Sent" and "Submitted" Orders Repopulate

Postby Kate MultiCharts » 01 Sep 2023

Hello Philip,

Orders are being placed again by your strategy, after you manually cancel them. Your strategy is not “aware” of your manual actions.
To cancel and not place orders again after you close a position, you can use the below code in your strategy.

Code: Select all

if MarketPosition_at_Broker <> MarketPosition_at_Broker_for_The_Strategy then begin ChangeMarketPosition(MarketPosition_at_Broker - MarketPosition_at_Broker_for_The_Strategy, close); end;


Return to “MultiCharts”