Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple time-frames on chart and horizontal lines on indicator

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

    Multiple time-frames on chart and horizontal lines on indicator

    Hi,
    I have couple of questions regarding multiple time-frames when using a strategy.

    Assume I have the following code:
    Code:
            protected override void Initialize()
            {
    
                CalculateOnBarClose = true;
                
                Add(PeriodType.Minute, 60); //adding 60 minutes poriod
    
                Add(SMA(50));  //adding SMA to the chart
                Add(ADX(5));  //adding ADX to the chart
            }
    1. Can I add the SMA to the chart, based on the 60 minutes period, regardless of the timeframe selected on the chart [usually 10 minutes]?
    2. When I add the ADX, I see 2 horizontal lines add automatically to it on levels 25 & 75. Can I change those levels? Can I add more than 2 lines? [let's say 10,20,80,90]

    Thanks.

    #2
    gogetit,

    1. You could do this by calling a MulitSeries indicator in the strategy, where you calculate the SMA needed always on the desired timeframe.

    2. To customize lines from indicators, please see the last section of this tip - http://www.ninjatrader.com/support/f...ead.php?t=3228

    Have a good weekend,

    Comment


      #3
      Can you please tell me why I can't see any difference on my chart? what's wrong with the following code?

      Code:
              protected override void Initialize()
              {
                  CalculateOnBarClose = true;
                  
                  Add(PeriodType.Minute, 60);
              }
      
      
              protected override void OnBarUpdate()
              {
                  double sma=SMA(BarsArray[1],100)[0];
                  if(Close[0]<sma){
                      DrawDot(Bars[0]+"sma",false,0,High[0]+TickSize*10,Color.Green);
                  }else{
                      DrawDot(Bars[0]+"sma",false,0,Low[0]-TickSize*10,Color.Red);
                  }
              }

      Comment


        #4
        Hi gogetit,

        One thing you're missing is checking update context with BarsInProgress.

        That means when you use Close[0] it could refer to updates to any series. To exclude everything but the primary, write at the top of OnBarUpdate():
        if (BarsInProgress != 0) return;
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        672 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        379 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        577 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        582 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X