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 michi08, 10-05-2018, 09:31 AM
      5 responses
      741 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by The_Sec, Today, 02:29 PM
      0 responses
      2 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by tsantospinto, 04-12-2024, 07:04 PM
      4 responses
      62 views
      0 likes
      Last Post aligator  
      Started by sightcareclickhere, Today, 01:55 PM
      0 responses
      1 view
      0 likes
      Last Post sightcareclickhere  
      Started by Mindset, 05-06-2023, 09:03 PM
      9 responses
      259 views
      0 likes
      Last Post ender_wiggum  
      Working...
      X