Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing look-back comparison

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

    Swing look-back comparison

    Hello,

    I am working on a Swing Strategy and my goal is to identify Higher Swing Highs.

    It seems like Condition Builder is limiting look back to bars ago, but that is not what I need. Attached is a picture for reference. I want to create one of the following conditions:
    (SwingHigh.0 > SwingHigh.1) OR (SwingHigh.1 > SwingHigh.2)

    How can I do this? (Compare the current Swing High to the Prior Swing High?)
    Attached Files

    #2
    Hello KINGKODA,

    Thanks for your post.

    The Strategy Builder would limit you to looking at the Swing high/low values on a bar by bar basis. If you want to be able to use the full power of Swing to look back at Swing high/low occurrences you would need to unlock the code and work directly in the script using the overloads found here: https://ninjatrader.com/support/help...-us/?swing.htm

    Otherwise, an approach in the strategy builder may be to compare the current swing value to one stored in a variable that you create. If the current swing is higher then save the current swing into the variable. Depending on your needs you could reset the variable at the start of each session or simply based on a time interval.

    Comment


      #3
      Thanks Paul,

      What would the condition look like if I unlocked the code and started working on it through NinjaScript Editor directly?

      Comment


        #4
        Hello KINGKODA,

        Thanks for your reply.

        Something like:

        double newestHigh = High[Math.Max(0, Swing(5).SwingHighBar(0, 1, 50))];
        double previousHigh = High[Math.Max(0, Swing(5).SwingHighBar(0, 2, 50))]

        if (newestHigh > previousHigh)
        {
        // do something
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        71 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        143 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        76 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        47 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        51 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X