Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Detect flat market with OnExecutionUpdate or OnPositionUpdate

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

    Detect flat market with OnExecutionUpdate or OnPositionUpdate

    Hello

    I am using the Addons Framework to develop an Addons with which to copy operations from one account to another. I have enough advance but I need some help with something.

    I need to check when the account is flat with no trades. I am using the syntax in OnExecutionUpdate or OnPositionUpdate:
    Code:
    private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
    {
         if (e.MarketPosition == MarketPosition.Flat)
         {
          marketflat == true;
         }
    }
    to store a variable that is updated depending on whether the market is flat or not. But I can't get this variable to change state as there is no event that calls my OnExecutionUpdate method.

    Please, could you help me to know how to automatically detect if an account is flat

    #2
    Doesn't OnPositionUpdate get notified when the Position is Flat?

    Comment


      #3
      Hi vltdavid

      Please, eliminate this post. I already saw how to work. Thank you.

      Comment


        #4
        Hello everyone

        I have not been able to use OnPositionUpdate to find out if the market is flat with some accounts. If I try with the data from Ninjatrader Continuum, it returns the Flat value when the position is canceled and enters the condition that I share below, but if I try to follow the same steps with the Uprofit account, the Market Flat value is not returned and does not enter the condition.
        Does anyone know what may be happening here?

        I am using the following code:
        Code:
        private void OnPositionUpdate(object sender, PositionEventArgs e)
        {
             totalposition = e.Position.Quantity;
        
             if (e.MarketPosition == MarketPosition.Flat) //Used to do something in OnOrderUpdate
             {
                  Dispatcher.InvokeAsync(() =>
                  {
                     bool slaveAccountFlat = true;
                     entryOrder = null; 
                     outputBox.AppendText(string.Format("{0}C. Esclava | 2. Flat | N° de Posiciones canceladas= {1}", Environment.NewLine, totalposition));
                      if (entryOrder == null)
                      {
                          outputBox.AppendText(string.Format("C. Esclava | 2. Variable 'entryOrder' Null."));
                      }
                  });
             }
        }

        Comment


          #5
          Hello jleira,

          Thanks for your post.

          There is an existing issue with Rithmic based connections where PositionUpdates were not properly reporting a flat position. This has been addressed in Release 24. I cannot offer an ETA on when the new build will be available, but it will be available soon. Ticket ID NTEIGHT-14707.

          The number for the ticket ID will be listed in the Release Notes page of the Help Guide when Release 24 becomes available.

          Release Notes - https://ninjatrader.com/support/help...ease_notes.htm

          I also tested this earlier today and can share that Release 24 is identifying the flat position properly.

          We look forward to assisting.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by gravdigaz6, Today, 11:40 PM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by MarianApalaghiei, Today, 10:49 PM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by XXtrader, Today, 11:30 PM
          0 responses
          4 views
          0 likes
          Last Post XXtrader  
          Started by love2code2trade, Yesterday, 01:45 PM
          4 responses
          28 views
          0 likes
          Last Post love2code2trade  
          Started by funk10101, Today, 09:43 PM
          0 responses
          9 views
          0 likes
          Last Post funk10101  
          Working...
          X