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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          61 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          149 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X