order cancellation - NinjaTrader Programming | futures io social day trading
futures io futures trading


order cancellation
Updated: Views / Replies:4,091 / 11
Created: by kaywai Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

order cancellation

  #1 (permalink)
Trading for Fun
singapore
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: IB
Favorite Futures: ES, forex, oil
 
Posts: 131 since Nov 2009
Thanks: 11 given, 7 received

order cancellation

Hi, Is it possible to create a script to cancel limit orders if they are not filled within a predetermined number of bars (for example 10 bars)? If so, how can I go about achieving that? This is all I have at the moment.

// Entry Condition: Submit a buy stop order one tick above the first 20 bar high.
if (Bars.BarsSinceSession > 20 && Close[0] >= highestHigh + TickSize)
{
// EnterLongLimit() can be used to generate buy orders.
EnterLongLimit(highestHigh+TickSize);
}


Reply With Quote
 
  #2 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,218 received

Track the order with IOrder then use CancelOrder to cancel.

 
Code
                            

IOrder myorder 
null;
int myorderbar 0;

myorder EnterLongLimit(highestHigh+TickSize);
myorderbar CurrentBar;

if (
myorderbar 10 CurrentBar)
  
CancelOrder(myorder); 
Typed from memory so check code first.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:
 
  #3 (permalink)
Trading for Fun
singapore
 
Futures Experience: Intermediate
Platform: ninjatrader
Broker/Data: IB
Favorite Futures: ES, forex, oil
 
Posts: 131 since Nov 2009
Thanks: 11 given, 7 received


thank you sir! much appreciated.

Reply With Quote
 
  #4 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received


kaywai View Post
Hi, Is it possible to create a script to cancel limit orders if they are not filled within a predetermined number of bars (for example 10 bars)? If so, how can I go about achieving that? This is all I have at the moment.

// Entry Condition: Submit a buy stop order one tick above the first 20 bar high.
if (Bars.BarsSinceSession > 20 && Close[0] >= highestHigh + TickSize)
{
// EnterLongLimit() can be used to generate buy orders.
EnterLongLimit(highestHigh+TickSize);
}


From the NinjaTrader Help Guide http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?CancelOrder

 
Code
private IOrder myEntryOrder = null; 
private int barNumberOfOrder = 0; 
 
protected override void OnBarUpdate() 
{    
    // Submit an entry order at the low of a bar 
    if (myEntryOrder == null) 
    {         
        myEntryOrder = EnterLongLimit(0, true, 1, Low[0], "Long Entry"); 
        barNumberOfOrder = CurrentBar; 
    } 
 
    // If more than 5 bars has elapsed, cancel the entry order 
    if (CurrentBar > barNumberOfOrder + 5) 
        CancelOrder(myEntryOrder); 
}
Hope that helps!

Reply With Quote
The following user says Thank You to mrticks for this post:
 
  #5 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received


kaywai View Post
Hi, Is it possible to create a script to cancel limit orders if they are not filled within a predetermined number of bars (for example 10 bars)? If so, how can I go about achieving that? This is all I have at the moment.

// Entry Condition: Submit a buy stop order one tick above the first 20 bar high.
if (Bars.BarsSinceSession > 20 && Close[0] >= highestHigh + TickSize)
{
// EnterLongLimit() can be used to generate buy orders.
EnterLongLimit(highestHigh+TickSize);
}


My code snippet above is incorrect for NT 7. Have had to code cancel orders today into a strat with limit orders, so they cancel if not filled after one bar.

For NT 7 it should look this:

In you variables section you need,
 
Code
#region Variables
private IOrder                              entryOrderR         = null; 
private int                                     entryBar               = 0;
In the OnBarUpdate () section you need something like this example, change for your own setups.
 
