Announcement

Collapse
No announcement yet.

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.

    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.

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            47 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            23 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            33 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            50 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Working...
            X