Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      ok
      thanks for the help

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      27 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 04-23-2024, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      193 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,235 views
      0 likes
      Last Post xiinteractive  
      Working...
      X