Close all positions attached to a strategy

Questions about MultiCharts .NET and user contributed studies.
drolles
Posts: 50
Joined: 03 Dec 2012
Has thanked: 4 times

Close all positions attached to a strategy

Postby drolles » 06 Jan 2013

Can I close all positions attached to a strategy?

Thanks and regards,

drolles

drolles
Posts: 50
Joined: 03 Dec 2012
Has thanked: 4 times

Re: Close all positions attached to a strategy

Postby drolles » 08 Jan 2013

If not a in-build method, possible workaround:

Code: Select all

if (PositionSide != 0)
{

if (PositionSide == 1)
{

//long_exit_orders_market[exit_counter].Send();
long_exit_order.Send(CurrentPosition.OpenLots);
exit_counter++;


}
else if (PositionSide == -1)
{

//short_exit_orders_market[exit_counter].Send();
short_exit_order.Send(CurrentPosition.OpenLots);
exit_counter++;


}

}

MidKnight
Posts: 343
Joined: 12 Aug 2012
Has thanked: 123 times
Been thanked: 56 times

Re: Close all positions attached to a strategy

Postby MidKnight » 08 Jan 2013

For whats what its worth, your first if block is redundant - thanks for the code snippet post :)

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Close all positions attached to a strategy

Postby Henry MultiСharts » 09 Jan 2013

Hello drolles,

You can use Sell and BuyToCover order commands for closing the position.


Return to “MultiCharts .NET”