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

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...
    BertrandNinjaTrader Customer Service

    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 ETFVoyageur, Today, 02:15 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post ETFVoyageur  
                    Started by Board game geek, Today, 01:34 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post Board game geek  
                    Started by morrnel, 05-12-2024, 06:07 PM
                    3 responses
                    38 views
                    0 likes
                    Last Post wzgy0920  
                    Started by FishTrade, Yesterday, 11:11 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post FishTrade  
                    Started by Austiner87, Yesterday, 03:42 PM
                    1 response
                    21 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Working...
                    X