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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    82 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    43 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X