NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 11-03-2011, 05:17 AM   #1
DH008
Member
 
Join Date: Jun 2009
Posts: 78
Thanks: 0
Thanked 1 time in 1 post
Default order cancellation in lower time frame

Hi!
I have the following strategy (unmanaged approach) on a 5 min chart:

A Stop Buy order 1 pip over the High of a range. The stop buy order should be cancelled as soon as the range is broken to the downside.

The problem: If one bar breaks the range downward and upward the stop buy order gets filled but should be cancelled.

I tried to cancel the pending order in a lower time frame (1 min) but thats not possible because the order is already filled, although the buy point was not hit yet!

So how to cancel the pending entry order?

Thanks, DH
DH008 is offline  
Reply With Quote
Old 11-03-2011, 05:27 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 974 times in 957 posts
Default

DH, you would need to debug the event / bar event update sequence seen by your strategy, if you try to do this from the 5 bars close in backtesting there would not be enough granularity available to do the order cancelleation as you desire as it all happens in one 5 min bar correct?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 11-03-2011, 05:33 AM   #3
DH008
Member
 
Join Date: Jun 2009
Posts: 78
Thanks: 0
Thanked 1 time in 1 post
Default

Yes, it all happens in one 5 min bar. That's why I tried to cancel the order in a lower time frame. But as soon as I get the first 1 min bar the order is already filled, but should not be filled at this point.
DH008 is offline  
Reply With Quote
Old 11-03-2011, 05:38 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 974 times in 957 posts
Default

From the perspective of the closed 5 min bars in backtesting it likely would be filled then, you would need to debug with Prints / TraceOrders to understand the event sequence your code runs through to arrive at this result.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 11-04-2011, 05:27 AM   #5
DH008
Member
 
Join Date: Jun 2009
Posts: 78
Thanks: 0
Thanked 1 time in 1 post
Default

Well, either I do something very wrong or there is a bug in back testing.

On the attached picture you see a 5 min chart (the primary series) with the trade which should not execute on the upper side and a 1 min chart on the lower side.

All trades are handled in the 1 min time frame.

At 22:30, at the end of the range, a stop buy was entered.
At 22:33, the range was broken to the downside and the pending entry order should get cancelled. But at this time, the entry order was already filled! Also the corresponding SL and TP orders have already been entered (at OnOrderUpdate)!

It looks like that it is not possible to handle trades in a lower time frame than the primary data series.

Please advise.
Thanks, DH
Attached Images
File Type: jpg $EURUSD (5 Min) _ $EURUSD (1 Min) 24_10_2011.jpg (134.7 KB, 5 views)
Attached Files
File Type: txt Trace01.txt (1.2 KB, 6 views)
DH008 is offline  
Reply With Quote
Old 11-04-2011, 08:47 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,404
Thanks: 252
Thanked 974 times in 957 posts
Default

DH008, so you're sending those orders directly to the BIP = 1 or do you only submit them on the BIP 1 event? Would it be possible to send me the strategy to reproduce here on our end? You can mask any proprietary logic used if sensitive for you.

Thanks,
NinjaTrader_Bertrand is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Time Frame Strategy Cancellation jthom Automated Trading 3 06-18-2010 02:18 PM
Multi-time frame - order Outlier Strategy Development 1 05-20-2010 08:25 AM
ATM Strategy Order Cancellation If Not Filled After Specified Time KBJ ATM Strategies (Discretionary Trading) 1 12-15-2009 01:48 PM
Multi-Time Frame Order Delay darckeen Strategy Development 10 08-31-2009 07:07 AM
Adjust order cancellation time webhalla Automated Trading 3 05-23-2007 02:05 PM


All times are GMT -6. The time now is 07:44 PM.