Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to use indicator in a strategy

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

    how to use indicator in a strategy

    hi

    I have written a custom indicator and want to use its readings in a custom strategy.

    How do I read the indicator from my strategy ?

    Can anyone help with a sample code ?

    Thanks in advance

    #2
    qewcool, you would just call it like the standard indicators, for example -

    Code:
     
    double myIndicValue = MyIndicator(Parameter1, Parameter2)[0];
    Just type your indicator name and add the brace, then Intellisense should offer you the overload you would need...

    Comment


      #3
      Thanks for the reply

      Sorry im a bit newbish to coding with NT

      So if i understand this will take the value of what is plotted in the value dataseries of the custom indicator ?

      What if my indicator had several plots (which it in fact has) ? how do I select which plot it will read when I call it.

      Or it will just read the first plot and the other plots cannot be read from a strategy ?

      Thanks for helping

      Comment


        #4
        qewcool,

        What Bertrand posted is good for accessing the values of a single plot indicator or DataSeries. If your indicator has several plots you can access the plots by their names individually.

        Take a look at the MACD indicator for instance. It has 3 plots. You can access them like so:

        MACD(some parameters).MACD[0]; <-- gets you the values of the MACD plot
        MACD(some parameters).Avg[0]; <-- gets you the values of the Avg plot
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Ok thanks a lot for the reply.

          will try it out when i get back.

          Comment


            #6
            I don't know how to correct this code error I looked up error CS0119 but couldn't figure out a solution. I tried the same code with MACD histogram and it worked but with this RSqueeze indicator it keeps giving an error.


            if (RSqueeze(RSqueeze.Utility.SqueezeStyle.CounterTre nd).PMomentumDown[0] > RSqueeze(RSqueeze.Utility.SqueezeStyle.CounterTren d).NMomentumUp[1])
            {
            DrawArrowUp("My up arrow" + CurrentBar, false, 0, 2, Color.Yellow);

            Thanks

            Comment


              #7
              chipotlebop,

              Can you please provide the exact text of that error message? I am not sure what CS0119 refers to. Thank you.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Hi Josh


                Strategy\AlertSqueeze.cs 'NinjaTrader.Strategy.Strategy.RSqueeze(RSqueeze.U tility.SqueezeStyle)' is a 'method', which is not valid in the given context CS0119 - click for info 45 26

                Thanks

                Comment


                  #9
                  Likely complaining about your use of RSqueeze.Utility.SqueezeStyle. It is saying RSqueeze is a method and you can't just use it as if it was a property.

                  Please check with the original author of this script to see how to properly parameterize it.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    ok

                    Ok, I will contact them directly. thanks again

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    662 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    376 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    110 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    574 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    580 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X