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 ghoul, Today, 06:02 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    44 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    20 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    179 views
    0 likes
    Last Post jeronymite  
    Started by DanielSanMartin, Yesterday, 02:37 PM
    2 responses
    13 views
    0 likes
    Last Post DanielSanMartin  
    Working...
    X