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,449 / 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?

  #11 (permalink)
Elite Member
Los Angeles, CA, USA
 
Futures Experience: Advanced
Platform: Interactive Brokers
Favorite Futures: YM
 
Posts: 7 since Dec 2012
Thanks: 2 given, 0 received

haha drolles,
i guess we r targeting the same problem here.
i'll follow u here and in nt forum. good luck!




drolles View Post
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
 
  #12 (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

Better solution for parsing the Order.Name string

Hi,

I've found a better solution for parsing the number from the order number string. I would recommend this method above the previous one posted. The previous isn't as robust.

 
Code
protected string GetOrderNumber(IOrder order)
        {

            string b = string.Empty;

            for (int i = 0; i < order.Name.Length; i++)
            {
                if (Char.IsDigit(order.Name[i]))
                    b += order.Name[i];
            }

            return b;

        }

Ref: .net - c# find and extract number from a string - Stack Overflow

Reply With Quote
 
  #13 (permalink)
Trading Apprentice
Milan, Italy
 
Futures Experience: Advanced
Platform: Ninja Trader
Favorite Futures: Forex
 
Posts: 2 since Apr 2012
Thanks: 1 given, 0 received

Perhaps the right path!


Hallo friends,

thank you for this interesting thread. How difficult it is to find the right indications sometimes...!

I posted a -still unanswered- thread on Ninja forum, (though my username there is different). I cannot paste links here because I am newbie, but it goes about "Managing multiple trades without string names".

From what I have read here, it seems that the only solution is parsing strings, is it correct?

Any further suggestions?

Bye

F

Reply With Quote
 
  #14 (permalink)
Elite Member
Austin TX
 
Futures Experience: Intermediate
Platform: SaintGobain Crystal Ball
Favorite Futures: 6E
 
Posts: 80 since Oct 2010
Thanks: 102 given, 129 received

Not sure about backtesting but the following will work in a live scenario:

In OnStartUp() method subscribe to the Execution event

 
Code
acct.Execution += new Cbi.ExecutionUpdateEventHandler(ExecutionUpdateHandler);
Then watch for the events:
 
Code
        List<Order> orderList = new List<Order>();
        private void ExecutionUpdateHandler(object sender, ExecutionUpdateEventArgs e)
        {
            Print("Execution Event: " + e.ToString());
            bool orderExists = false;
            foreach(Order _ord in orderList)
            {
               if( _ord.OrderId == e.Execution.Order.OrderId)
               {
                   _ord.OrderState = e.Execution.Order.OrderState;
                   orderExists = true;
                   break;
               }
            }
            if (orderExists == false)
            {
                orderList.Add((Order)e.Execution.Order);
            }
                              
        }
finally, important, in OnTermination() unsubscribe:

 
Code
acct.Execution -= ExecutionUpdateHandler;
This should populate the list with new Orders and modify the existing ones. There might be some typos in the code, but that's the general idea. Use at your own risk.

Here are some others to play with:

 
Code
	a.OrderStatus += new Cbi.OrderStatusEventHandler(OrderStatusUpdateHandler);
	private void OrderStatusUpdateHandler(object sender, OrderStatusEventArgs e) 
	{
                 	 Print("Order Update event:  " +e.ToString());
	}

	a.PositionUpdate += new Cbi.PositionUpdateEventHandler(PositionUpdateHandler); 
	private void PositionUpdateHandler(object sender, PositionUpdateEventArgs e)
	{
		Print("Position Update event:  " +e.ToString());
	}

	a.AccountUpdate += new Cbi.AccountUpdateEventHandler(AccountUpdateHandler);
	private void AccountUpdateHandler(object sender, AccountUpdateEventArgs e)
	{
		Print("Account Update event:  " +e.ToString());
	}

	a.Connection.ConnectionStatus += new Cbi.ConnectionStatusEventHandler(ConnectionStatusHandler);
	private void ConnectionStatusHandler(object sender, ConnectionStatusEventArgs e) 
	{
		Print("Connection Status event:  " +e.ToString() +a.Connection.Accounts);
	}

	// don't forget to clean up:
	protected override void OnTermination()
	{
		Print("Removing event handlers from account " +a.Name);
		a.Execution -= ExecutionUpdateHandler;
		a.OrderStatus -=  OrderStatusUpdateHandler;
		a.PositionUpdate -= PositionUpdateHandler;  // AccountUpdate
		a.AccountUpdate -= AccountUpdateHandler;
		a.Connection.ConnectionStatus -= ConnectionStatusHandler;
	}
Good luck.
J


Last edited by Jaba; April 18th, 2013 at 12:43 AM. Reason: added some more event handlers
Reply With Quote
The following 4 users say Thank You to Jaba for this post:
 
  #15 (permalink)
Trading Apprentice
Milan, Italy
 
Futures Experience: Advanced
Platform: Ninja Trader
Favorite Futures: Forex
 
Posts: 2 since Apr 2012
Thanks: 1 given, 0 received

Thank you J,

I will try it!

Reply With Quote

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 08:59 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.09 seconds with 19 queries on phoenix via your IP 54.83.122.227