I have been trying to implement a scaling out strategy but have been unsuccessful. If I have the default number of contracts set to 2, I have tried the following two methods. The code is simplified to show only 1 side, and I have verified that the Stop and Limit prices are correct.
Method #1
Code: Select all
Create() {
// create sell stop order
m_SellStop = OrderCreator.Stop(new SOrderParameters(Contracts.CreateUserSpecified(1), "SellStop", EOrderAction.Sell, OrderExit.FromAll));
// create sell limit orders
m_SellLimit1 = OrderCreator.Limit(new SOrderParameters(Contracts.CreateUserSpecified(1), "SellLmt1", EOrderAction.Sell, OrderExit.FromAll));
m_SellLimit2 = OrderCreator.Limit(new SOrderParameters(Contracts.CreateUserSpecified(1), "SellLmt2", EOrderAction.Sell, OrderExit.FromAll));
}
CalcBar() {
m_SellStop.Send(m_StopPrice, 2);
m_SellLimit1.Send(m_Lmt1Price, 1);
m_SellLimit2.Send(m_Lmt2Price, 1);
}
Method #2
Code: Select all
Create() {
// create sell stop order
m_SellStop = OrderCreator.Stop(new SOrderParameters(Contracts.Default, "SellStop", EOrderAction.Sell, OrderExit.FromAll));
// create sell limit orders
m_SellLimit1 = OrderCreator.Limit(new SOrderParameters(Contracts.Default, "SellLmt1", EOrderAction.Sell, OrderExit.FromAll));
m_SellLimit2 = OrderCreator.Limit(new SOrderParameters(Contracts.Default, "SellLmt2", EOrderAction.Sell, OrderExit.FromAll));
}
CalcBar() {
m_SellStop.Send(m_StopPrice, 2);
m_SellLimit1.Send(m_Lmt1Price, 1);
m_SellLimit2.Send(m_Lmt2Price, 1);
}
Please give correct code snippet for partial exits with single entry.
Thanks,
Bryan Z