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

Indicator in a strategy

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

    Indicator in a strategy

    Hi,
    I am trying to develop a multi timeframe strategy,
    I have my indicator and i would like to use the indicator values from within my strategy,
    I would also want to plot the indicator out to the chart panels
    The indicator has many input properties,

    What i already did:
    I added the indicator to the chart,
    I added the indicator to my strategy, but i was needed to enter the same many input properties into both my indicator and my strategy

    My questions are:
    1. Is it possible to plot the indicator from within my strategy (to other panel than the bars panel)
    2. Is it possible to read the indicator values directly from the chart so i wont need to create the indicator in my strategy ?

    Thanks,​

    #2
    Hello yaniv,

    If you manually added the indicator to a chart that won't be the indicator that the strategy is using, that's just another instance that you would have to configure separately. To have the indicator that the strategy is using displayed you would use AddChartIndicator however that only works if the indicator is using the primary data series. If the indicator is using a secondary series it can't be added visually.

    To have one set of user inputs you would need to create user inputs in the strategy for the indicators inputs that you wanted to control, then when you call the indicator in the strategy you would pass the strategies inputs to the indicator to use.

    The SampleMACrossOver strategy is a good example of this concept, the strategy adds users inputs that are passed to the SMA indicators as the period. Those indicators are also being added visually.

    Where the indicator plots is determined by the indicator, if it by default uses a sub panel then when you add it using AddChartIndicator it will make a new panel.

    You can't read the values from the indicators on the chart, your strategy needs to add them in its code for it to work correctly.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks,
      So what should I do if I want to plot the indicator that is using a secondary data series ?

      Thanks

      Comment


        #4
        Hello yaniv,

        In that case you would need to replot the value yourself using the strategy. A strategy can use AddPlot to have plots in the strategy panel or you can use custom indicators to plot in secondary panels from a strategy.

        The process would involve setting the indicators value in BarsInProgress 0, for example:

        if(BarsInProgress == 0)
        {
        Value[0] = SMA(Closes[1], 12)[0]; // setting the current value from the secondary series SMA
        }


        You can find an example of a strategy that has two dummy indicators which pull data from the strategy for plotting purposes in the following link. That concept could be used if you wanted to plot in multiple panels. In this case you would also need to use a Series<double> inside of the strategy so that you can store indicator values during BarsInProgress 0, the indicator can then access that series to plot the values.

        https://ninjatrader.com/support/help..._a_ninjasc.htm
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Balage0922, Today, 07:38 AM
        0 responses
        3 views
        0 likes
        Last Post Balage0922  
        Started by JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        19 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        6 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Working...
        X