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 AaronKoRn, Yesterday, 09:49 PM
        0 responses
        11 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        10 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        11 views
        0 likes
        Last Post strategist007  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,981 views
        3 likes
        Last Post jhudas88  
        Started by rbeckmann05, Yesterday, 06:48 PM
        0 responses
        9 views
        0 likes
        Last Post rbeckmann05  
        Working...
        X