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

Accessing other indicators

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

    Accessing other indicators

    I want to plot lines using Pivots (included indicator for NT8). When I write the following lines it gives me the error message. : CS0122: 'Member' is inaccessible due to protection level
    What do I need to do?



    R2 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 100).r2;
    R1 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 100).r1;
    PP = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 100).pp;
    S1 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 100).s1;
    S2 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 100).s2;

    #2
    Hello Gregorio,

    The plots returned by the Pivots indicator are data series. You would need to select a bars ago index for the collection.

    Try:
    Code:
    double R2 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 100).R2[0];
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Gregorio,

      The plots returned by the Pivots indicator are data series. You would need to select a bars ago index for the collection.

      Try:
      Code:
      double R2 = Pivots(PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 100).R2[0];
      Same error! :-(

      Comment


        #4
        Gregorio,

        Are you certain that is the code you are testing and that is the code you are getting an error for?

        I have copied and pasted this exact code into a test script and have compiled without error and have run the script and this has printed to the Output Window without error.

        Attached is the script that I have tested this in.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          You are right, there was a mistake in my version in my line! Thanks for the correction! :-)

          Comment


            #6
            The NinjaScript gives no error but the log still gives me an error when i try to use this double and plot it on my indicator. I am in NT8. Can you give my a sample indicator for that too.
            Thanks!

            Comment


              #7
              Hello Gregorio,

              For future reference, I am including a link to the NinjaTrader 8 section of the forums.


              Attached is the same example script created for NinjaTrader 8 Beta.

              One thing to keep in mind, is that the Pivots indicator adds a secondary series to the script. With NinjaTrader 8, any script that calls an indicator with a secondary series, also has to have that secondary series added to itself.
              (Meaning if a strategy calls an indicator that has a secondary series added, the strategy also needs that same secondary series added)
              Attached Files
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Meaning that: if my indicator needs intraday bars I can forgot about this project of mine?
                Pivots need this: AddDataSeries(BarsPeriodType.Day, 1);

                Comment


                  #9
                  Hello Gregorio,

                  I'm not understanding your inquiry.

                  When you mention " if my indicator needs intra-day bars I can forgot about this project of mine?", can you clarify what this means?

                  If an indicator is being called that adds a secondary series that is intra-day, the calling indicator or strategy also needs that same secondary series added.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    I mean, my indicator, where i call Pivots from, is an indicator using intra-day bars. But when I include this line: " AddDataSeries(BarsPeriodType.Day, 1); " that Pivots indicator needs for working, as you said, then my indicator stops plotting what it has plotted so far. Meaning those two things are not working together.

                    Or, i just need to learn more about scripting! :-)

                    Comment


                      #11
                      Hello Gregorio,

                      When you add a data series to the script, this causes OnBarUpdate to process for that added series.

                      For the logic to be the same, you would need to add a condition to only process during the primary series (BarsInProgress 0). I have demonstrated this in the example I have provided to you.

                      May I confirm you have done the same in your script?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks for the help! That has done the trick.

                        I really should learn more about this stuff. What I know so far I learnt by reading the indicator scripts line by line, trying to understand them. And tweaking them to my needs. :-)

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Tim-c, Today, 02:10 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post Tim-c
                        by Tim-c
                         
                        Started by cre8able, Today, 01:16 PM
                        2 responses
                        9 views
                        0 likes
                        Last Post cre8able  
                        Started by chbruno, 04-24-2024, 04:10 PM
                        3 responses
                        48 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by samish18, Today, 01:01 PM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_LuisH  
                        Started by WHICKED, Today, 12:56 PM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Working...
                        X