Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Oanda Strategy Error Message - TimeInForce Not Supported - NT8

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

    Oanda Strategy Error Message - TimeInForce Not Supported - NT8

    Greetings,

    I've enabled a strategy and my first execution resulted in an error that said:

    TimeInForce <59> = 1 not supported.

    Here's how I'm executing in the code:

    EnterLong(LotSizing, "Long");
    SetProfitTarget("Long", CalculationMode.Price, Close[0] + ATR(20)[0] * ATRMult);
    SetStopLoss("Long", CalculationMode.Price, Close[0] - ATR(20)[0] * ATRMult, false);

    And my strategy settings are "GTC".

    Any clues as to what's happening?

    #2
    Hello Moody,
    Thanks for your post and welcome to the NinjaTrader forum.

    The connection technology used in NinjaTrader for Oanda shows the option for the GTC Time In Force due to the connection being used for the NinjaTrader Continuum connection as well. However, the Time In Force of GTC is not supported for the Oanda connection in NinjaTrader and thus the error is seen when you use the GTC Time In Force for the Oanda account.

    I have been told that Oanda plans to introduce support for this in their next FIX server upgrade. They currently do not have an ETA for this.

    Alternatively, GTD is supported and can be used as a replacement for GTC albeit, not as convenient.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Would you be able to show me an example of how to use the GTD? When I enable the strategy, I select "GTD" as the TimeInForce and there's no box allowing me to actually select the date that my orders will be good through.

      Comment


        #4
        The TimeInForce for the strategy will not give the needed DateTime settings for the Date that the order will be good until for the GTD setting.

        However, in NinjaScript you can use the Account.CreateOrder() to submit the order using a DateTime for the Date of the GTD. You can find more details at the following link:

        Help Guide - CreateOrder()

        The use of Account.CreateOrder() would mean the order is not submitted through the strategy technically and therefore will not trigger OnPositionUpdate() for the strategy. You would then need to implement checking of the Account itself for the position, execution, and order update. Please find these items detailed at the following link:

        Help Guide - Account

        Please note this would require a re-design of your strategy based on the Unmanaged Approach to order handling. Please see the following link for more information.

        Help Guide - Unmanaged Approach
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Would you check me on this? I'm adapting what you've mentioned to the unmanaged approach and I'm getting an error "object reference not set to instance of object" during backtest.

          Here's what I'm declaring:

          private Account myAccount;
          private Order LongMar****rder;
          private Order LongStopOrder;
          private Order LongLimitOrder;

          And here's how I'm submitting the order:

          LongMar****rder = myAccount.CreateOrder(Instrument, OrderAction.Buy, OrderType.Market, OrderEntry.Automated, TimeInForce.Gtd, LotSizing, 0, 0, "", "Long", Core.Globals.MaxDate, null);

          LongLimitOrder = myAccount.CreateOrder(Instrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Automated, TimeInForce.Gtd, LotSizing, Close[0] + ATR(20)[0] * 2, 0, "LongOCO", "Long", Core.Globals.MaxDate, null);

          LongStopOrder = myAccount.CreateOrder(Instrument, OrderAction.Sell, OrderType.StopMarket, OrderEntry.Automated, TimeInForce.Gtd, LotSizing, Close[0] - ATR(20)[0] * 2, 0, "LongOCO", "Long", Core.Globals.MaxDate, null);

          myAccount.Submit(new[] { LongMar****rder, LongLimitOrder, LongStopOrder });

          Comment


            #6
            Is that all of the code you have written so far?
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              No, I have an existing strategy and I've replaced these three lines in my old strategy:

              EnterLong(LotSizing, "Long");
              SetProfitTarget("Long", CalculationMode.Price, Close[0] + ATR(20)[0] * ATRMult);
              SetStopLoss("Long", CalculationMode.Price, Close[0] - ATR(20)[0] * ATRMult, false);

              With those declarations and orders. I know you guys are way too busy to debug code so I'm just trying to figure out how to get my execution code which works with other brokers to work with Oanda. I replaced the three lines above with what I showed in my last post. Am I missing something for getting these lines to execute in Oanda?

              Is the only other change to set it to unmanaged?

              Edit - I think all of this would be resolved if you guys had a sample strategy that uses unmanaged orders with a fixed stop and target (all template strategies seem to be managed). Do you have a version of the MA crossover template strategy like this or anything of the sort?
              Last edited by Moody; 08-16-2018, 09:56 AM.

              Comment


                #8
                This is going to require a major redesign of your strategy and will not be as easy as swapping out those order methods.

                The Unmanaged Approach removes the safety net present with the Managed Approach. This means you have to implement your own means to monitor orders, executions, positions, etc. You can still call the functions available for assistance like OnExecutionUpdate, OnOrderUpdate, and OnPositionUpdate, but you would want to make sure you understood those functions and information they provide. Developing an Unmanaged Approach based strategy is generally reserved for advanced programmers with an understanding of the functions they will need. Essentially, there is no hand holding in Unmanaged Approach, it is up to you to develop the full system.

                While examples have been explored in the past for the Unmanaged Approach, nothing is going to cover all the bases and be one solid system without the need to provide extensive code in the strategy. The samples available in the application, the help guide, and on the support forum are for ideas to be presented to beginners in NinjaScript or as a quick reference for those who are advancing in NinjaScript development.
                Josh G.NinjaTrader Customer Service

                Comment


                  #9
                  Actually, I think if I just switch to on tick updates and code in my fixed stop and target and exit when a tick goes beyond, I can get by.

                  Thanks!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                  4 responses
                  541 views
                  0 likes
                  Last Post PaulMohn  
                  Started by GLFX005, Today, 03:23 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post GLFX005
                  by GLFX005
                   
                  Started by XXtrader, Yesterday, 11:30 PM
                  2 responses
                  11 views
                  0 likes
                  Last Post XXtrader  
                  Started by Waxavi, Today, 02:10 AM
                  0 responses
                  7 views
                  0 likes
                  Last Post Waxavi
                  by Waxavi
                   
                  Started by TradeForge, Today, 02:09 AM
                  0 responses
                  14 views
                  0 likes
                  Last Post TradeForge  
                  Working...
                  X