• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 - submit orders for different account and or instrument from a strategy

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    NT8 - submit orders for different account and or instrument from a strategy

    NT8 - submit orders for different account and or instrument from a strategy

    submitOrder(accountx, instrument, marketorder, 2, buy, signalName....)

    Sorry if you added this and i missed it...

    Imagine...
    A Sim robot running from historical into realtime gives us vital stats....
    most people dont realise this and want best settings . .wotever that is meant to mean... for live trading....

    actually what we really want to do is examine the intel from the sim model - even if the trade management is not the same as our live trading plan,...
    we can see averages MAE/ MFE, drawdown, win days losing days... we can look for equity curve crossovers - consec losers vs winners...

    we can use that data + experience or observation on price analysis of news/events seasonal timings or ranges to then allow a live version of the robot to start trading.... or we submit live orders from the robot running primarily on sim and selectively submitting live orders based on a set of rules... such as

    it might be we have reached what looks sensibly as a drawdown trough -at this moment
    internally in the realtime sim robot we want to shadow and submit live orders

    i hope that rather verbose request made sense... some also use the above tehcnique for rather perilous martingale and not so perilous position size stategies....

    Alternatives
    Currently the aternative is usually a sim strategy will be coupled to a live strategy running in parrallel locally or remotely.. then kick off trading etc....

    but the simply order request above is very neat too...

    so then we would also add stops and targets etc...... and get position info
    based on the sim model or by query the get position for instrument/account

    Please add that if you can... there is a way already but its not clean or obvious to the normal view

    #2
    Have you looked through the Accounts class? The example in the Help Guide is written in the context of an Add On, but you can use it anywhere, such as strategies - http://www.ninjatrader.com/support/h...ount_class.htm

    With this exposure, you could find the account you wish to submit orders to and invoke account.Submit() / Change() / Cancel(), etc...

    Code:
    public class MyCustomStrategy1 : Strategy
    {
    	private Account secondAccount = null;
    	private Order marketOrder = null;
    
    	protected override void OnStateChange()
    	{		
    		if (State == State.SetDefaults)
    		{			
    			// Find our Sim102 account
          		        lock (Account.Accounts)
               		    secondAccount = Account.Accounts.FirstOrDefault(a => a.Name == "Sim102");				
    		}		
    	}		
    
    	protected override void OnBarUpdate()
    	{			
    		if(State == State.Realtime)
    		{
    			if(Position.MarketPosition == MarketPosition.Flat && marketOrder == null)
    			{
    				//Submit order on Sim101 which strategy runs on
    				EnterLong("Sim101 Order");
    			
    				//create sim102 order from second account
    				marketOrder = secondAccount.CreateOrder(Instrument, OrderAction.Buy, OrderType.Market, TimeInForce.Day, 1, 0, 0, null, "Sim102 Order", null);
    
    				//Submit order on Sim102 account which was added in SetDefaults
    				secondAccount.Submit(new[] { marketOrder });
    			}
    		}
    	}		
    }
    Last edited by NinjaTrader_Matthew; 05-08-2015, 09:58 AM.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Matthew View Post
      Have you looked through the Accounts class? The example in the Help Guide is written in the context of an Add On, but you can use it anywhere, such as strategies -http://www.ninjatrader.com/support/helpGuides/nt8/en-us/index.html?account_class.htm

      With this exposure, you could find the account you wish to submit orders to and invoke account.Submit() / Change() / Cancel(), etc...

      Code:
      public class MyCustomStrategy1 : Strategy
      {
      	private Account secondAccount = null;
      	private Order marketOrder = null;
      
      	protected override void OnStateChange()
      	{		
      		if (State == State.SetDefaults)
      		{			
      			// Find our Sim102 account
            		        lock (Account.Accounts)
                 		    secondAccount = Account.Accounts.FirstOrDefault(a => a.Name == "Sim102");				
      		}		
      	}		
      
      	protected override void OnBarUpdate()
      	{			
      		if(State == State.Realtime)
      		{
      			if(Position.MarketPosition == MarketPosition.Flat && marketOrder == null)
      			{
      				//Submit order on Sim101 which strategy runs on
      				EnterLong("Sim101 Order");
      			
      				//create sim102 order from second account
      				marketOrder = secondAccount.CreateOrder(Instrument, OrderAction.Buy, OrderType.Market, TimeInForce.Day, 1, 0, 0, null, "Sim102 Order", null);
      
      				//Submit order on Sim102 account which was added in SetDefaults
      				secondAccount.Submit(new[] { marketOrder });
      			}
      		}
      	}		
      }
      i will be sure to in the near future... excellent help...

      Comment


        #4
        Originally posted by NinjaTrader_Matthew View Post
        Have you looked through the Accounts class? The example in the Help Guide is written in the context of an Add On, but you can use it anywhere, such as strategies - http://www.ninjatrader.com/support/h...ount_class.htm

        With this exposure, you could find the account you wish to submit orders to and invoke account.Submit() / Change() / Cancel(), etc...

        Code:
        public class MyCustomStrategy1 : Strategy
        {
            private Account secondAccount = null;
            private Order marketOrder = null;
        
            protected override void OnStateChange()
            {        
                if (State == State.SetDefaults)
                {            
                    // Find our Sim102 account
                              lock (Account.Accounts)
                               secondAccount = Account.Accounts.FirstOrDefault(a => a.Name == "Sim102");                
                }        
            }        
        
            protected override void OnBarUpdate()
            {            
                if(State == State.Realtime)
                {
                    if(Position.MarketPosition == MarketPosition.Flat && marketOrder == null)
                    {
                        //Submit order on Sim101 which strategy runs on
                        EnterLong("Sim101 Order");
                    
                        //create sim102 order from second account
                        marketOrder = secondAccount.CreateOrder(Instrument, OrderAction.Buy, OrderType.Market, TimeInForce.Day, 1, 0, 0, null, "Sim102 Order", null);
        
                        //Submit order on Sim102 account which was added in SetDefaults
                        secondAccount.Submit(new[] { marketOrder });
                    }
                }
            }        
        }
        I see both EnterLong() and Account.Submit().

        Does that mean that we can now mix and match Managed and Unmanaged order code?

        Comment


          #5
          Originally posted by koganam View Post
          I see both EnterLong() and Account.Submit().

          Does that mean that we can now mix and match Managed and Unmanaged order code?
          Not exactly. You can think of there being 3 layers now.

          Managed and Unamanged orders both have internal logic which will do all sorts of error handling (one of which is checking if the strategy IsUnmanaged) and this has not changed.

          When you introduce orders via this Account class, you're now dealing with a 3rd layer which we consider a "Core Order"-> it's completely up to the developer to manage. However any Managed order methods will still operate as if they were managed.
          MatthewNinjaTrader Product Management

          Comment


            #6
            No, pls don't try to mix managed and unmanaged. This is asking for trouble.
            DierkNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Dierk View Post
              No, pls don't try to mix managed and unmanaged. This is asking for trouble.
              I would expect it to be trouble, if NT would even allow it to compile.

              But I saw what looked like mixing, and had to clarify the situation in my mind.

              So I guess what we have is now a "You are totally on your ownsome" mode. NT will not even bother to think of handling that position if you use Account.Submit()."?

              Comment


                #8
                Sure it would compile.

                Using Account.Submit/.Change/.Cancel is even more low-level than any documented unmanaged logic. Matthew might correct me, but I believe there aren't any docs for that type of low-level code yet...
                DierkNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Dierk View Post
                  Sure it would compile.

                  Using Account.Submit/.Change/.Cancel is even more low-level than any documented unmanaged logic. Matthew might correct me, but I believe there aren't any docs for that type of low-level code yet...
                  Hm. Strange, but I guess I never tried because I just thought that it was not sensible: I always thought that NT would catch an attempt to use managed orders like EnterLong() and deny compilation if the Unmanaged property was enabled.

                  Comment


                    #10
                    Compile (which the C# compiler does) != run time check (which NT does)
                    DierkNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Dierk View Post
                      Compile (which the C# compiler does) != run time check (which NT does)
                      Thanks. Obvious now. I should have seen it. Then again, as I said, I never really thought about doing it anyway.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by RockRiver, Today, 10:38 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post RockRiver  
                      Started by 7robert, Today, 10:07 AM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_ChrisL  
                      Started by Irukandji, 06-10-2019, 06:13 AM
                      4 responses
                      35 views
                      0 likes
                      Last Post Irukandji  
                      Started by Uwe1981, Today, 03:41 AM
                      1 response
                      18 views
                      0 likes
                      Last Post NinjaTrader_Kate  
                      Started by emuns, Today, 09:36 AM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_PaulH  
                      Working...
                      X