Solutions to managing multiple orders in NT? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Solutions to managing multiple orders in NT?
Updated: Views / Replies:2,447 / 14
Created: by drolles 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
 

Solutions to managing multiple orders in NT?

  #1 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Favorite Futures: if it trades...
 
Posts: 94 since Oct 2010
Thanks: 24 given, 38 received

Solutions to managing multiple orders in NT?

Hi,

Iím wondering if I could share some ideas on managing multiple orders in NT?

Given that you canít create IOrder objects (as it is an interface) Iím wondering what is people usual approach to this?

Iíve been pursuing a possible approach around putting IOrder in a List (System.Collections.Generic) as they are created. Then you can search the list for the last order created to know which one was the last entry.

I see that NT is going to fix this in Version 8 access to the orders of open positions (thanks for Big Mike to organising the walk-through the other week).

Thanks and regards,

drolles

Reply With Quote
 
  #2 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received


drolles View Post
Hi,

Iím wondering if I could share some ideas on managing multiple orders in NT?

Given that you canít create IOrder objects (as it is an interface) Iím wondering what is people usual approach to this?

Iíve been pursuing a possible approach around putting IOrder in a List (System.Collections.Generic) as they are created. Then you can search the list for the last order created to know which one was the last entry.

I see that NT is going to fix this in Version 8 access to the orders of open positions (thanks for Big Mike to organising the walk-through the other week).

Thanks and regards,

drolles

Account has a method called CreateOrder, that should do the trick, you can also modify existing ones...

vvhg

Hic Rhodos, hic salta.
Reply With Quote
The following user says Thank You to vvhg for this post:
 
  #3 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Favorite Futures: if it trades...
 
Posts: 94 since Oct 2010
Thanks: 24 given, 38 received


Thanks for the prompt reply.

I think you might mean something like this:
 
Code
                 foreach (Account acct in Cbi.Globals.Accounts)
                            {
                                // do some stuff with the orders

                                if (acct.Orders != null)
                                {
                                    foreach (Order x in acct.Orders)
                                    {

                                        Print(x.Name);

                                    }
                                }

                            }
NT forum ref here: Sync-ing an always in strategy across weekends - NinjaTrader Support Forum


However, it doesnít appear to work in backtest. Iím assuming the ďAccountsĒ is for live accounts only? Though it is funny I would have through there is some sort of backtest account. Any suggestions for backtest?

Thanks and regards,

drolles

Reply With Quote
 
  #4 (permalink)
Elite Member
Northern Germany
 
Futures Experience: Intermediate
Platform: NT
Favorite Futures: FDAX, CL
 
vvhg's Avatar
 
Posts: 1,583 since Mar 2011
Thanks: 1,016 given, 2,807 received


drolles View Post
Thanks for the prompt reply.

I think you might mean something like this:
 
Code
                 foreach (Account acct in Cbi.Globals.Accounts)
                            {
                                // do some stuff with the orders

                                if (acct.Orders != null)
                                {
                                    foreach (Order x in acct.Orders)
                                    {

                                        Print(x.Name);

                                    }
                                }

                            }
NT forum ref here: Sync-ing an always in strategy across weekends - NinjaTrader Support Forum


However, it doesn’t appear to work in backtest. I’m assuming the “Accounts” is for live accounts only? Though it is funny I would have through there is some sort of backtest account. Any suggestions for backtest?

Thanks and regards,

drolles

What do you need unmanaged orders for in a backtest? I don't know much about strategies and backtests... @NJAMC or @Xav1029 should be more proficient regarding strategies.

What I was referring to was sth. like this:
 
Code
myorder = acct.CreateOrder(.....);
myorder.Submit();
vvhg

Hic Rhodos, hic salta.
Reply With Quote
 
  #5 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Favorite Futures: if it trades...
 
Posts: 94 since Oct 2010
Thanks: 24 given, 38 received

Thanks for the prompt reply.

Iím ok on using managed. I have a situation where Iím looking to do multiple entries (against the same instrument). Iím doing some testing on some ideas (Nuclear Phynance).

I was thinking that I would create a list of entryOrders, targetOrders and stopOrders; using a number to signify the entry number (e.g. Long Entry 1).

I would then check if each entryOrder is filled to determine if there is a corresponding target and stop order for the position. Something like this:
 
Code
foreach (IOrder x in entryOrders)
                            {

                                if (x != null)
                                {

                                    if (x.OrderState == OrderState.Filled)
                                    {

                                        // check to see if a stop / target exists if it does check it state to make sure it isn't fulled

                                        int orderNumber = Int32.Parse(x.Name.Substring(x.Name.Length - 1));


                                    }


                                }


                            }
