Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Not all pivots found

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

    Not all pivots found

    Hi,

    I am currently programming an indi that draws horizontal lines at pivot highs and pivot lows.
    To not clutter up, found pivots are rounded to one decimal. So a pivot found at 86.23 will be drawn at 86.20 etc.

    I have defined a pivot as the highest high or lowest low of 7 consecutive bars.

    As you can see in the attached screenshot numerous pivots are found, the thin red and green lines.

    I drew in the thick brown lines myself, as these are also pivots indicated by the circles. But the program is not recognizing them as such.

    The big question I have is why are these pivots not found by the program?

    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    //SR.Set(Close[0]);

    if (CurrentBar < 3) return;

    for (int i = 3; i <= CurrentBar; i++)
    {
    if (IsPivotHigh(i))
    {
    ResistanceList.Add(Math.Round(High[i],Interval));
    }
    if (IsPivotLow(i)) SupportList.Add(Math.Round(Low[i],Interval));
    }

    DrawResistanceLines();
    DrawSupportLines();

    }

    private bool IsPivotHigh(int i)
    {
    if ( High[i] >= High[i - 1]
    && High[i] >= High[i - 2]
    && High[i] >= High[i - 3]
    && High[i] >= High[i + 1]
    && High[i] >= High[i + 2]
    && High[i] >= High[i + 3] )
    {
    return true;
    }

    return false;
    }

    private bool IsPivotLow(int i)
    {
    if ( Low[i] <= Low[i - 1]
    && Low[i] <= Low[i - 2]
    && Low[i] <= Low[i - 3]
    && Low[i] <= Low[i + 1]
    && Low[i] <= Low[i + 2]
    && Low[i] <= Low[i + 3] )
    {
    return true;
    }
    return false;
    }
    Attached Files

    #2
    Hello MarpleTrading,
    Thanks for your note.

    If you try using the Swing indicator that comes with NinjaTrader then are you able to get the values.


    Pivots (peaks and valleys) values can be very obscure depending on how you calculate it. You can also calculate it via the ZigZag indicator. Please refer to this code which calculates the pivots based on the ZigZag indicator.
    JoydeepNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    571 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    331 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    549 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    549 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X