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 argusthome, Yesterday, 10:06 AM
        0 responses
        22 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        19 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        14 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        10 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        41 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X