• 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

Error with IOrder object

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

    Error with IOrder object

    My strategy that works on calculateonbarclose=true is doing some strange thing. It duplicate orders. Then, I am trying to launch a new order only if the IOrder is not filled,

    Code:
    if(longOrder.OrderState == OrderState.Filled){}else{longOrder = EnterLong(1,"Long");}

    I can compile but when the the strategy is enabled the outputwindow launch this message:


    **NT** Error on calling 'OnBarUpdate' method for strategy

    Thank you for help

    #2
    Hello,

    Thank you for the question.

    If you would like to check if you are currently in a position to prevent logic until that position has filled, you could do that two ways.

    The first would be from OnBarUpdate by checking the Position or:

    Code:
    if(Position.CurrentMarketPosition == MarketPosition.Flat)
    {
       EnterLong();
    }
    http://ninjatrader.com/support/helpG...htsub=Position

    The second would be to use OnExecution to check for the actual filled order is the order you submitted. Because you are already storing the order as a variable, OnExecution may be more beneficial depending on what you are trying to do. There is a sample in the helpguide here: http://ninjatrader.com/support/helpG...ub=onexecution

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

    Comment


      #3
      Thank you Jesse,

      The first dont work. The duplicate orders ocurrs with this code:


      Code:
      if(Position.MarketPosition.ToString() != "Long"){ 
         EnterLong(); 
      }
      Yes, CalculateonBarClose is = false

      Comment


        #4
        Hello,

        Thank you for the reply.

        What you have provided should work but generally you can just use the enum value, you could use the enum instead of a string if you check the Position object:

        if(Position.CurrentMarketPosition == MarketPosition.Flat)
        {

        }

        MarketPosition.Flat, .Long or .Short.

        If you are still seeing double orders, it could be the Entries per direction you have set, in the case the condition can become true again it would allow for another entry.

        If you can post the full context of the test you are doing it may be more apparent what the problem is.

        I look forward to being of further assistance.
        Last edited by NinjaTrader_Jesse; 06-30-2016, 09:47 AM.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Ok, the problem was solved.

          Ninjatrader take ExitLong() function like the same as EnterShort() ...


          Thank you

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by dmking, Today, 10:55 AM
          0 responses
          1 view
          0 likes
          Last Post dmking
          by dmking
           
          Started by broffe18, Today, 09:57 AM
          2 responses
          10 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by NtFan, Today, 10:47 AM
          0 responses
          6 views
          0 likes
          Last Post NtFan
          by NtFan
           
          Started by U0000999, Today, 10:33 AM
          1 response
          5 views
          0 likes
          Last Post U0000999  
          Started by iq200, Today, 10:21 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X