Closing a position with C#

Questions about MultiCharts .NET and user contributed studies.
phayes
Posts: 2
Joined: 24 Dec 2015
Has thanked: 1 time

Closing a position with C#

Postby phayes » 16 Jan 2016

Hi,

can anybody help me with an example of how to close a position with code, I have looked at the documentation and online help and failed.

I am getting all long positions with this:

Code: Select all

var buyPositions = Positions[0].OpenTrades.Where(x => x.IsLong);
Then I am attempting to close the long positions using:

Code: Select all

foreach (var p in buyPositions)
{
OrderExit.FromEntry(p.EntryOrder);
PrintLoggingInfo("long position closed due to morning and afternoon sessions being closed.");
}
As you can see I am attempting to use an ITradeOrder when it expects an IOrderObject, any help from anyone would be very grateful.

Regards,

Paul.

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

Re: Closing a position with C#

Postby Henry MultiСharts » 19 Jan 2016

Hello Paul,

Please contact support@multicharts.com regarding this inquiry.


Return to “MultiCharts .NET”