.NET Strategy - Dynamic Order Creation/Modification

Questions about MultiCharts .NET and user contributed studies.
mk42
Posts: 6
Joined: 13 Jun 2013

.NET Strategy - Dynamic Order Creation/Modification

Postby mk42 » 13 Jun 2013

Hi,

I am trying to work on some strategies, which I have been using in other C# based platform, but am struggling with the orders. As far as I understand it I have to pre-create all orders in the Create() method before the strategy starts processing data.

But if the strategy needs to work with different amounts of contracts, different entry names (for different entry patterns for example) etc. I end up pre-creating many combinations of orders.

Cannot this be simplified? Why cannot the order be created during the CalcBar() method?

Or is there a way how to modify the created Order object during the run of strategy?

Also another question. Can the GenerateProfitTarget()/StopLoss() methods be executed right after the Order.Send() method? Or does the order first be executed into open position (which will happen on next tick) and only after that the Generate... can work? In that case how to catch that precise moment?

Thanks in advance.

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

Re: .NET Strategy - Dynamic Order Creation/Modification

Postby Henry MultiСharts » 13 Jun 2013

Hello mk42,
As far as I understand it I have to pre-create all orders in the Create() method before the strategy starts processing data.
That is correct.
Why cannot the order be created during the CalcBar() method?
Unfortunately that is not technically possible at the moment.
Cannot this be simplified?
We are going to add dynamic order name support in MultiCharts 8.8.
Or is there a way how to modify the created Order object during the run of strategy?
That is possible to modify the amount of contracts and price. Example
Can the GenerateProfitTarget()/StopLoss() methods be executed right after the Order.Send() method? Or does the order first be executed into open position (which will happen on next tick) and only after that the Generate... can work? In that case how to catch that precise moment?
If GenerateProfitTarget()/StopLoss() methods are not under condition - they are automatically sent intra bar on the next tick after the code knows there is an open position. If they are under condition-the orders are generated once the condition is met (either intrabar or on bar close).

mk42
Posts: 6
Joined: 13 Jun 2013

Re: .NET Strategy - Dynamic Order Creation/Modification

Postby mk42 » 13 Jun 2013

Hi, thanks for fast response,
Or is there a way how to modify the created Order object during the run of strategy?
That is possible to modify the amount of contracts and price. - url=viewtopic.php?f=19&t=11963#p59064 - Example
I read the thread linked and I can see that is about modifying amount in GenerateProfitTarget()/StopLoss() methods, what I meant is an entry order with number of contracts dynamically selected according to the situation in the market during the CalcBar() execution.
Can the GenerateProfitTarget()/StopLoss() methods be executed right after the Order.Send() method? Or does the order first be executed into open position (which will happen on next tick) and only after that the Generate... can work? In that case how to catch that precise moment?
If GenerateProfitTarget()/StopLoss() methods are not under condition - they are automatically sent intra bar on the next tick after the code knows there is an open position. If they are under condition-the orders are generated once the condition is met (either https://www.multicharts.com/trading-sof ... Calculated - intrabar or on bar close).
What do you mean by "under condition" ? Is the following this simple scenario correct and will the order be filled and stoploss immediately created?

Code: Select all

buyorder.Send()
GenerateStopLoss(amount)
Thanks again.

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

Re: .NET Strategy - Dynamic Order Creation/Modification

Postby Henry MultiСharts » 13 Jun 2013

I read the thread linked and I can see that is about modifying amount in GenerateProfitTarget()/StopLoss() methods, what I meant is an entry order with number of contracts dynamically selected according to the situation in the market during the CalcBar() execution.
You can specify amount of contracts to buy for any order you like. Another example
What do you mean by "under condition" ? Is the following this simple scenario correct and will the order be filled and stoploss immediately created?

Code: Select all

buyorder.Send()
GenerateStopLoss(amount)
If these are the only two lines you have in CalcBar then this is correct and the order will be sent on the next tick after the code knows a position has been opened.
Under condition is like that:

Code: Select all

if(StrategyInfo.MarketPosition != 0)
{
GenerateStopLoss(amount);
}


Return to “MultiCharts .NET”