• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 ahm1992, Today, 04:56 PM
          6 responses
          28 views
          0 likes
          Last Post bltdavid  
          Started by firstlanetech, Today, 11:24 AM
          2 responses
          29 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by grayfrog, Today, 09:29 PM
          0 responses
          5 views
          0 likes
          Last Post grayfrog  
          Started by alcorr247, Today, 12:04 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_EricB  
          Started by HiddenPhilosopher, Today, 11:08 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X