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 Mindset, Today, 06:46 AM
          0 responses
          8 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, Yesterday, 05:21 PM
          0 responses
          12 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          15 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          82 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          47 views
          0 likes
          Last Post PaulMohn  
          Working...
          X