Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get Anchor Prices from object drawn by Indicator

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

    Get Anchor Prices from object drawn by Indicator

    Hello guys,

    I have a third party indicator that draw Rectangles on chart. I would like to get the price values from those boxes. How I could achieve this inside my strategy?

    Thanks!

    #2
    Sounds like the indicator does NOT have plots (ie accessible from Strategy Builder) It would have to be recoded to include plots if that is the case.

    Is it CongestionBoxLite ?

    Comment


      #3
      Hello facuevasm,

      DTSSTS is correct, the preferrable way would be to set indicator plot values.


      However, if you have instantiated an indicator to a variable you can loop through the indicators DrawObjects collection.

      private MyIndicator myIndy;

      myIndy = MyIndicator();

      foreach (DrawTool draw in myIndy.DrawObjects.ToList())
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thank you guys!

        So far I'm detecting the indicator that is loaded in the chart using this method....

        protected override void OnRender(ChartControl char tControl, ChartScale chartScale)
        {

        ChartObjectCollection<NinjaTrader.Gui.NinjaScrip t.IndicatorRenderBase> indicatorCollection = chart Control.Indicators;

        foreach (NinjaTrader.Gui.NinjaScript.IndicatorRenderBase indicator in indicatorCollection)
        {
        if(indicator.Calculate != Calculate.OnBarClose)
        Print(String.Format("{0} is using Calculate.{1}", indicator.Name, indicator.Calculat e.ToString()));
        }
        }

        And the indicator is listed.... now, how I can detect the rectangles been drawn by the specific indicator? Because I already ran this code....

        protected override void OnBarUpdate()
        {
        foreach (DrawingTool draw in DrawObjects.ToList( ))
        {

        }
        }

        But it does not detect the rectangles as drawn objects.....

        Please if you could guide me.

        Thanks again!

        Comment


          #5
          Hello facuevasm,

          See my suggestion in post #3.

          I have suggested you assign the indicator to a variable, and loop through the variable .DrawObjects.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thank you Chelsea. I put this code but nothing is printed on the output window.....



            protected override void OnBarUpdate()
            {
            myIndicator = ThirdPartyIndicator();
            foreach (DrawingTool draw in myIndicator.DrawObjects.ToList())
            {
            Print(draw.Name);
            }

            }

            Comment


              #7
              Hello facuevasm,

              Is ThirdPartyIndicator() drawing the drawing objects?

              Are you adding this to the chart with AddChartIndicator() from a strategy?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Ok, I add the indicator using:

                else if (State == State.DataLoaded)
                {

                AddChartIndicator(myIndicator);

                }

                But now I got this error on the Output:

                Strategy 'TestV1': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

                Comment


                  #9
                  Hello facuevasm,

                  How are the drawing objects getting on the chart if they are not being drawn by the indicator?

                  You can see these in the Drawing objects window, correct?

                  Did the indicator draw these, or did you draw these?

                  myIndicator needs to be assigned an instance of an indicator.

                  myIndicator = ThirdPartyIndicator();

                  Then it can be added to the chart with AddChartIndicator(myIndicator).

                  However, I was asking you if the indicator is drawing the objects and is being added to the chart with AddChartIndicator(). If they are not, then how are the drawing objects getting on the chart?

                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    I'm loading the indicator directly on the chart and I want to read the objects drawn by the indicator within the strategy.

                    Comment


                      #11
                      Hello facuevasm,

                      The instance added directly to the chart will not be accessible through any supported means, however, if instantiated to a variable and added to the chart with AddChartIndicator() that should work.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Ok, I was able to add the indicator using a variable, as you mentioned. But now the rectangles are not plotted on chart. What could be wrong?

                        Thank you!!

                        Comment


                          #13
                          Hello facuevasm,

                          The indicator is added to the chart by the strategy with AddChartIndicator() and is not be added to the chart directly correct?

                          Do you see the indicator appearing in the Indicators window?
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello Chelsea,

                            yes I add the indicator with AddCharIndicator() and I also see the indicator appearing in the Indicators window, but nothing displays on chart as I see when you load the indicator directly on the chart. Do you know what could be generating this?

                            Thank you!

                            Comment


                              #15
                              As you see in this screenshot, the indicator is loading, but it does not show any Properties... so that's also weird.

                              Click image for larger version

Name:	screenshot.JPG
Views:	202
Size:	34.8 KB
ID:	1208963

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Yesterday, 05:17 AM
                              0 responses
                              66 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              141 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              76 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              47 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              51 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X