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

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.
    Paul H.NinjaTrader Customer Service

    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
        }
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by reynoldsn, Today, 12:42 PM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by f.saeidi, Today, 12:35 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by snoussi, Today, 12:26 PM
        2 responses
        7 views
        0 likes
        Last Post snoussi
        by snoussi
         
        Started by Italohispanico, Today, 12:39 PM
        0 responses
        3 views
        0 likes
        Last Post Italohispanico  
        Started by SnailHorn, 05-02-2024, 10:49 PM
        3 responses
        30 views
        0 likes
        Last Post SnailHorn  
        Working...
        X