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

To add indicator to the chart with specific bar period

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

    To add indicator to the chart with specific bar period

    Hello.

    I use 2 different bar periods in my strategy, Some of indicators are linked to main period, some of them are linked to second period. For example:

    Code:
    protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
    ......
                }
                else if (State == State.Configure)
                {
                    AddDataSeries(Data.BarsPeriodType.Minute, 10);
                }
                else if (State == State.DataLoaded)
                {
                    sma = SMA(BarsArray[0],21); //With default bar period
                    rsi = RSI(BarsArray[1],14,3); //With 10 mins period
    
    
                    AddChartIndicator(sma);
                    AddChartIndicator(rsi); //I expect to see RSI with 10 minutes bar period
                }
            
            }
    Supposedly I must have RSI placed on 10 minutes period. But really I have RSI placed with default bar period. Look at the attachment, please
    Attached Files

    #2
    Hello rfsettling,

    Thanks for your post.

    With reference to the helpguide section on AddChartIndicator there is this note:"An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same Add series call included as well)
    o If a secondary or null Bars series is specified by the calling strategy (not the indicator itself), the strategy's primary series will be substituted instead."
    Link: http://ninjatrader.com/support/helpG...tindicator.htm

    The alternatives are as the helpguide advises or you can manually add a hidden data series to the chart itself and then manually add the RSI and point the RSI to the hidden data series. Here is a link to another thread/post where I have detailed the process to add a hidden data series and add an indicator that uses the hidden data series: http://ninjatrader.com/support/forum...28&postcount=2
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by AttiM, 02-14-2024, 05:20 PM
    11 responses
    184 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by fernandobr, Today, 09:11 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by timmbbo, Today, 08:59 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by KennyK, 05-29-2017, 02:02 AM
    2 responses
    1,281 views
    0 likes
    Last Post marcus2300  
    Started by itrader46, Today, 09:04 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X