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 junkone, Today, 11:37 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by frankthearm, Yesterday, 09:08 AM
      11 responses
      42 views
      0 likes
      Last Post frankthearm  
      Started by quantismo, 04-17-2024, 05:13 PM
      5 responses
      35 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by proptrade13, Today, 11:06 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by love2code2trade, 04-17-2024, 01:45 PM
      4 responses
      35 views
      0 likes
      Last Post love2code2trade  
      Working...
      X