• 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

a question on the example of an indicator - highest high lowest low time range

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

    a question on the example of an indicator - highest high lowest low time range

    Hello everyone, a question on the example of an indicator Calculating the highest high or lowest low for a specified time range

    how do i get PLOT of past high and low?

    Example:

    Draw.Square(this, "highestHigh" + CurrentBar, true, 0, highestHigh, Brushes.Lime);

    This Not working

    #2
    Hi memonolog, thanks for your question.

    The HighestHigh and LowestLow objects are of type Series<double> so they must be indexed to get a particular value. HighestHigh[0] would grab the latest plot value, HighestHigh[1] would get the second to last plot value. Try printing the values of HighestHigh[0] to see, e.g. Print(HighestHigh[0]); Print(HighestHigh[1]); , etc...

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi memonolog, thanks for your question.

      The HighestHigh and LowestLow objects are of type Series<double> so they must be indexed to get a particular value. HighestHigh[0] would grab the latest plot value, HighestHigh[1] would get the second to last plot value. Try printing the values of HighestHigh[0] to see, e.g. Print(HighestHigh[0]); Print(HighestHigh[1]); , etc...

      Please let me know if I can assist any further.
      I don’t need one specific value, I need to draw a line (Plot) along all the past of the high and low, so I need all the past values.
      In general, the task is to get the maximum and minimum prices to draw a line along them.
      What other options are there in time to get the maximum and minimum milking my task?

      Example:

      Draw.Square(this, "highestHigh" + AllpastValues, true, 0, highestHigh, Brushes.Lime);
      Last edited by memonolog; 05-20-2020, 08:34 AM.

      Comment


        #4
        Hi, thanks for your reply.

        It will depend on how many previous values you have. Something like this in OnBarUpdate will iterate through a number of bars:

        Code:
                int period = 20;
                protected override void OnBarUpdate()
                {
                    if(CurrentBars[0] < period) return;
        
                    double sum = 0;
        
                    for(int i = 0; i < period; i++)
                    {
                        sum += High[i] - Low[i] / 2;
                    }
        
                    Print(sum);
                }
        A lot of our tools do this for you and the coder just need to input a period to evaluate over. We have the MAX and MIX methods for finding max and min values of a series. e.g.

        MAX(ISeries<double> input, int period)[int barsAgo]

        There is "Highest High" example on the documentation for MAX:
        https://ninjatrader.com/support/help...aximum_max.htm

        Please let me know if I can assist any further.

        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hi, thanks for your reply.

          It will depend on how many previous values you have. Something like this in OnBarUpdate will iterate through a number of bars:

          Code:
          int period = 20;
          protected override void OnBarUpdate()
          {
          if(CurrentBars[0] < period) return;
          
          double sum = 0;
          
          for(int i = 0; i < period; i++)
          {
          sum += High[i] - Low[i] / 2;
          }
          
          Print(sum);
          }
          A lot of our tools do this for you and the coder just need to input a period to evaluate over. We have the MAX and MIX methods for finding max and min values of a series. e.g.

          MAX(ISeries<double> input, int period)[int barsAgo]

          There is "Highest High" example on the documentation for MAX:
          https://ninjatrader.com/support/help...aximum_max.htm

          Please let me know if I can assist any further.
          Sorry, but I don’t have enough knowledge yet, can you specifically help determine past highs in my code?

          double highestHigh = MAX(High, endBarsAgo - startBarsAgo) [CurrentBar - endBarsAgo];

          // Now that we have the start and end bars ago values for the specified time range we can calculate the lowest low for this range
          double lowestLow = MIN(Low, endBarsAgo - startBarsAgo)[CurrentBar - endBarsAgo];

          // Set the plot values
          HighestHigh[0] = highestHigh;
          LowestLow[0] = lowestLow;


          // High Plot

          Draw.Dot(this, "1" + CurrentBar, false, 0, highestHigh, Brushes.Blue);

          Comment


            #6
            Hi memonolog,

            the MIN/MAX inidicators are useful if the number of bars is constant and you'd like the MIN/MAX to be recalculated on each bar of the chart.

            for a static range where the calculation is only performed once, like with a drawing tool, this would be suitable

            Code:
            double highestHigh = double.MinValue;
            double lowestLow = double.MaxValue;
            
            int endBarsAgo = CurrentBar - StartBar;
            for(int i = 0; i <= endBarsAgo; i++) {
                if(High[i] > highestHigh) {
                    highestHigh = High[i];
                }
            
                if(Low[i] < lowestLow) {
                    lowestLow = Low[i];
                }
            }
            
            if(highestHigh != double.MinValue) {
                //your code here
            }
            For an indicator that calculates highs/lows each day for a specific time period the code would need some adaptation for efficiency.
            Last edited by MojoJojo; 05-23-2020, 05:11 AM.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by atman, Today, 12:37 AM
            0 responses
            1 view
            0 likes
            Last Post atman
            by atman
             
            Started by random9570, Yesterday, 09:01 PM
            1 response
            13 views
            0 likes
            Last Post Fulcanelli  
            Started by natngk, Yesterday, 08:28 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Marco  
            Started by Borsz, 05-27-2020, 10:37 AM
            2 responses
            24 views
            0 likes
            Last Post aligator  
            Started by Tagliareni, Yesterday, 08:10 PM
            0 responses
            8 views
            0 likes
            Last Post Tagliareni  
            Working...
            X