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

How can we access objects drawn of chart

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

    How can we access objects drawn of chart

    for example, one of the indicator draws lines on chart.
    I want (without touching that indicator) from another indicator, to get the values of those line.


    how can i achieve that from another indicator?

    thanks in advance.

    #2
    Hello,

    Thank you for the post.

    If the lines you are showing are Plots, you may be able to access their values from code. The syntax would very likely be:

    IndicatorName(parameters).PlotName[0]

    If these are instead drawing objects, you would need to be able to access the code for the indicator in question to expose some value for another indicator to see. Indicator drawn objects are not listed in the drawing object collection another script would see so it would not be possible to detect a script drawn object from another script.


    I look forwad to being of further assistane.
    JesseNinjaTrader Customer Service

    Comment


      #3
      can you advise:

      that source code is protected, have no idea of how the lines are generated, even they are not exposed.
      Last edited by ttodua; 07-30-2019, 07:08 AM.

      Comment


        #4
        Hello,

        Thank you for the reply.

        That looks like it could potentially be a drawing tool as well, just placed above the line. It could also be custom rendering.

        If you open the Indicators properties, do you see Plots listed where you can set their color? it would look similar to the Bollinger indicator pictured here:


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

        Comment


          #5
          no, there is no "PLOT" subgroup in options windows of that indi ...

          Comment


            #6
            Hello,

            Thank you for confirming that.

            In the situation where the indicator has no exposed plots, it would not be possible without having the code for that item. It seems this was not created in a way that exposes its data to be accessed from another script. You could try contacting the developer/vendor of this item to double check that it does not have any way to access the values you want and also to request they add that as a feature.

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

            Comment


              #7
              can you give me any kind of solution?
              Last edited by ttodua; 07-30-2019, 07:09 AM.

              Comment


                #8
                Hello,

                Thank you for the reply.

                In the terms of how the program works, yes, these items do exist somewhere in memory. Unfortunately, you will not be able to access them how you want.

                Regarding accessing objects in simple programming terms, all languages generally have some Context which provides a way to access some object you have defined. In C# structure is very important and there are cases where you cannot access an object due to the context in which it is defined. Access modifies may also prevent you from accessing what you want like a private variable, this cannot be seen from other places. To learn more about how C# works in this respect, I would suggest reviewing the following document: https://docs.microsoft.com/en-us/dot...ing-namespaces


                In this case, there is really no more to detail I could provide. A script cannot access another script's drawn objects using the collections which are available to NinjaScript.

                You can check this yourself using the following example and a secondary indicator applied to the same chart that draws some object: https://ninjatrader.com/support/foru...1&postcount=10
                Looping through the collection even with no filters will result in 0 objects found. The indicator you are using would need to expose some data as a DataSeries in order for another script to access that data.


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

                Comment


                  #9
                  I know PHP programming well, and there is one thing.. for example, when all things are outputed (doesnt matter private namespace variables or etc..), but everything, that is ECHO-ed, in the end of execution, can be obtained with command `ob_get_contents()`.
                  Last edited by ttodua; 07-30-2019, 07:10 AM.

                  Comment


                    #10
                    Hello,

                    Thank you for the reply.

                    In this case, there is really no comparison. PHP is a web server based language that has its own structure and intrinsics where C# has its own structure and intrinsics. The method you have linked is a method specific to PHP and how that language works.

                    C# is not going to work like PHP in a large number of ways so this concept is not directly possible. There is not an output buffer or way generally access all output in C# in the context of NinjaScript, instead, you would need to write the data to file or a variable if you wanted to accumulate some output from some logic being run. We have some samples of writing and reading data at the following page: https://ninjatrader.com/support/foru...ead.php?t=3220

                    What specifically are you trying to output in this way? Perhaps there is a specific method or C# way to do the task you are trying. I did want to mention that we have some guidelines on debugging in NinjaTrader if you are trying to debug something by means of Ouptut: https://ninjatrader.com/support/foru...749#post413749

                    There is no central location for data in NinjaTrader, it really depends on what specifically you are trying to access in the platform and that would relate to where it would be located. The help guide tries to isolate each topic as best as it can to differentiate the different areas of NinjaScript. If you are unsure of the location of what you want to access, please provide a description and we could try and point out where it is.

                    The closest thing I can think of to what you have linked would be to just create a string variable and append strings to it:

                    Code:
                    string myString = "";
                    
                    for(int i = 0; i < 3; i++)
                    {
                        myString += "Some Output " + System.Environment.NewLine;
                    }
                    Print(myString);
                    Which would output

                    Some Output
                    Some Output
                    Some Output

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

                    Comment


                      #11
                      ---------------------
                      Last edited by ttodua; 04-19-2018, 02:12 AM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by funk10101, Today, 12:02 AM
                      1 response
                      10 views
                      0 likes
                      Last Post NinjaTrader_LuisH  
                      Started by GLFX005, Today, 03:23 AM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_Erick  
                      Started by nandhumca, Yesterday, 03:41 PM
                      1 response
                      12 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by The_Sec, Yesterday, 03:37 PM
                      1 response
                      11 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by vecnopus, Today, 06:15 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post vecnopus  
                      Working...
                      X