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 pibrew, Today, 06:37 AM
          0 responses
          4 views
          0 likes
          Last Post pibrew
          by pibrew
           
          Started by rbeckmann05, Yesterday, 06:48 PM
          1 response
          14 views
          0 likes
          Last Post bltdavid  
          Started by llanqui, Today, 03:53 AM
          0 responses
          6 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          11 views
          0 likes
          Last Post burtoninlondon  
          Started by AaronKoRn, Yesterday, 09:49 PM
          0 responses
          16 views
          0 likes
          Last Post AaronKoRn  
          Working...
          X