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 Jeremytang, 07-14-2018, 06:45 PM
      21 responses
      439 views
      0 likes
      Last Post mav8rick  
      Started by LeonK, Yesterday, 09:26 PM
      1 response
      8 views
      0 likes
      Last Post bltdavid  
      Started by NicholasJoannette, Yesterday, 03:01 PM
      2 responses
      12 views
      0 likes
      Last Post NicholasJoannette  
      Started by rach1994, Yesterday, 12:20 PM
      1 response
      35 views
      0 likes
      Last Post bltdavid  
      Started by litamm89, Yesterday, 11:00 AM
      5 responses
      22 views
      1 like
      Last Post rafael_delima86  
      Working...
      X