Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Pass reference to Strategy into Indicator

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

    Pass reference to Strategy into Indicator

    I would like to use the value of

    MyStrategy.Position

    in OnBarUpdate() of an indicator which is created by the strategy in its "if (State == State.Configure)" section.

    Is there a vay to do that?

    I have tried the usual C# stuff, such as declaring:

    public Strategy Strategy { get; set;}

    In the Indicator and using:

    MyIndicator.Strategy = this;

    just after creating the indicator object.

    Everything I try has not worked yet.

    Is there a way to do it?

    #2
    Hello AlgoJason,

    You would likely need to create an enum in the indicator to represent the market position, create a public input with this, and then set the input of the indicator from the strategy in an if statement or switch in OnPositionUpdate.

    Below is a link to an example of an enum.


    And a link to an example of setting an indicator value from a strategy.
    When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    637 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    571 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X