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

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 kaywai, 09-01-2023, 08:44 PM
    5 responses
    601 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by xiinteractive, 04-09-2024, 08:08 AM
    6 responses
    22 views
    0 likes
    Last Post xiinteractive  
    Started by Pattontje, Yesterday, 02:10 PM
    2 responses
    18 views
    0 likes
    Last Post Pattontje  
    Started by flybuzz, 04-21-2024, 04:07 PM
    17 responses
    230 views
    0 likes
    Last Post TradingLoss  
    Started by agclub, 04-21-2024, 08:57 PM
    3 responses
    17 views
    0 likes
    Last Post TradingLoss  
    Working...
    X