people with nt,
i have been working with the samples for onorder and onexecution update methods that nt makes available.
i have read the help guides and the notes on the samples and i still would like a brief explanation of the different commands used inside the onorder and onexecution update sections.
now, i have been able to get strategies with time limits and stop loss orders to work acceptably, so i'm now trying to get strategies that also include secondary entries to work and i have some questions.
- i'm not sure if the platform is using Position.AveragePrice as i understand it. my stop loss orders look like this:
pullbackstop = ExitShortStopMarket(1, true, execution.Order.Filled, Position.AveragePrice + ( Convert.ToInt32(Pullbackticks) * TickSize ), "shstlopuen01", "shpuen01");
what i have in mind is: 1) execute initial entry, 2) set stop loss order for initial entry at average price plus several ticks. 3) if a secondary entry is triggered and executed, 4) set stop loss orders for all contracts (initial and secondary entries) at average price plus ticks.
i understand that Position.AveragePrice after the first execution for 2 contracts will be different than Position.AveragePrice after a second entry for 1 additional contract has been executed. ¿is this correct? ¿will the nt platform adequately understand the values for Position.AveragePrice to be different after every execution? ¿is it ok to use Position.AveragePrice or is there code that would work better for what i have in mind?
- and somewhat related to this, i would like to know what kind of code should i use in the onbarupdate section of an strategy so that nt will adjust a stop loss order but only after a particular (secondary) execution has happened.
if ( Position.MarketPosition == MarketPosition.Short && Closes[1][0] < Position.AveragePrice - ( Convert.ToInt32(Profitticks) * TickSize ) )
{
if (shstloorenor != null && shstloorenor.StopPrice > Position.AveragePrice)
{
shstloorenor = ExitShortStopMarket(1, true, shstloorenor.Quantity, Position.AveragePrice - ( Convert.ToInt32(Breakeventicks) * TickSize ), "shstlooren01", "shoren01");
}
}
i tried to work with a very basic breakeven stop sample that nt makes available and thought that using only a condition for an order like shstloorenor != null would be enough but the strategy will not work in that case.
if the secondary entry in my strategy is called shpuenor, ¿what kind of code should use in the onbarupdate to make nt adjust the stop loss order for the initial entry but only after the secondary entry has been executed? ¿can nt detect every execution that happens as some kind of event? ¿will executions be not null (!=) as long as its corresponding entry has not been closed? i'm interested in understanding how will the nt platform process orders and executions so that i can try to create code that will work as intended.
very well, thanks, regards.
Comment