Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing Instrument on Different Timeframe

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

    Accessing Instrument on Different Timeframe

    Hi

    I'm trying to access a 60 min ATR value from within a strategy that is attached to a one minute chart. I don't want to add the 60 minute timeframe, just access the value.

    So far I have:

    myThreshold = ATR(GC 06-10 (60 min),14)[1];

    But it's throwing syntax errors.

    Any guidance would be appreciated.

    #2
    Hi FatCanary,

    For this you would need to add a series to the strategy, then access the indicator with the correct context.

    More info at - http://www.ninjatrader-support.com/H...ameInstruments

    See the CCI indicator example in the above link.
    TimNinjaTrader Customer Service

    Comment


      #3
      Thanks, Tim.

      Works great for a minute chart but now I'm struggling with accessing daily values.
      I have:

      Add("GC ##-##",PeriodType.Day,1);

      This compiles fine and the strategy is enabled ('**NT** Enabling NinjaScript strategy...' in output window) but it does not appear to be running.

      Comment


        #4
        Hi FatCanary,

        What chart type (period) are you adding this to?

        Can you clarify "does not appear to be running."?
        TimNinjaTrader Customer Service

        Comment


          #5
          Adding to one minute chart.

          I have the ouput window set to print the ATR value (from the added series) for each of the primary series bars. But when I try to access the daily ATR value nothing prints except '**NT** Enabling NinjaScript strategy ...'

          So it appears to not be running and the chart shows no trades taken.

          Comment


            #6
            Hi FatCanary,

            What datafeed provider are you connected to?
            TimNinjaTrader Customer Service

            Comment


              #7
              Hi Tim

              IQFeed - for test purposes. I have Zenfire if necessary.

              Comment


                #8
                Hi FatCanary,

                How are you trying to access the daily ATR values? Can you please provide the relevant code snippets.
                TimNinjaTrader Customer Service

                Comment


                  #9
                  Hi Tim

                  Here's the relevant code:

                  protected override void Initialize()
                  {
                  SetStopLoss("", CalculationMode.Ticks, myStopLoss, false);

                  CalculateOnBarClose = false;
                  Add("GC ##-##",PeriodType.Day,1);
                  }

                  ...other code ...

                  protected override void OnBarUpdate()
                  {
                  adxThreshold = ATR(BarsArray[1],14)[1];

                  ...rest of code ...

                  The only difference when I tested 60 minutes was ...PeriodType.Minute,60);
                  which worked fine.

                  Comment


                    #10
                    Hi FatCanary,

                    Are you getting any errors in the log tab of the Control Center?

                    Make sure you have enough bar to cover the 1440 minutes to look back on the ATR with...


                    protected override void OnBarUpdate()
                    {
                    if (CurrentBarArray[1] > 0)
                    {
                    rest of code..
                    }
                    }
                    TimNinjaTrader Customer Service

                    Comment


                      #11
                      Hi Tim

                      if (CurrentBarArray[1] > 0) fixed the charting issues, thanks.

                      Unfortunately now, when I run a backtest, I get zero results.
                      So, for today I have 8 trades showing on the chart but Strategy Analyzer is showing all zeros.

                      Comment


                        #12
                        Hi FatCanary,

                        Which version of NinjaTrader are you using?

                        Can you send a screenshot of your strategy backtest settings.

                        To send a screenshot press Alt (sometimes Fn key) + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CRTL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.
                        TimNinjaTrader Customer Service

                        Comment


                          #13
                          Tim,

                          Using Beta 7.0.0.15.

                          Also tried minimum bars req'd: 1440.
                          Attached Files

                          Comment


                            #14
                            Hi FatCanary,

                            I will try this on my end as well, but first, can you try adjusting the "Maximum bars lookback" to Infinite.
                            TimNinjaTrader Customer Service

                            Comment


                              #15
                              Hi Tim

                              Max bars lookback set to infinite makes no difference.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              649 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              573 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              576 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X