Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

easy question

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

    easy question

    Hi,

    I new to programming and can do simple things for now.
    I wanted to add series that have highest and lowest but I have errors from the NT8.

    can you help me understand what I did wrong?

    THANKS!!
    assi



    private int Period, R1, S1 ;
    private double Speriod, PPP;
    private Series<int> Highest1;
    private Series<int> Lowest1;


    if (State == State.SetDefaults)
    {
    Period =30;
    Speriod=0.3;
    }
    else if (State == State.DataLoaded)
    {

    Highest1 = new Series<int>(this, MaximumBarsLookBack.Infinite);
    Lowest1 = new Series<int>(this, MaximumBarsLookBack.Infinite);
    }
    }

    protected override void OnBarUpdate()
    {

    Highest1[0] = HighestBar(High, Period);
    Lowest1[0] = LowestBar(Low, Period);
    PPP = Math.Round(Speriod*Period);


    if (Highest1[0] == Highest1[PX1])
    { R1=Highest1[0];}

    if (Lowest1[0] == Lowest1[PX1])
    { S1=Lowest1[0];}
    }

    #2
    Hello assik,

    Thanks for your post.

    When asking for help with errors it is helpful to post what those errors are, not the CS number but the descriptions.

    Just looking at your code, I would suggest one error may be that you are not doing a current bars check. When the code executes, on the first historical bar it would attempt determine the Highest bar and the lowest bar over the previous bars as defined by "Period", however on the first historical bar there are no previous bars and this would cause an indexing error. Here is a link to the help guide section on performing a current bar check (and then returning if a minimum bars are not yet processed): https://ninjatrader.com/support/help...currentbar.htm I would suggest using Period+1 as the value to check the currentbar against.

    PX1 does not appear to be defined.

    Comment


      #3
      ok
      thanks for the help

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      62 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      134 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      50 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X