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

I created an Indicator and want to use it in a Strategy

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

    I created an Indicator and want to use it in a Strategy

    Hi all,
    I developed this really kewl indicator and want to use it in a very kewl strategy I am creating. The indicator has three Series: Lower, Middle and Upper. See below. I want to ask the question: Is Close[0] > Upper[0] or is Close[0] between Lower[0] and Middle[0].

    When I use the indicator in a chart, it does what it is supposed to.

    How do I reference them in my strategy?

    Thanks much!

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> Middle
    {
    get { return Values[0]; }
    }
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> Lower
    {
    get { return Values[1]; }
    }
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> Upper
    {
    get { return Values[2]; }
    }

    #2
    Hello morrnel,

    Thanks for your post.

    You would create a private instance of your indicator in the strategy, then initialize the private instance with the indicator s parameters in State.DataLoaded and then in OnBarUpdate() you would reference the name of the private instance followed by the name of the plot and the bar. For example, assuming your indicator was named Kewl:

    At the class level: private Kewl mylocalKewl; // create private instance

    In state.DataLoaded mylocalKewl = Kewl(your parameters);

    In the OnBarUpdate()

    if (Close[0] > mylocalKewl.Upper[0])
    {
    /./ do something
    }


    I would suggest using the Strategy builder to actually generate the code for you that you can copy into your startegy. New>Strategy Builder, then go to the conditions display and add a condition Close[0] greater than Indicators>(your indicator) and then select the "Value plot" to use. I've created a short video demonstrating this with the Bollinger indicator https://paul-ninjatrader.tinytake.co...MF8xMjk0NDg2Nw
    Last edited by NinjaTrader_PaulH; 03-31-2020, 11:53 AM. Reason: Replaced link.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much for the info. However, the link you shared doesn't exit.

      Comment


        #4
        Hello morrnel,

        Thanks for your reply.

        I've updated the link, I suspect I had an extra character at the end.

        Please try again.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          thank you. do you know I cannot respond with a simple thanks?

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jpapa, Today, 07:22 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by kevinenergy, 02-17-2023, 12:42 PM
          116 responses
          2,758 views
          1 like
          Last Post kevinenergy  
          Started by franatas, 12-04-2023, 03:43 AM
          7 responses
          106 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Jltarrau, Today, 05:57 AM
          3 responses
          9 views
          0 likes
          Last Post Jltarrau  
          Started by f.saeidi, Today, 05:56 AM
          2 responses
          8 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X