![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Junior Member
Join Date: Sep 2011
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
In my strategy, after an order has been filled, I place a trailing stop order than I want to manage the price of synthetically. So in my OnExecution I have the following code (after some amount of checking)
Code:
IOrder trailStop = SubmitOrder(0, OrderAction.Sell, OrderType.Stop, execution.Order.Quantity, 0, epv.fillPrice, "", this.LONG_BUY_TRAIL_TAG + epv.entryno); trailStopOrders.Add(trailStop); Code:
for(int i = 0; i < trailStopOrders.Count; i++)
{
IOrder order = (IOrder)trailStopOrders[i];
EntryPatternValues epv = null;
orderMap.TryGetValue(order.OrderId, out epv);
if((order.OrderAction == OrderAction.Sell) && (epv != null))
{
if(High[0] > (epv.farPrice + (Math.Abs(epv.a - epv.farPrice) * .5)))
{
ChangeOrder(order, order.Quantity, 0, (epv.farPrice + (Math.Abs(epv.a - epv.farPrice) * .382)));
}
}
}
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,858
Thanks: 162
Thanked 579 times in 570 posts
|
Hello,
I do not see any issues with the snippet you have provided. Is it that OnBarUpdate is not being called until 1000 bars later, is it is just this single condition that isn't true until later? Do you have this snippet in any other statements that might be preventing it from calling with each incoming tick? For example, do are you using a Time Filter to limit trading times?
Matthew
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Sep 2011
Posts: 20
Thanks: 0
Thanked 0 times in 0 posts
|
Matthew,
I solved the issue, it was a matter of another thread modifying the arraylist. Thanks for your help! Mark |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| OnExecution | neb1998 | Strategy Development | 6 | 01-28-2011 01:50 PM |
| NT7B6 Indicators: Non-displayed daily bars - yesterday's OnBarUpdate is out of sync | kdoren | Version 7 Beta General Questions & Bug Reports | 2 | 01-18-2010 09:00 AM |
| OnBarUpdate Vs. OnExecution | binwang2 | Strategy Development | 1 | 12-01-2009 10:24 AM |
| Variable transfer/access between OnBarUpdate and OnExecution | noincomenojobnoassets | Strategy Development | 9 | 09-23-2009 03:36 AM |
| OnExecution | Mike Winfrey | Strategy Development | 2 | 12-14-2008 06:59 AM |