Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating a function that skips inside bars

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

    Creating a function that skips inside bars

    Hey everybody,
    I am currently coding an indicator that plots the swing highs and lows on the chart. The logic for a swing low is that when a low is forming it has to have two higher-lows on both sides of the bar.
    What I am trying to do now is that I want to ignore any inside bars leading up to the swing low or after the forming swing low bar.

    In the picture below you can see the inside bars that I don't want to count after the swing low bar labeled SL.

    I currently have hard code the indexs to check for Swing lows:

    if(lookingForSL)
    {
    if(lookForSL())
    {
    Draw.Text(this, "SL" + CurrentBar, "SL", 2, Low[2] - 0.05);
    lookingForSH = true;
    lookingForSL= false;
    return;
    }
    }​

    private bool lookForSL()
    {
    return Low[1] > Low[2] &&
    Low[1] <= Low[0] &&
    Low[0] > Low[2] &&
    Low[3] > Low[2] &&
    Low[4] > Low[2];
    }

    Low[2] is the swing low on the chart​
    LookingForSL is a flag so that the loop resets and looks for a SH when a SL is found.

    I would be so greatful for any ideas :-)

    Cheers

    //Stefan

    #2
    The easy answer would be to just use the existing NinjaTrader Swing indicator. Test it using different "Strength" settings to see what works best for you.

    Here is a link to the NS part: https://ninjatrader.com/support/help...html?swing.htm

    Comment


      #3
      Hello Stefan,

      Thanks for your post.

      Tasker-182 is correct. The Swing indicator from NinjaTrader could be used and you could test the different 'Strength' settings to find what works best for your goals.

      For information about how to access the Swing indicator values in a custom NinjaScript, see the help guide linked by Tasker-182.

      You could view the Swing indicator's code in a NinjaScript Editor window by going to Control Center > New > NinjaScript Editor, opening the Indicators folder, and double-clicking on the Swing file.

      Let me know if I may assist further.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Thanks for the tips Tasker-182 and NinjaTrader_BrandonH

        Comment

        Latest Posts

        Collapse

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