Scaling Out

Questions about MultiCharts .NET and user contributed studies.
bryanzim
Posts: 36
Joined: 26 Mar 2013
Has thanked: 5 times
Been thanked: 3 times

Scaling Out

Postby bryanzim » 25 Apr 2013

To whom it may concern:

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);
}
In method 1 I get no fills.

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);
}
In method #2 I get both contracts filled at the 1st limit price instead of 1.

Please give correct code snippet for partial exits with single entry.

Thanks,
Bryan Z

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

Re: Scaling Out

Postby Henry MultiСharts » 26 Apr 2013

Hello Brian,

Is the a typo in your description?
In method #2 I get both contracts filled at the 1st limit price instead of 1.
Please attach a detailed problem description and highlight the problem on the screenshots.

bryanzim
Posts: 36
Joined: 26 Mar 2013
Has thanked: 5 times
Been thanked: 3 times

Re: Scaling Out

Postby bryanzim » 28 Apr 2013

I was able to create a scale out strategy after discovering two important points.

First, the stop and limit entries must be entered on each CalcBar and do not remain in effect.

For example,

Code: Select all


void CalcBar() {
m_SellStop.Send(m_StopPrice, (int) OpenContracts);
m_SellLimits[targetx].Send(m_TargetPrices[targetx], (int) m_TargetContracts[targetx]);
}
instead of

Code: Select all


void CalcBar() {
if (!b_ExitsSet) {
m_SellStop.Send(m_StopPrice, (int) OpenContracts);
m_SellLimits[targetx].Send(m_TargetPrices[targetx], (int) m_TargetContracts[targetx]);
b_ExistsSet=true;
}
}
next I had to use

Code: Select all

m_SellLimits[i] = OrderCreator.Limit(new SOrderParameters(Contracts.Default, "SellLmt"+(i+1).ToString(), EOrderAction.Sell, OrderExit.Total));
instead of

Code: Select all

m_SellLimits[i] = OrderCreator.Limit(new SOrderParameters(Contracts.Default, "SellLmt"+(i+1).ToString(), EOrderAction.Sell, OrderExit.FromAll));
Then I was able to scale with partials, i.e. enter with two and exit 1 at a time at either a stop or limit.

I did notice that the performance report shows a single entry and two exits as two trades and three exists as three trades, etc., is there a way to group the different exits as 1 trade with a total P/L for the entire trade?

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

Re: Scaling Out

Postby Henry MultiСharts » 30 Apr 2013

I did notice that the performance report shows a single entry and two exits as two trades and three exists as three trades, etc., is there a way to group the different exits as 1 trade with a total P/L for the entire trade?
Hello bryanzim,

There is no way to change that at the moment.


Return to “MultiCharts .NET”