Cancel Order - NinjaTrader Programming | futures io social day trading
futures io futures trading


Cancel Order
Updated: Views / Replies:904 / 10
Created: by olres7 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
 

Cancel Order

  #1 (permalink)
Elite Member
Gatlinburg TN/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Futures
 
Posts: 12 since Sep 2015
Thanks: 5 given, 0 received

Cancel Order

Hi there!

I am trying to write a simple script to cancel an order.

If 2 bars no entry(5 min) = cancel order. I found a script similar in ninja tutorial however this code doesn't work.
I put in my strategy and back-tested and no results.

This is Ninja Trader Tutorial 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);

This is my code:

private int barNumberOfOrder = 0;
private IOrder myEntryOrder = null;
protected override void Initialize()
{

TimeInForce = Cbi.TimeInForce.Day;
ExitOnClose = true;
ExitOnCloseSeconds = 960;
ConnectionLossHandling = ConnectionLossHandling.KeepRunning;
EntriesPerDirection = 6;
EntryHandling = EntryHandling.AllEntries;
SetStopLoss("", CalculationMode.Ticks, 5, false);
SetProfitTarget("", CalculationMode.Ticks, 18);
CalculateOnBarClose = true;

}
protected override void OnBarUpdate()
{
if(myEntryOrder==null)
{
if( Range()[0] <= 9*TickSize &&
Volume[0] > 510 &&
High[0] > MAX(High, 30)[1])
{
myEntryOrder=EnterShortLimit(0,true,1,High[0]-(3*TickSize), "Short1");
barNumberOfOrder = CurrentBar;
}
}
if (CurrentBar > barNumberOfOrder + 2)
CancelOrder(myEntryOrder);
}


I spent the whole week to figure out about that issue and still no results
If you anybody knows how to fix it I would be very appreciate

Thanks,
Serge

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,488 since Sep 2013
Thanks: 1,703 given, 3,691 received
Forum Reputation: Legendary


Hello

You might consider to look at the code of the BOT i published in my thread

https://futures.io/elite-automated-trading/32559-ron-s-alpha-trade-method-ninjatrader-advanced-trade-management-bot-21.html

You will find several types of updates on an order.

Also like dynamically changing a
stop (trailing)
target (turbo)

good luck

Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #4 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,572 given, 3,982 received

Maybe a simple else missing?
Not tested nor compiled.

 
Code
                            
