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

adding an indicator to a strategy and access some of its values

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

    adding an indicator to a strategy and access some of its values

    Hi all,

    is there any sample script that shows and explains how to add an indicator into a strategy and how to access some of its values ? I am aware of AddChartIndicator but this is only for drawing purposes as far as I know, please correct me if I'm wrong. What I need is accessing values of the indicator and use them for my strategy logic.

    Please point me to the right direction. Thank you.

    #2
    Hello patricia70,

    Thanks for your post.

    For a sample, I would suggest using the Strategy Builder. The strategy builder will generate the code that you can see/copy if you wish.

    Here is a short video taking a quick look at a Bollinger indicator: https://Paul-ninjaTrader.tinytake.co...MV8xNzQ5Mzg5Ng

    In the video, it only shows accessing the upper value with Bollinger1.Upper[0]. With the code, you could also access the middle and lower by replacing Upper, for example:

    Bollinger1.Middle[0]
    or
    Bollinger1.Lower[0]

    In summary, create a private instance of the indicator, in state.DataLoaded initialize the private indicator. In OnBarUpdate() access the values of interest.


    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Paul and thanks for quick reply. I looked into the video you made, many thanks. I'd like to know: is there a way to retrieve ALL possible parameters of the instanciated indicator? In your demonstration for example you used Bollinger1.Upper[0] in Set1 logic. But how do I know which other parameters are retrievable for that indicator? In the example of Bollinger I know there is upper, middle and lower but is there another way to retrieve ALL of the possible and usable parameters without digging into the code of the indicator? In my example the indicator I wanna use is huge with lots of stuff. Let's say it has 20 possible plots or values (eg A, B, C, D, ....) . But I wanna access only 6 (A, C, G, J, N and V) of them. How do I access them?

      eg:

      if (Indicator1.A[0] && Indicator1.C[0] && Indicator1.G[0] && ... Indicator1.V[0] > foo)

      Comment


        #4
        Hello patricia70,

        Thanks for your reply.

        That was precisely why I recommended using the strategy builder.

        Using the "Value Plot" as a drop-down selector shows you the (names of the) available data selectors from the indicator.

        Once you have the data names you can change it as I showed in post #2.


        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi Paul,

          thanks you. I understood this because I already have done this in the past. I was curious if there was another way without using the strategy builder. I throught of kind of sort "retrieving" all available parameters of the indicator and even being possible to output (print) them in a series string to check them and their expected data types. But ok, if you say there is absolutely no other way then this is what it is.

          Thanks for your support.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, Today, 06:40 PM
          0 responses
          9 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          7 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          7 views
          0 likes
          Last Post quantismo  
          Started by AttiM, 02-14-2024, 05:20 PM
          8 responses
          168 views
          0 likes
          Last Post jeronymite  
          Started by cre8able, Today, 04:22 PM
          0 responses
          10 views
          0 likes
          Last Post cre8able  
          Working...
          X