Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting higher time frame MA

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

    Plotting higher time frame MA

    I am trying to plot 13 period MA from 15 min chart on a 5 min chart. But for some reason the code does not work. Can someone please help me with what am I doing wrong here?

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Add(PeriodType.Minute, 15);
    Overlay = true;
    }


    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
    return;

    if (BarsInProgress == 0)

    {
    Plot0.Set(SMA(BarsArray[1], 13)[0]);

    }
    }

    #2
    Hello pandyav ,

    It looks OK. Are there any error messages in log tab of control center?

    One thing I would change is this statement:
    Code:
    if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
    return;
    Since you only have a primary and secondary series, there is never a Currentbars[2] defined. I would remove that check here:
    Code:
    if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
    return;
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      It works now and I can see the SMA line. But the question is why the line is in 'step by step' fashion. It should be a smooth line since it is SMA. Any idea? I am attaching the latest picture.
      Attached Files

      Comment


        #4
        Pandyav,

        It's because you're plotting a higher time frame SMA on a smaller time frame chart. each 15 minute bar takes up 3 five minute bars, so the value will remain the same for 3 bars and then move.

        VT

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bmartz, 03-12-2024, 06:12 AM
        5 responses
        32 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by Aviram Y, Today, 05:29 AM
        4 responses
        12 views
        0 likes
        Last Post Aviram Y  
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        28 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X