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 carnitron, Today, 08:42 PM
          0 responses
          5 views
          0 likes
          Last Post carnitron  
          Started by strategist007, Today, 07:51 PM
          0 responses
          6 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,973 views
          3 likes
          Last Post jhudas88  
          Started by rbeckmann05, Today, 06:48 PM
          0 responses
          8 views
          0 likes
          Last Post rbeckmann05  
          Started by rhyminkevin, Today, 04:58 PM
          4 responses
          58 views
          0 likes
          Last Post dp8282
          by dp8282
           
          Working...
          X