Algorithmic orders, OCO, OSO, TRSTP  [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

Algorithmic orders, OCO, OSO, TRSTP

Postby orad » 15 Jan 2015

In the Supported Brokers page it indicates that for most of the brokers OCO and Trailing Stops are tracked by MultiCharts, and sent when appropriate. Does that mean that the strategy developer has to do the monitoring in the CalcBar method and send orders or is it totally handled by MC.NET? I haven't been able to find any code example of OCO, Bracket OCO, or OSO for MC.NET.

Also for Trailing Stops, are they only available through GenerateDollarTrailing and GeneratePercentTrailing special orders? They don't handle the case where profit amount is not reached. For example if a long position is opened at price 100 and GenerateDollarTrailing(2) is called that does not stop at price 98 because it has not reached the profit amount of 2. Instead if it goes to 102 it will activate a Trailing Stop at price 100. For that I think the developer has to write code to set a stop at price 98 and when the profit amount is reached and Trailing Stop is generated then cancel the original stop. I can't find any examples that can help me to implement this. Please help.

Thanks!
orad

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Algorithmic orders, OCO, OSO, TRSTP

Postby Andrew MultiCharts » 16 Jan 2015

Hello orad,
In the Supported Brokers page it indicates that for most of the brokers OCO and Trailing Stops are tracked by MultiCharts, and sent when appropriate. Does that mean that the strategy developer has to do the monitoring in the CalcBar method and send orders or is it totally handled by MC.NET? I haven't been able to find any code example of OCO, Bracket OCO, or OSO for MC.NET.
All orders generated at a particular calculation are in the same OCO group.
Also for Trailing Stops, are they only available through GenerateDollarTrailing and GeneratePercentTrailing special orders? They don't handle the case where profit amount is not reached. For example if a long position is opened at price 100 and GenerateDollarTrailing(2) is called that does not stop at price 98 because it has not reached the profit amount of 2. Instead if it goes to 102 it will activate a Trailing Stop at price 100. For that I think the developer has to write code to set a stop at price 98 and when the profit amount is reached and Trailing Stop is generated then cancel the original stop. I can't find any examples that can help me to implement this. Please help.
GenerateDollarTrailing and GeneratePercentTrailing are regular stop orders that are triggered and moved based on a certain built-in logic. You can do the same and even more by creating your own logic for regular stop orders.

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

Re: Algorithmic orders, OCO, OSO, TRSTP

Postby orad » 16 Jan 2015

Hi Andrew,
All orders generated at a particular calculation are in the same OCO group.
I'm not sure if I understand. Does this mean that if there is a market order and stop order generated on the same bar then they are sent as a OCO bracket? What if there are two limit orders generated on the same bar? If the first limit order is filled will that cancel the second limit order?
GenerateDollarTrailing and GeneratePercentTrailing are regular stop orders that are triggered and moved based on a certain built-in logic. You can do the same and even more by creating your own logic for regular stop orders.
Is the code for GenerateDollarTrailing or GeneratePercentTrailing available to use as sample, or is there any other code sample available that shows how a simple TRSTP can be implemented in MC.NET?

Thanks!

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 559 times

Re: Algorithmic orders, OCO, OSO, TRSTP  [SOLVED]

Postby Andrew MultiCharts » 20 Jan 2015

Does this mean that if there is a market order and stop order generated on the same bar then they are sent as a OCO bracket?
No, market orders is the exception. They are processed with a higher priority and are not sent in OCO.
What if there are two limit orders generated on the same bar? If the first limit order is filled will that cancel the second limit order?
Yes.
Is the code for GenerateDollarTrailing or GeneratePercentTrailing available to use as sample, or is there any other code sample available that shows how a simple TRSTP can be implemented in MC.NET?
Unfortunately the code is available. The idea is to place a stop order at a certain price when a certain condition is satisfied, then monitor current price and move the stop order following the price, when it moves in your dircetion.


Return to “MultiCharts .NET”