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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      41 views
      0 likes
      Last Post CarlTrading  
      Working...
      X