Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Values of DynamicSRLines

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

    Values of DynamicSRLines

    https://ninjatraderecosystem.com/use...amicsrlines-2/

    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.

        https://ninjatrader.com/support/help...?draw_line.htm

        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, 11:37 AM.

          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.

            https://stackoverflow.com/questions/...-double-to-int
            https://www.w3schools.com/cs/cs_type_casting.asp
            https://docs.microsoft.com/en-us/dot...pe-conversions
            https://www.geeksforgeeks.org/c-sharp-type-casting/

            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.

                https://ninjatrader.com/support/help...lueComparisons

                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#.

                https://www.w3schools.com/cs/cs_conditions.asp

                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

                        https://ninjatraderecosystem.com/use...indicator-nt8/

                        Last edited by DTSSTS; 10-09-2020, 11:25 AM.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by janiyaconnelly, Today, 10:41 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post janiyaconnelly  
                        Started by slimoriginus, Today, 10:07 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post slimoriginus  
                        Started by slimoriginus, Today, 10:05 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post slimoriginus  
                        Started by KevinWalker, Today, 07:48 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post KevinWalker  
                        Started by WaveAtElliot, Today, 05:11 PM
                        1 response
                        14 views
                        1 like
                        Last Post hdge4u
                        by hdge4u
                         
                        Working...
                        X