Generate Trailing Stop on the same bar as entry order  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
User avatar
orad
Posts: 121
Joined: 14 Nov 2012
Has thanked: 50 times
Been thanked: 20 times

Generate Trailing Stop on the same bar as entry order

Postby orad » 16 Jan 2015

How can I generate Trailing Stop on the same bar as entry order? I tried the following and the call to GenerateDollarTrailing does not create any orders. I tried it both with Intra-bar Order Generation (IOG) mode enabled and disabled. Also in the strategy properties I have "Allow up to 2 entry orders in the same direction as the currently held position regardless of the entry that generated the order."

Code: Select all

_thisBar_LE.Send();
CurSpecOrdersMode = ESpecOrdersMode.PerContract;
GenerateDollarTrailing(50);

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

Re: Generate Trailing Stop on the same bar as entry order

Postby Henry MultiСharts » 22 Jan 2015

Hello orad,

GenerateDollarTrailing will generate an order only once there is an open position. If there is no position open - special orders will not be generated. You may find this topic useful.

User avatar
orad
Posts: 121
Joined: 14 Nov 2012
Has thanked: 50 times
Been thanked: 20 times

Re: Generate Trailing Stop on the same bar as entry order

Postby orad » 23 Jan 2015

Hi Henry,

The documentation page for Special Orders does not say anything about the lifetime of Special Orders. I think the confusing part is that the Generate prefix in special order method names may be perceived as new order being sent upon method call, whereas what it does is really to keep the special order active in the current bar, or if it is not called in the current bar then the special order will be canceled. So to keep an special order active at the broker we need to generate it on each consecutive bar and this does not result in re-sending the price orders every time. I think this is important and should be added in the documentation with examples.

Thanks,
orad

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

Re: Generate Trailing Stop on the same bar as entry order  [SOLVED]

Postby Henry MultiСharts » 30 Jan 2015

Order lifetime is described in 4.6.9 Advanced. How The Strategy Backtesting Engine works:
Orders, generated by the signals without IOG, are active from open to close of the bar. Orders generated in IOG mode - are active from the signal calculation to the signal calculation.


Return to “MultiCharts .NET”