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 jeronymite, 04-12-2024, 04:26 PM
          2 responses
          29 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by Mindset, 05-06-2023, 09:03 PM
          10 responses
          264 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by michi08, 10-05-2018, 09:31 AM
          5 responses
          742 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by The_Sec, Today, 02:29 PM
          0 responses
          4 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Started by tsantospinto, 04-12-2024, 07:04 PM
          4 responses
          63 views
          0 likes
          Last Post aligator  
          Working...
          X