Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged orders not working for me

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

    Unmanaged orders not working for me

    This is the first day using NT 8. So, I'm sure I'm doing something wrong. Can someone point me in the right direction?

    I'm trying to simply send an unmanaged order.


    private Order _flattenOrder = null;
    IsUnmanaged = true; // placed in .SetDefaults

    In OnBarUpdate:
    if (Position.MarketPosition == MarketPosition.Flat && _flattenOrder == null)
    _flattenOrder = SubmitOrderUnmanaged(0,OrderAction.Buy,OrderType.L imit,1,1000,0,"","buy");


    After running the strategy (Market Replay), I get the following error.

    Strategy 'test': Error on calling 'OnBarUpdate' method on bar 3416: Strategy 'test/68860946': 'SubmitOrderUnmanaged' method can't be called on managed strategies.
    Disabling NinjaScript strategy 'test/68860946'



    Can anyone tell me what I'm missing here?

    Thanks!

    #2
    Hello,

    Thank you for the question.

    I copy and pasted the syntax you provided and was able to see an order placed. This leads me to believe there may be something else happening.

    I wanted to check, had you applied this to a chart and then added the IsUnmanaged = true?

    If so, can you go to the control center, remove all instances of the strategy and then re apply it to see if that corrects the message?

    If that does not work, Please attach the strategy for me to review.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      No, this is being run from the Strategies tab. I've put the code below.

      Code:
      #region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.Indicators;
      using NinjaTrader.NinjaScript.DrawingTools;
      #endregion
      
      //This namespace holds Strategies in this folder and is required. Do not change it. 
      namespace NinjaTrader.NinjaScript.Strategies
      {
          public class test : Strategy
          {
      
              // Orders
              private Order _flattenOrder = null;
      
      
              
      
      
              // Default settings and state changes
              protected override void OnStateChange()
              {
                  if (State == State.SetDefaults)
                  {
                      IsUnmanaged = true;
                      Description = @"testing new NT8 strats";
                      Name = "test";
                      Calculate = Calculate.OnEachTick;
                      EntriesPerDirection = 1000;
                      EntryHandling = EntryHandling.UniqueEntries;
                      IsExitOnSessionCloseStrategy = true;
                      ExitOnSessionCloseSeconds = 30;
                      IsFillLimitOnTouch = false;
                      MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                      OrderFillResolution = OrderFillResolution.Standard;
                      OrderFillResolutionType = BarsPeriodType.Tick;
                      OrderFillResolutionValue = 1;
                      Slippage = 0;
                      StartBehavior = StartBehavior.WaitUntilFlat;
                      TimeInForce = TimeInForce.Gtc;
                      TraceOrders = false;
                      RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                      StopTargetHandling = StopTargetHandling.PerEntryExecution;
                      BarsRequiredToTrade = 20;
                      ShowForm = false;
                  }
                  
                  if (State == State.Configure)
                  {
                      
                  }
      
                  if (State == State.Transition)
                  {
                      Print("Now using real-time data.");
                  }
              }
      
      
      
      
      
              // Market Data Handling
              protected override void OnMarketData(MarketDataEventArgs e)
              {
              }
      
              protected override void OnMarketDepth(MarketDepthEventArgs marketDepthUpdate)
              {
      
              }
      
              protected override void OnBarUpdate()
              {
                  if (State >= State.Realtime)
                  {
                      if (Position.MarketPosition == MarketPosition.Flat && _flattenOrder == null)
                          _flattenOrder = SubmitOrderUnmanaged(0,OrderAction.Buy,OrderType.Limit,1,1000,0,"","buy");
                  }
              }
      
      
      
              
      
      
      
      
      
      
      
        
      
      
      
              
              // System Order Handling
      
              protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity, Cbi.MarketPosition marketPosition, string orderId, DateTime time)
              {
      
              }
      
              protected override void OnOrderUpdate(Cbi.Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, Cbi.OrderState orderState, DateTime time, Cbi.ErrorCode error, string comment)
              {
                  
              }
      
              protected override void OnPositionUpdate(Cbi.Position position, double averagePrice, int quantity, Cbi.MarketPosition marketPosition)
              {
                  
              }
      
          
              // Account Handling
      
              protected override void OnAccountItemUpdate(Cbi.Account account, Cbi.AccountItem accountItem, double value)
              {
              }
      
            
      
      
              /// Extras
      
              //protected override void OnConnectionStatusUpdate(ConnectionStatus orderStatus, ConnectionStatus priceStatus)
              //{
      
              //}
      
              #region Properties
              [NinjaScriptProperty]
              [Display(Name="ShowForm", Description="Show the form", Order=1, GroupName="Parameters")]
              public bool ShowForm
              { get; set; }
              #endregion
      
          }
      }
      Thanks!

      Comment


        #4
        Hello,

        Yes all strategies end up in the strategies tab, had you completely removed all instances of the strategy and then restested? Again I am not seeing the same outcome.

        If you had applied the strategy at any point before changing to an Unmanaged strategy, the instances in the control center would need to be removed to reflect the change. Any change to OnStateChange it would be good practice to completely remove the strategy instance and re add it so new changes are applied.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          I just exited and re-started NT8. Same result. Can you tell me what options you are using when you load the strategy? Would that even matter?

          I'm using Market Replay data if that makes a difference.
          Last edited by lookOutBelow; 03-08-2016, 05:01 PM.

          Comment


            #6
            So, I made a brand new strategy and it seems to be working. I have no idea what the differences are, since it has the same code cut/pasted. Everything seems identical. But the original version will not work (still). But the new one does.

            Something has certainly gone wrong, but I don't have any idea what it is.

            Comment


              #7
              Hello,

              I am glad the new file solved the problem, I too am unsure what may be happening with the other file as it did not produce the same result on my end.

              You could certainly experiment with the non working file to see if you can isolate what is happening, mainly just comment out one property at a time until you are left with just the items in OnBarUpdate.

              Otherwise if you don't feel like digging into it further, it seems the new file did the job and should allow you to continue.

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Originally posted by lookOutBelow View Post
                I just exited and re-started NT8. Same result. Can you tell me what options you are using when you load the strategy? Would that even matter?

                I'm using Market Replay data if that makes a difference.
                I don't think closing and re-starting NT reloads the old strategy - you need to right click the old strategy, then select remove. Once you remove it this way, then reload the same strategy, it should be your updated version.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,607 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                16 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X