Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using indicator parameters in Strategy

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

    Using indicator parameters in Strategy

    This follows from the Tutorial 2 sample strategy in the Help Guide (i.e. RSI with a Stop Loss and a Profit Target).

    Our entry condition is this:

    Code:
    if (CrossAbove (RSI([B]RSIPeriod[/B], RSISmooth), 20, 1))
    {[INDENT]EnterLong();
    [/INDENT]}
    Instead of setting a new RSIPeriod for the strategy, I'd like to use the Period parameter from the RSI indicator, that is added during the Initialize() phase of the Strategy.

    How do I got about referencing it?

    Thanks!

    #2
    Hello nicbizz,

    Your strategy should control all the input parameters in this case.

    You can use the same variable name for both places: 1) adding the indicator for visualization in initialize 2) evaluating indicator values in OnBarUpdate() for an order condition. This is what is shown in the example.

    You can access the indicator "Period" value but there is no benefit to this. Since the user never has access to this indicator input when running the strategy, it will always be the default value for Period in the RSI indicator.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      THanks for the reply.

      Perhaps this is not the best example to illustrate what I'm attempting to do.

      Let's say I have a custom indicator called IndicatorX, which has a public property called PricePoint.

      If I'd like to reference the value of PricePoint in my strategy, what is the correct syntax to do so?

      In regular C#, I'd have to create an instance of IndicatorX .....

      IndicatorX thisIndicator = new IndicatorX();

      and then call the property using thisIndicator.PricePoint.

      -Nick

      Comment


        #4
        Originally posted by nicbizz View Post
        Hi Ryan,

        THanks for the reply.

        Perhaps this is not the best example to illustrate what I'm attempting to do.

        Let's say I have a custom indicator called IndicatorX, which has a public property called PricePoint.

        If I'd like to reference the value of PricePoint in my strategy, what is the correct syntax to do so?

        In regular C#, I'd have to create an instance of IndicatorX .....

        IndicatorX thisIndicator = new IndicatorX();

        and then call the property using thisIndicator.PricePoint.

        -Nick
        That is one way to do it.

        Comment


          #5
          Nicbizz,

          Yes, that is how you would do it. Can see this sample for best practices on exposing non-plot value from another indicator:
          Ryan M.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X