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.
.NET Strategy - Dynamic Order Creation/Modification
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Re: .NET Strategy - Dynamic Order Creation/Modification
Hello mk42,
That is correct.As far as I understand it I have to pre-create all orders in the Create() method before the strategy starts processing data.
Unfortunately that is not technically possible at the moment.Why cannot the order be created during the CalcBar() method?
We are going to add dynamic order name support in MultiCharts 8.8.Cannot this be simplified?
That is possible to modify the amount of contracts and price. ExampleOr is there a way how to modify the created Order object during the run of strategy?
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).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?
Re: .NET Strategy - Dynamic Order Creation/Modification
Hi, thanks for fast response,
Thanks again.
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.That is possible to modify the amount of contracts and price. - url=viewtopic.php?f=19&t=11963#p59064 - ExampleOr is there a way how to modify the created Order object during the run of strategy?
What do you mean by "under condition" ? Is the following this simple scenario correct and will the order be filled and stoploss immediately created?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).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?
Code: Select all
buyorder.Send()
GenerateStopLoss(amount)
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Re: .NET Strategy - Dynamic Order Creation/Modification
You can specify amount of contracts to buy for any order you like. Another exampleI 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.
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.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)
Under condition is like that:
Code: Select all
if(StrategyInfo.MarketPosition != 0)
{
GenerateStopLoss(amount);
}