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

Finding the beginning of a swing

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

    Finding the beginning of a swing

    Greetings,
    I am developing a strategy using the builtin swing indicator..
    I want to use information regarding the last two swings, the last low and the last high. I want to know the date of the leftmost dot in either case.

    How do I find it?

    Thanks

    Morris

    #2
    Welcome to the forums!

    The Swing indicator supports two methods that return the BarsAgo index of the bar where the swing occurred.

    Try using the SwingHighBar/SwingLowBar methods.
    The return value could then be used to access the Time series, something like this,

    Code:
    int SwingHighBarsAgo = Swing(strength).SwingHighBar(0, [COLOR=#FF0000]1[/COLOR], CurrentBar);
    int SwingLowBarsAgo = Swing(strength).SwingLowBar(0, [COLOR=#FF0000]1[/COLOR], CurrentBar);
    
    if (SwingHighBarsAgo != -1 && SwingLowBarsAgo != -1)
    {
        DateTime SwingHighDateTime = Time[SwingHighBarsAgo];
        DateTime SwingLowDateTime = Time[SwingLowBarsAgo];
        ....
    }
    This should get you what you want.

    EDIT:
    Changed the code to better reflect OP's original question.
    Last edited by bltdavid; 03-22-2020, 03:58 PM.

    Comment


      #3
      Hi morrnel, thanks for your post.

      I agree with bltdavid's answer here. Thanks for sharing bltdavid
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pechtri, 06-22-2023, 02:31 AM
      9 responses
      122 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by frankthearm, 04-18-2024, 09:08 AM
      16 responses
      66 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by habeebft, Today, 01:18 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by benmarkal, Today, 12:52 PM
      2 responses
      15 views
      0 likes
      Last Post benmarkal  
      Started by f.saeidi, Today, 01:38 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X