Having trouble with multiple Entry Order objects...

Questions about MultiCharts .NET and user contributed studies.
drmrboyc
Posts: 7
Joined: 22 Mar 2013
Has thanked: 1 time

Having trouble with multiple Entry Order objects...

Postby drmrboyc » 16 Apr 2013

I'm trying to manage multiple entries and exits with the following order objects:

Code: Select all

buy_order_1 = OrderCreator.MarketThisBar(new SOrderParameters(EOrderAction.Buy, "LE_1"));
buy_order_2 = OrderCreator.MarketThisBar(new SOrderParameters(EOrderAction.Buy, "LE_2"));

sell_order_1 = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, "LX_1", EOrderAction.Sell, OrderExit.FromEntry(buy_order_1)));
sell_order_2 = OrderCreator.MarketThisBar(new SOrderParameters(Contracts.Default, "LX_2", EOrderAction.Sell, OrderExit.FromEntry(buy_order_2)));
I then place the orders with this code:

Code: Select all

buy_order_1.Send();
buy_order_2.Send();
However, only 1 order is placed?

Is there something I'm doing wrong with the objects?

Thanks!

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

Re: Having trouble with multiple Entry Order objects...

Postby Henry MultiСharts » 17 Apr 2013

Hello drmrboyc,

Make sure you have enabled "Allow up to N entry orders in the same direction as the currently held position" option in Format->Strategy properties->Properties tab.

drmrboyc
Posts: 7
Joined: 22 Mar 2013
Has thanked: 1 time

Re: Having trouble with multiple Entry Order objects...

Postby drmrboyc » 17 Apr 2013

I got it set to 999 entries, so I don't believe that is causing issues.

If the code looks like it should be working, are there any other settings that could be causing only the first order to enter/exit?

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

Re: Having trouble with multiple Entry Order objects...

Postby Henry MultiСharts » 19 Apr 2013

As we can see in your code-this function always exits (the condition in the code is always met):

Code: Select all

if (Bars.Status != EBarState.Close || (Bars.High[0] >= Bars.High[1] || Bars.Low[0] <= Bars.Low[1])) return;
Your code trades only when this function returns a status. Our developer has changed the code so that it returns a status required for trading. As we do not know your exact logic-please adjust it the way you need:

Code: Select all

if (Bars.Status != EBarState.Close && (Bars.High[0] >= Bars.High[1] || Bars.Low[0] <= Bars.Low[1])) return;
or

Code: Select all

if (Bars.Status != EBarState.Close || (Bars.High[0] >= Bars.High[1] && Bars.Low[0] <= Bars.Low[1])) return;
such versions of code generate orders.


Return to “MultiCharts .NET”