Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

>= working but not > only

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

    >= working but not > only

    My strategy is in NT 8.

    In OnBarUpdate() I have the following vars:

    int lowestBarsAgo = LowestBar(Low, Bars.BarsSinceNewTradingDay)
    double lowestPrice = Low[lowestBarsAgo]

    then in my trade logic


    if (Close[0] >= Open[0] && Low[0] <= lowestPrice)
    <enter trade logc>

    so here's the issue, when I have the above Low[0] <= lowestPrice it works as expected but when I change it to Low[0] < lowestPrice it doesn't run as expected. Any thoughts or suggestions as to why less than or equal works but not less than only?

    #2
    Hello algofy,

    This appears to be a logic related question, however, I think what may be going on is that you are finding the lowest low since the open. Then you are trying to see if the current low is lower than the lowest low. If the current bar's low is the lowest low already, it won't be lower than itself. But it could be equal to itself.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ahh that makes sense, looking at my code do you know of an easy way to exclude the [0] bar in that lowest bar look back?

      Comment


        #4
        Hello algofy,

        If you just want to know if the current low is lower than the lowest low not including the current bar, you can use the MIN() method.

        For example:

        if (Low[0] < MIN(Low, Bars.BarsSinceNewTradingDay)[1])

        MIN(ISeries<double> input, int period)[int barsAgo]
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you Chelsea!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          673 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          578 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X