Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MTF Ploting

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

    MTF Ploting

    Hi all,

    Im trying to develop a MTF indicator that plots data from higher timeframes.
    I wanted to start simple to test MTF functionality but Im lost.

    I already searched and read here and bigmike forums but cannot find the path.

    I have the following code, but I cannot see any line ploted:

    Code:
    protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.AppWorkspace), PlotStyle.Line, "M15"));
                Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "H1"));
                Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "H4"));
                Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "D1"));
    			
    			Add(PeriodType.Minute, 60);
    			Add(PeriodType.Minute, 240);
    			Add(PeriodType.Day, 1);
                Overlay				= true;
            }
    
         
            protected override void OnBarUpdate()
            {
                
            M15.Set(SMA(BarsArray[0],20)[0]);
    		H1.Set(SMA(BarsArray[1],20)[0]);
            H4.Set(SMA(BarsArray[2],20)[0]);
            D1.Set(SMA(BarsArray[3],20)[0]);
            }
    Thanks in advance

    #2
    P.D. I loaded 90 days of data, so the needed bars are there

    Comment


      #3
      Hello dotnetfreak,

      Thank you for your post and welcome to the NinjaTrader Support Forum!

      You will need to add a check for the bars needed, in this case 20 as the SMA is using a 20 period. The code at the beginning of your OnBarUpdate() needs to reflect the following:
      Code:
      if(CurrentBars[0] <= 20 || CurrentBars[1] <= 20 || CurrentBars[2] < = 20)
      return;
      For information on CurrentBars please visit the following link: http://www.ninjatrader.com/support/h...urrentbars.htm

      And for information on ensuring you have enough data before accessing it please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170

      Please let me know if you have any questions.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      580 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      336 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      102 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X