Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I access methods in an indicator for

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

    How do I access methods in an indicator for

    a strategy? For example, in this custom indicator, there are numbers values that have been calculated which I need to build a strategy, how would I be able to access those values?

    #2
    Kay, if those are indicator plots they can be directly accessed as they are exposed by default already...if you want to access internal variables and unplotted data, you would need to with the concept presented here -

    http://www.ninjatrader-support2.com/...ead.php?t=4991
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand, I thought I followed the example you provided by Adding the indicator like this:-
      Code:
      
      protectedoverridevoid Initialize()
      {
      Add(TDSetup);
      Add(draftMA1);
      CalculateOnBarClose = true;
      }
      
      First error: The name TDSetup doesnot exist in the current context.
      Second error: The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.Add(NinjaTrader .Indicator.IndicatorBase)' has some invalid arguments.
      Third error: cannot convert from 'method group' to 'NinjaTrader.Indicator.IndicatorBase'

      Please advise what is wrong. Thx!

      Comment


        #4
        HI Bertrand, Just an update...I think I've solved most of the errors except the 1st one - First error: The name TDSetup doesnot exist in the current context.

        Can't access it from the strategy.

        Comment


          #5
          Is the TDSetup a plot from an indicator (shown in datseries when you apply in on the chart) or an internal value of an indicator?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            It is actually a series of 9 consecutive counts where each count's close is lower than the respective close 4 bars ago. it is a non-conventional indicator i suppose, which is why i asked how do you access methods from within an indicator for use in a strategy...

            Comment


              #7
              Kay, ok but is this a plot in the indicator or not? A plotted value could be directly accessed...

              MyIndicator(Parameter1, Parameter2).MyFirstPlot[0] ...

              If this is a not plotted value, you would need to expose it's values first to open it up for access via the calling strategy.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                I don't think it is a plotted value. They are just arithmetically-derived text on the chart.

                I guess what you are saying is the simplest way is to cut and paste the indicator to the strategy and build the strategy from there, no?

                Comment


                  #9
                  just an example of what i am trying to do (please see attached chart).

                  Everytime there is a descending '9' count, a "true" condition is triggered. And within 4 bars after the '9' count, if the close is greater than the purple line to enter a long position.
                  Attached Files

                  Comment


                    #10
                    Yes, that would be an option too - the other is to expose needed values as per this reference sample -

                    http://www.ninjatrader-support2.com/...ead.php?t=4991
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Bertrand, I cut and pasted the indicator code to the strategy...2 errors

                      The name 'Overlay' doesnot exist in the current context.
                      The name 'PriceTypeSupported' does not exist in the current context.

                      Would removing these 2 lines from Initialize() affect the strategy? That would mean I will get no display on the chart, right? But everything is being worked in the background, right?

                      Comment


                        #12
                        Kay, correct both those properties do not exist for NinjaScript strategies, so you would need to remove those to be able to compile it.

                        Not being familiar with your custom code, if you Draw it should be drawing in the strategy as well, but there would be no plots from the strategy excpect with workarounds...
                        BertrandNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by op1031, Yesterday, 05:16 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NT-Roland  
                        Started by sinpeople, Today, 07:20 AM
                        1 response
                        3 views
                        0 likes
                        Last Post NT-Roland  
                        Started by Frank1000, Today, 03:05 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NT-Roland  
                        Started by ntdev, Today, 01:14 AM
                        4 responses
                        16 views
                        0 likes
                        Last Post ntdev
                        by ntdev
                         
                        Started by ct, Today, 02:22 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Jason  
                        Working...
                        X