Code
protected override void OnBarUpdate()
if (Position.MarketPosition == MarketPosition.Flat 
                    && Position.MarketPosition != MarketPosition.Short
                    && Close[1] > Open[1]
                    && GetCurrentBid() < Close [1] - 2 * TickSize                
                    )
                {
                    {
                        
                        
                        entryOrderR = EnterLongStopLimit(Close[1] + 1 * TickSize, Close[1]); 
                         entryBar = CurrentBar;
                        
                        
                    }
                    // If more than 1 bars has closed since, cancel the entry order. 
                    if (CurrentBar > entryBar + 1) 
                    {    
                    CancelOrder(entryOrderR); 
                    }
                }

                else if (Position.MarketPosition == MarketPosition.Flat
                         && Position.MarketPosition != MarketPosition.Long
                         && GetCurrentAsk() > Close [1] + 2 * TickSize
                         && Close[1] < Open[1]                    
                         )
                {
                    {
                        
                        entryOrderR = EnterShortStopLimit(Close[1] - 1 * TickSize, Close[1]);
                        entryBar = CurrentBar;
                        
                    }
                    // If more than 1 bars has closed since, cancel the entry order.
                    if (CurrentBar > entryBar + 1) 
                    {
                    CancelOrder(entryOrderR); 
                    }
In my earlier sample I had left out curly brackets from the CancelOrder(MyEntryOrder); call sample. I have added to this post for my own future reference and also so it may help others in the future.

Reply With Quote
The following user says Thank You to mrticks for this post:
 
  #6 (permalink)
Elite Member
Israel
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: pfg
Favorite Futures: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 206 received

You don't need any code to cancel orders!
Just issue order without "live until canceled" (the simple one) and don't renew it.

Baruch

Reply With Quote
 
  #7 (permalink)
Elite Member
Bala, PA, USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus, IB
Favorite Futures: SPY, Oil, Euro
 
monpere's Avatar
 
Posts: 1,858 since Jul 2010
Thanks: 300 given, 3,276 received


baruchs View Post
You don't need any code to cancel orders!
Just issue order without "live until canceled" (the simple one) and don't renew it.

Baruch

live until canceled only works for 1 bar.

Reply With Quote
 
  #8 (permalink)
Elite Member
Israel
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: pfg
Favorite Futures: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 206 received


Quoting 
live until canceled only works for 1 bar

Your wrong!
EnterLongLimit()

Baruch

Reply With Quote
 
  #9 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received


baruchs View Post
You don't need any code to cancel orders!
Just issue order without "live until canceled" (the simple one) and don't renew it.

Baruch

Baruch - I need to manually cancel orders otherwise they don't expire until the close of the session. Also, sometimes one of my entry signals causes an "invalid order submitted" error which then terminates the strategy.

Can you post the code or attach a sample strategy that cancels an order after one bar closes?

Reply With Quote
 
  #10 (permalink)
Elite Member
Israel
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: pfg
Favorite Futures: eminis
 
Posts: 323 since Jun 2009
Thanks: 6 given, 206 received


EnterLongLimit(Price);
Will be valid for 1 bar. Of course if you issue this order on each bar then until you stop doing it the order will exist.

Quoting 
Also, sometimes one of my entry signals causes an "invalid order submitted" error which then terminates the strategy.

How do you want me to respond to it?
Baruch

Reply With Quote

Reply



futures io > > > > > order cancellation

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Time Frame Strategy Cancellation jthom NinjaTrader Programming 2 October 9th, 2014 12:00 PM
Order Ticker Default User The Elite Circle 30 July 20th, 2011 11:58 AM
Limit Order LukeGeniol Terms (Glossary) 0 June 29th, 2010 02:38 AM
Stop Order Big Mike Terms (Glossary) 0 June 28th, 2010 01:25 AM
Z-Order Programmically DavidHP NinjaTrader Programming 3 April 30th, 2010 07:54 PM


All times are GMT -4. The time now is 09:00 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-11 in 0.15 seconds with 19 queries on phoenix via your IP 54.83.122.227