Announcement

Collapse
No announcement yet.

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.


    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.


        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 NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          62 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          134 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X