• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      ok
      thanks for the help

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Simon Investimens, Today, 03:26 AM
      0 responses
      3 views
      0 likes
      Last Post Simon Investimens  
      Started by EnveousColnago, Yesterday, 06:58 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by owreivmatot, Today, 01:38 AM
      0 responses
      1 view
      0 likes
      Last Post owreivmatot  
      Started by lindsayf, Today, 01:13 AM
      0 responses
      6 views
      0 likes
      Last Post lindsayf  
      Started by thgamey, Yesterday, 06:46 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Working...
      X