sending a Sell Stop order  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
szoi
Posts: 8
Joined: 29 Jan 2015
Has thanked: 7 times

sending a Sell Stop order

Postby szoi » 16 Feb 2015

Hi
I know this is a dummy's request, but I'm not able to solve this simple task.
I want to send priced a Sell order, to be filled at a defined price.
Here is the code.

Code: Select all

IOrderPriced SellStopOeder;
IOrderMarket ExitOrder;

int OnBars;
public _zD_SellStopTest(object _ctx) : base(_ctx)
{
}

protected override void CalcBar()
{
if (StrategyInfo.MarketPosition == 0) {
SellStopOeder.Send(Bars.HighValue);
OnBars = 0;
} else {
OnBars += 1;
if (OnBars == 5) {
ExitOrder.Send();
}
}
}
protected override void Create()
{
SellStopOeder = OrderCreator.Stop(new SOrderParameters(Contracts.Default, "SellStop", EOrderAction.Sell));
ExitOrder = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, "ExitBuy", EOrderAction.Buy));
}
}
This way the order's never executed.
Note:
If I send a Buy order, all works fine

Code: Select all


SellStopOeder = OrderCreator.Stop(new SOrderParameters(Contracts.Default, "BuyStop", EOrderAction.Buy));
ExitOrder = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, "Exit", EOrderAction.Sell));
Thank you in advance

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

Re: sending a Sell Stop order  [SOLVED]

Postby Henry MultiСharts » 17 Feb 2015

Hello szoi,

You need to use SellShort in your code, not Sell.
Buy and SellShort are for opening/reversing a position.
Sell and BuyToCover are for closing an open position.


Return to “MultiCharts .NET”