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

Values of DynamicSRLines

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

    Values of DynamicSRLines

    This indicator draws horizontal Support/Resistance lines at various price levels, above and below the market, where price historically created swing High/Low pivots multiple times, creating support and resistance as price action bounced off of those levels.


    How do I extract the values of DynamicSRLines for my strategy?
    How do I get the values of L1, L2, L3 of Resistance and Support?

    I tried DynamicSRLines.SL1[0]
    which isn't working.

    Thank you!

    #2
    Hello johnnybegoode,

    Thanks for your post.

    You can check the indicator's source code to see if it exposes information through plots or creates public properties that can be accessed from other scripts.

    This indicator does not add any plots, so it would have to be modified in order for a strategy to access it. Our documentation on AddPlot describes how plots can be added and how values can be set. If you right click on the Indicators folder in the NinjaScript Editor and select New Indicator, you could add a plot there and a Series<double> will be added that matches the plot name. You can then follow the syntax created by the New Indicator Wizard to add plots to this indicator, and those plots can then be accessed by the strategy.

    AddPlot() - https://ninjatrader.com/support/help...t8/addplot.htm

    The indicator draws lines with Draw.Line, and the information that is used to create the line would then be used to set a plot value.

    Please let us know if you have any questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Could you show me one example like how to AddPlot for SL1,
      so I could figure out the rest of them?
      Thank you!

      Comment


        #4
        Hello johnnybegoode,

        AddPlot can be called in OnStateChange under State.SetDefaults.

        Code:
        protected override void OnStateChange()
        {
          if (State == State.SetDefaults)
          {
            Name = "Examples Indicator";
        
            // Add three plots and associated Series<double> objects
            AddPlot(Brushes.Blue, "PlotA");     // Defines the plot for Values[0]
            AddPlot(Brushes.Red, "PlotB");     // Defines the plot for Values[1]
            AddPlot(Brushes.Green, "PlotC");   // Defines the plot for Values[2]
          }
        }
        Please reference the Draw.Line documentation for more information on what each parameter is used for. This will direct you further to what would be assigned as the plot value.



        For example, we see the line:

        Draw.Line (this, "supLine"+level, false, 0, p-((ZoneTickSize*TickSize)/2), MaxLookBackBars, p-((ZoneTickSize*TickSize)/2), ColorBelow, DashStyleHelper.Solid, 1);

        The line is being drawn at p-((ZoneTickSize*TickSize)/2)

        Each plot would need to be assigned this value. Since as a loop is used, you can use "level" when you are referencing the Values Series.

        Values[level-1][0] = p-((ZoneTickSize*TickSize)/2);

        If this is too difficult, I would recommend first building a simple test indicator that assigns Close[0] to Values[0][0] following the AddPlot documentation. A consultant could also be considered to make these modifications for you.

        Let me know if I can be of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          johnnybegoode

          did you figure this out, I am having same issues, I know how to add plot, but i have not been able to determine the plot equals

          thanks

          when i use Jim code

          PlotA[0]=Values[level-1][0] = p-((ZoneTickSize*TickSize)/2);

          i get an error "Cannot implicityly convert type double to int. An explicity conversion exists (are you missing a cast?)

          thanks for any help
          Last edited by DTSSTS; 09-27-2020, 12:37 PM.

          Comment


            #6
            Hello DTSSTS,

            '=' is an assignment operator. This is used to assign values to a variable. '==' would be an equality operator that checks if two values are equal.

            The error you are receiving would mean you are trying to assign a double to an int. These are not the same variable types and the code will not compile. If you look up the C# compile error, you can learn more about it, and also about casting.

            Publicly available resources on this error and casting can be found below.

            I want to make a program that converts Fahrenheit to Kelvins but in the conversion, you need to add 273.15. My current code for the conversion is int finalTemp = (temp1 - 32) * 5 / 9 + 273.15...

            W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


            A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.


            We look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #7
              so you are saying use


              PlotA[0]==Values[level-1][0] = p-((ZoneTickSize*TickSize)/2);

              Comment


                #8
                Hello DTSSTS,

                We must understand the code we are writing and the errors we encounter to correct an issue with the code. I am not making a direct suggestion on how to change your code since the code written should be understood.

                You are combining an assignment operation and an equality check in the same line of code which would not be advised. If you want to make an equality check within an if statement, you can use the Strategy Builder to generate syntax.



                The code would be similar, to use an if statement that has an equality check (not an assignment operation) in the condition.

                I have also included a publicly available resource on writing conditions in C#.

                W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


                We look forward to assisting.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  I have added plots many times using = and of course other information, on this indicator i just cannot seem to find what the plots it creates are actually called to reference

                  Guess I will use the old stand by $ 300 coder

                  Thanks

                  Comment


                    #10
                    Hey guys,
                    Did you figure this out?
                    I'm having the same issue and can't find a good example to use DynamicSRLines indicator.

                    Thanks

                    Comment


                      #11
                      Hello vcapeluto,

                      The indicator does not expose plots that can be referenced by a strategy.

                      The indicator will need to be modified so that plots are added and values would need to be assigned to the plots for use with a strategy. (Please see posts #2 and #4.)

                      We will leave the thread open for other community members in this thread to share if they have been successful making these modifications.
                      JimNinjaTrader Customer Service

                      Comment


                        #12
                        vcapeluto I move onto this indicator

                        https://ninjatraderecosystem.com/use...ad/swingrays2/

                        I did not really care for the way the other plotted the levels on the chart, I added a plot of the trigger of the levels from the Which is only one bar, then went to my coding team to extend the plots as a reference to use later, but you could probably add the 1 bar plot and then use that in a trigger of some sort

                        you may like this as well, does NOT add plots for Strategies etc, but displays on charts

                        When applied to a chart LabeledRays will render the end anchor price level for all Ray drawing objects.


                        Last edited by DTSSTS; 10-09-2020, 12:25 PM.

                        Comment


                          #13
                          The indicator does not expose plots that can be referenced by a strategy.

                          Comment


                            #14
                            Which indicator elise11

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by adeelshahzad, Today, 03:54 AM
                            4 responses
                            25 views
                            0 likes
                            Last Post adeelshahzad  
                            Started by merzo, 06-25-2023, 02:19 AM
                            10 responses
                            823 views
                            1 like
                            Last Post NinjaTrader_ChristopherJ  
                            Started by frankthearm, Today, 09:08 AM
                            5 responses
                            17 views
                            0 likes
                            Last Post NinjaTrader_Clayton  
                            Started by jeronymite, 04-12-2024, 04:26 PM
                            3 responses
                            43 views
                            0 likes
                            Last Post jeronymite  
                            Started by yertle, Today, 08:38 AM
                            5 responses
                            16 views
                            0 likes
                            Last Post NinjaTrader_BrandonH  
                            Working...
                            X