protected override void OnBarUpdate() { 
    if(
myEntryOrder==null) { 
        if(    
Range()[0] <= 9*TickSize && Volume[0] > 510 && High[0] > MAX(High30)[1]) {
            
myEntryOrder=EnterShortLimit(0,true,1,High[0]-(3*TickSize), "Short1");
            
barNumberOfOrder CurrentBar;
        }
    } 
    else if (
CurrentBar barNumberOfOrder 2) { //myEntryOrder is not NULL
            
Print("myEntryOrder to be cancelled: " myEntryOrder.ToString());
            
CancelOrder(myEntryOrder);
        }


Success requires no deodorant! (Sun Tzu)
Reply With Quote
The following user says Thank You to sam028 for this post:
 
  #5 (permalink)
Elite Member
Gatlinburg TN/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Futures
 
Posts: 12 since Sep 2015
Thanks: 5 given, 0 received

Error message

I am using Ninja 7
I was trying to open your strategy thru
FILE\UTILITIES\IMPORT\AlphaTradingMethodRonV36.zip

However, It doesn't open. It says some error.

Do you know how to open it?

Thanks,
Serge





rleplae View Post
Hello

You might consider to look at the code of the BOT i published in my thread

https://futures.io/elite-automated-trading/32559-ron-s-alpha-trade-method-ninjatrader-advanced-trade-management-bot-21.html

You will find several types of updates on an order.

Also like dynamically changing a
stop (trailing)
target (turbo)

good luck


Reply With Quote
 
  #6 (permalink)
Elite Member
Gatlinburg TN/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Futures
 
Posts: 12 since Sep 2015
Thanks: 5 given, 0 received

I did it however still no results
I back-tested. I doesn't make any trades at all. I really don't know where is the problem is.
It doesn't print also:
Print("myEntryOrder to be cancelled: " + myEntryOrder.ToString());





sam028 View Post
Maybe a simple else missing?
Not tested nor compiled.

 
Code
                            
protected override void OnBarUpdate() { 

    if(
myEntryOrder==null) { 
        if(    
Range()[0] <= 9*TickSize && Volume[0] > 510 && High[0] > MAX(High30)[1]) {
            
myEntryOrder=EnterShortLimit(0,true,1,High[0]-(3*TickSize), "Short1");
            
barNumberOfOrder CurrentBar;
        }
    } 
    else if (
CurrentBar barNumberOfOrder 2) { //myEntryOrder is not NULL
            
Print("myEntryOrder to be cancelled: " myEntryOrder.ToString());
            
CancelOrder(myEntryOrder);
        }



Reply With Quote
 
  #7 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,488 since Sep 2013
Thanks: 1,703 given, 3,691 received
Forum Reputation: Legendary


olres7 View Post
I did it however still no results
I back-tested. I doesn't make any trades at all. I really don't know where is the problem is.
It doesn't print also:
Print("myEntryOrder to be cancelled: " + myEntryOrder.ToString());

1. I would recomend adding some debug information
with Print statements of the value of range
and of your 9 X ticksize

2. also output the limit you are putting on the order
if it enters the iff at all

Same for all other conditions, you will then be able to see step by step what happens.

Reply With Quote
 
  #8 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,488 since Sep 2013
Thanks: 1,703 given, 3,691 received
Forum Reputation: Legendary


olres7 View Post
I am using Ninja 7
I was trying to open your strategy thru
FILE\UTILITIES\IMPORT\AlphaTradingMethodRonV36.zip

However, It doesn't open. It says some error.

Do you know how to open it?

Thanks,
Serge

you simply take an unzipper
open the archive and inside is a .cs file
use it as an illustration

don't try to run the strategy
however you might find some ideas in the code..

code luck

Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #9 (permalink)
Elite Member
Gatlinburg TN/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Futures
 
Posts: 12 since Sep 2015
Thanks: 5 given, 0 received

Thanks


rleplae View Post
you simply take an unzipper
open the archive and inside is a .cs file
use it as an illustration

don't try to run the strategy
however you might find some ideas in the code..

code luck


Reply With Quote
 
  #10 (permalink)
Elite Member
Gatlinburg TN/USA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Futures
 
Posts: 12 since Sep 2015
Thanks: 5 given, 0 received


Thanks,
I opened .cs with .txt file.
However, your project is so complected for me. It is completely out of my scope. I am a novice trader.
And some things are very hard for me to understand.
If you have some simple examples with an order handling that would be great.

Thanks,
Serge



rleplae View Post
you simply take an unzipper
open the archive and inside is a .cs file
use it as an illustration

don't try to run the strategy
however you might find some ideas in the code..

code luck


Reply With Quote

Reply



futures io > > > > > Cancel Order

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
How to cancel an order at a specific time sburtt NinjaTrader Programming 3 August 15th, 2013 02:58 AM
Simple Limit Order with SL/TP/Cancel prosonic NinjaTrader Programming 3 August 14th, 2013 09:36 PM
cancel last order terratec NinjaTrader Programming 16 September 1st, 2011 02:17 PM
ATM Order Cancel Project Baseheadz NinjaTrader Programming 4 August 16th, 2011 12:32 AM
IOG causing my limit order to cancel and replace intrabar tradersheldon EasyLanguage Programming 10 August 2nd, 2011 10:03 AM


All times are GMT -4. The time now is 05:26 AM.

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-13 in 0.13 seconds with 19 queries on phoenix via your IP 54.92.194.75