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 Max238, Today, 01:28 AM
    4 responses
    35 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by r68cervera, Today, 05:29 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by geddyisodin, Today, 05:20 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by timko, Today, 06:45 AM
    2 responses
    14 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by habeebft, Today, 07:27 AM
    0 responses
    7 views
    0 likes
    Last Post habeebft  
    Working...
    X