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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      160 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      308 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      245 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      349 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X