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

Getting line levels from code

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

    Getting line levels from code

    Hello,

    I would like to know how to get lines level from a chart in code.

    For example I have 3 Fib lines , 2 manual horizontal lines and Fin Extension line drawn on the chart. Now I would like to get the price levels of these lines from code so I can put them in a file on the computer.


    Any ideas how I could get these levels from code.
    I imagine I have a for loop but I need help to go further.

    Thank you

    #2
    OK I am sorry just found out my answer in preceding post...

    Comment


      #3
      blar58,

      Thanks for letting us know you found the solution. Please do not hesitate to ask for anything else.
      MatthewNinjaTrader Product Management

      Comment


        #4
        Matthew

        Yes I have a question because I didn't find out the right solution for me.

        I would like to get all lines price level that is actually drawn on a chart from code.

        It could be any lines : Fib Ret Fib Ext Manual horizontal lines....

        The following code works for horizontal lines only. I would like the code to get these levels for all kind of lines drawn not only horizontal lines.

        Code:
        foreach(IDrawObject o in DrawObjects)
        			{
        					
        				if (o.UserDrawn)
        				{					
        					
        					
        					if (o.DrawType == DrawType.HorizontalLine)
        					{
        						IHorizontalLine hLine = (IHorizontalLine)o;
        						Print(hLine.Y);		
        					}
        					
        				}
        			}
        Is there a way to do it

        Thanks

        Comment


          #5
          Hello,

          There is not a supported method to get all values from all objects drawn. You will need to define these and ask the foreach loop to look for each draw type.

          Please take a look at the following indicator which looks for user drawn drawtypes including drawline, ray, extended line, etc.

          MatthewNinjaTrader Product Management

          Comment


            #6
            Matthew,

            That answer my question


            Many thanks

            Comment


              #7
              I still have a few questions.

              I am building an indicator for a customer that wants to get the following :

              " I would like to have an indicator reading lines plotted on a chart.
              As far as lines go they are all different types. Some are drawn by my own indicators, some are by well known software like nexgen and some are drawn manually. The Nexgen fibs are drawn on the chart and we don't have access to their code so all we see is the end result.
              The indicator would have to be able to read those lines and plug the value to a text file. "

              I do not want to have all the code but just want to know if it is possible to read all these differents lines on the chart ?
              If yes maybe get a hint.

              Thank you !

              Comment


                #8
                Hello,

                There is not a supported method, but as a tip, please take a look at ChartControl.ChartObject

                We do not have any documentation on ChartControl and cannot define or guarantee any behavior with these methods.
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Matthew

                  I will take a look

                  Comment


                    #10
                    I am coming back to this problem because I am still looking for a solution.

                    I have an indicator called AutoPlotLevels. What this indicator does is drawing lines on the chart with the graphics.DrawLine method.

                    I am developing an indicator that reads these lines.

                    With manually drawn lines I have no problem reading the lines accessing the dawn object with the IDrawObject interface. (foreach(IDrawObject draw in DrawObjects))

                    But I don't know how to read the lines coming from an indicator taht has been applied on the chart.

                    Can you help me find a solution.

                    Thanks

                    Comment


                      #11
                      Hello,

                      Since these are graphics, there would be no way to read those directly. You would need to expose the levels you are using from the AutoPlotLevels as plots or a public variable and this would allow the second indicator to read the values that these graphics are drawn at.

                      Please take a look at our reference sample on Exposing indicator values that are not plots if you would rather not expose these levels as a plot:

                      MatthewNinjaTrader Product Management

                      Comment


                        #12
                        Can you tell me if it is possible and how I could read Fibonacci levels in my code ?

                        Thanks

                        Comment


                          #13
                          With IFibonacciRetracements you can read the Anchor points (startY & endY), which would be the 0% and 100% lines, but you cannot directly read the individual lines. If you would like these values to be read by an indicator, you can calculate these values from the anchor points.
                          MatthewNinjaTrader Product Management

                          Comment


                            #14
                            If I try to read Start and end value for Fibonacci Retracements with the following
                            code I have the following choices with the draw object :

                            AutoScale
                            <DeepClone>
                            Drawtype
                            Locked
                            SeparateZOrder
                            Tag
                            ToString
                            UserDrawn


                            Code:
                            foreach (IDrawObject draw in DrawObjects)
                            {
                                   if (draw.DrawType == DrawType.FibonacciRetracements)
                            		Print(draw.xxxx    );
                            }
                            I don't have access to EndY or StartY ?

                            Comment


                              #15
                              Sorry there will not be an exposed value for the Start/EndY with the DrawType.FibonacciRetracements

                              If the code is plotting the FibRetracement, you can use IFibonacciRetracements to read the Start/EndY

                              Code:
                              IFibonacciRetracements fibRetracements = DrawFibonacciRetracements("tag1", true, 10, Low[10], 0, High[0]);
                                          
                               Print(fibRetracements.StartY);
                              MatthewNinjaTrader Product Management

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DanielTynera, Today, 01:14 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post DanielTynera  
                              Started by yertle, 04-18-2024, 08:38 AM
                              9 responses
                              40 views
                              0 likes
                              Last Post yertle
                              by yertle
                               
                              Started by techgetgame, Yesterday, 11:42 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post techgetgame  
                              Started by sephichapdson, Yesterday, 11:36 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post sephichapdson  
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,615 views
                              0 likes
                              Last Post aligator  
                              Working...
                              X