Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Today, 09:29 PM
    0 responses
    7 views
    0 likes
    Last Post Belfortbucks  
    Started by zstheorist, Today, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    151 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    6 views
    0 likes
    Last Post mattbsea  
    Working...
    X