But then I realised before I headed too far down that path that a filled entry order may not necessary correspond to a ďPositionĒ. A relationship I tried to explain to NT Support previously (that they are now fixing in V8 Ė see post 17 - trade lifecycle analysis - log file - NinjaTrader Support Forum)

I think your solution is a great one for live positions (live meaning connected to an account like IB).

Cheers,

drolles

Reply With Quote
 
  #6 (permalink)
Elite Member
Tampa, FL
 
Futures Experience: Beginner
Platform: NinjaTrader, Sierra Chart
Broker/Data: Mirus Futures/Zen-Fire
Favorite Futures: 6E, M6E, 6J
 
Xav1029's Avatar
 
Posts: 1,374 since Dec 2011
Thanks: 1,452 given, 3,354 received

I don't do strategies either...I love the chart trader, so I've just been tweaking it lately to do some extra tricks like dataseries trails. I really don't know much about backtesting except that I was always rich after optimization

London Calling
Reply With Quote
 
  #7 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Favorite Futures: if it trades...
 
Posts: 94 since Oct 2010
Thanks: 24 given, 38 received

Possibly may be onto something. I've found an Orders collection in StrategyBase. I'm just determining how to use it.

Cheers,

drolles

Reply With Quote
 
  #8 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Favorite Futures: if it trades...
 
Posts: 94 since Oct 2010
Thanks: 24 given, 38 received

Tried these, but none of them worked.
 
Code
                            foreach (Execution x in this.Executions)
                            {

                                if (x.Name.Contains("Short Entry")) {
                                    Print(x.Name);
                                }
                            }

                            foreach (Order x in this.Orders)
                            {

                                if (x != null)
                                {

                                    Print(x.Name);

                                }

                            }
They all remain null even through there are positions live and executions have occurred.

Anyone with any ideas? All help greatly appreciated if we can put a work around in place prior to NT 8 coming out.

Cheers,

drolles

Reply With Quote
 
  #9 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


Xav1029 View Post
I really don't know much about backtesting except that I was always rich after optimization

Absolutely. Shame more folks can't see it out of the box. If a feature is worthwhile and means something in a generic context then it always will, anything else is just fly-by-night/fly-by-wire/fly-by-seat-of-pants conformed noise. On the other hand I guess some manage to use it profitably so yet another example of what makes a market. Me, strictly discretionary.

Travel Well
Reply With Quote
 
  #10 (permalink)
Elite Member
London, UK
 
Futures Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Favorite Futures: if it trades...
 
Posts: 94 since Oct 2010
Thanks: 24 given, 38 received

Active list of open executions


One possible solution I think Iíve come to is keeping a list of open execution.

That is when OnExecution is called to open a solution position (ďLong Entry 1Ē) add it to a list for Open Executions.
 
Code
openExecutions.Add(execution);
Also we need to remove it when the execution is closed
 
Code
else if (execution.Order.Name != "" && (execution.Order.Name.Contains("Long Target") || execution.Order.Name.Contains("Long Target")))
                {

                    string orderNumber = execution.Order.Name.Substring(execution.Order.Name.Length - 1);

                    int indexNum = 0;

                    foreach (IExecution y in openExecutions)
                    {

                        if (y.Order.Name.Contains(orderNumber))
                        {
                            indexNum++;
                            break;
                        }

                        indexNum++;

                    }

                    openExecutions.RemoveAt(indexNum);

                }

It relies on the fact that we are keeping a unique number to append to the back of the IOrder text. I do this by just having a method to increment it each time it is called (might better doing it via a Property?).
 
Code
protected string GetOrderNumber(IOrder order)
        {

            return order.Name.Substring(order.Name.Length - 1);

        }
I think someone mentioned IOrder Tokens, I thought that Tokens were not always unique?

Any thoughts greatly appreciated.

Cheers,

drolles

Reply With Quote
The following user says Thank You to drolles for this post:

Reply



futures io > > > > > Solutions to managing multiple orders in NT?

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
Market If Touched orders for NT 7? vinceb NinjaTrader 3 October 27th, 2017 07:20 PM
NT one click orders with 1buy OCO and 1 OCO.Can we do this???? Rad4633 NinjaTrader 2 December 1st, 2012 07:59 AM
NT + IB problem in realtime orders / strategy thomas79 NinjaTrader 1 December 6th, 2011 07:43 AM
Run multiple copies of NT on one machine samWest The Elite Circle 2 December 3rd, 2010 03:46 PM
Managing multiple entries arjfca EasyLanguage Programming 2 October 16th, 2010 07:28 PM


All times are GMT -4. The time now is 10:38 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-10 in 0.13 seconds with 19 queries on phoenix via your IP 54.221.73.186