Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need to get SMA(3)[2] value in custom indicator

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

    Need to get SMA(3)[2] value in custom indicator

    In the custom indicator I'm trying to create, SMA(3)[0] works as intended, but when I use SMA(3)[2] the indicator display goes blank. How can I compare the current close to the value of the SMA 2 bars ago? Here's a section... Thanks.

    protectedoverridevoid OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.

    if (Close[0] > SMA(3)[2])
    {
    UpSMA3disp2.Set(
    2);
    }
    if (Close[0] < SMA(3)[2])
    {
    DownSMA3disp2.Set(
    2);
    }
    if (Close[0] == SMA(3)[2])
    {
    NeutralSMA3disp2.Set(
    2);
    }

    #2
    Hello jmneale,

    Most likely you will need CurrentBar check according to this link:
    Make sure you have enough bars in the data series you are accessing

    if (CurrentBar < 2)
    return;
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you. Worked Perfectly.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X