NexusFi: Find Your Edge


Home Menu

 





CancelOrder on multiple contracts


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one bukkan with 3 posts (0 thanks)
    2. looks_two NinjaStrategies with 3 posts (0 thanks)
    3. looks_3 redratsal with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 1,848 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread

CancelOrder on multiple contracts

  #1 (permalink)
NinjaStrategies
Netherlands
 
Posts: 10 since Feb 2011
Thanks Given: 0
Thanks Received: 0

I am working on a strategy that can be used with multiple contracts.
It is using limitorders and when they are not filled, a condition must cancel them.

The problem is: only one contract is cancelled, see below.

//Entering Trades
if (Contracts==2) {entryOrderLong = EnterLongLimit(0,true,1,BuyPrice1,"EL1");entryOrderLong = EnterLongLimit)0,true,1,BuyPrice1,"EL2");}

//Cancelorders
if (Position.MarketPosition == MarketPosition.Flat && entryOrderLong != null && Close[0]>=CancelPrice)
{
CancelOrder(entryOrderLong);
}

How do I get both contracts cancelled?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
About a successful futures trader who didnt know anythin …
Psychology and Money Management
Trade idea based off three indicators.
Traders Hideout
 
  #3 (permalink)
 
redratsal's Avatar
 redratsal 
Milan (I)
 
Experience: Advanced
Platform: Ninjatrader
Broker: Kinetick
Trading: FDAX,6E,CL,YM,NQ,ES
Posts: 1,648 since Oct 2010
Thanks Given: 1,215
Thanks Received: 2,090


you might get some clues here

Visit my NexusFi Trade Journal Reply With Quote
  #4 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271

you can simply use
 
Code
CancelAllOrders(....)
alternatively for better management (i.e. not only for cancelling orders) i would prefer to have a list, like

in variables
 
Code
private List<IOrder> list = new List<IOrder>();

the trade managements
 
Code
IOrder order = EnterLong(....);
list.Add(order);
//enter the second order
order = EnterLong(...);
listAdd(order);

//cancellation logic

 
Code
for (int i = 0; i < list.Count; i++)
{
        if (condition)
        {
                CancelOrder(list[i])
         }
}

Reply With Quote
  #5 (permalink)
NinjaStrategies
Netherlands
 
Posts: 10 since Feb 2011
Thanks Given: 0
Thanks Received: 0


bukkan View Post
you can simply use
 
Code
CancelAllOrders(....)

I am using the managed approach and CancelAllOrders does not exist.

I am not that good in programming to fix it the other way you mentioned.

Everything works with 1 contract but using 2 or 3 contracts only one is cancelled.

Is there a way to edit my own code to fix this?

Reply With Quote
  #6 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271

are you using the bool overloads

Attached Thumbnails
Click image for larger version

Name:	CAO.png
Views:	124
Size:	34.4 KB
ID:	56357  
Reply With Quote
  #7 (permalink)
NinjaStrategies
Netherlands
 
Posts: 10 since Feb 2011
Thanks Given: 0
Thanks Received: 0


bukkan View Post
are you using the bool overloads

Can you give me a direction howto add this?

Reply With Quote
  #8 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271


NinjaStrategies View Post
Can you give me a direction howto add this?

CancelAllOrders(true, true);

Reply With Quote




Last Updated on December 5, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts