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

Best way to list a series of falling Close values

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

    Best way to list a series of falling Close values

    I'm currently trying to come up with a script that has a series of at least 4 falling close values. I've tried using the strategy builder and ninjascript, with mixed results. What is my best option?
    This is the code I've come up with on ninjascript:
    if IsFalling(close(4))) {
    {
    EnterLong()

    #2
    Hello escobar63,

    If you wanted to make this type of condition you would need 4 total conditions as you want to know about 4 falling close values. The IsFalling only checks the current close so this specifically could not be used, you could instead check that the current price is lesser than the previous and so on to accomplish the same task.

    In the builder you can create the first part of your condition by adding a condition:
    Left: Price -> Close -> 0 BarsAgo
    Center: Less than
    Right: Price -> Close -> 1 BarsAgo

    Repeat this 3 more times in the same set adding 1 BarsAgo to each value, or comparing 1 BarsAgo against 2 BarsAgo, and 2 against 3 etc.. for as long as you wanted to look back.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      So, like this?

      if (Close[1] < Close[2] && Close[2] < Close[3] && Close[0] < Close[1])

      Interesting. So isFalling only check the current close. Not a series of closes

      Comment


        #4
        Hello escobar63,

        Yes that is essentially it, this is also mentioned in the documentation for IsFalling:
        Evaluates a falling condition which is true when the current value is less than the value of 1 bar ago.


        By just checking the prices yourself you recreate what the IsFalling is doing but for a larger lookback period.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Gotcha! Thank you so much.
          The next ? I have is how would I be able to make it a default of '4'. Meaning If there was a series of Falling 'Close' values that was greater than 4, how would I be able to capture that series?

          I've included a screenshot to better illustrate what I'm talking about.
          Attached Files

          Comment


            #6
            Hello escobar63,

            If you wanted 4 bars in a row you would need to use 4 conditions that span those 4 bars. That would be the BarsAgo 0 through 4. You formed 3 of the conditions in what you provided earlier, you would just need one more looking back to 3 less than 4 bars ago.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by elirion, Today, 01:36 AM
            0 responses
            2 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            2 views
            0 likes
            Last Post gentlebenthebear  
            Started by samish18, Yesterday, 08:31 AM
            2 responses
            9 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by Mestor, 03-10-2023, 01:50 AM
            16 responses
            389 views
            0 likes
            Last Post z.franck  
            Started by rtwave, 04-12-2024, 09:30 AM
            4 responses
            31 views
            0 likes
            Last Post rtwave
            by rtwave
             
            Working...
            X