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 Brevo, Today, 01:45 AM
          0 responses
          6 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by aussugardefender, Today, 01:07 AM
          0 responses
          4 views
          0 likes
          Last Post aussugardefender  
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          242 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          9 responses
          384 views
          1 like
          Last Post Gavini
          by Gavini
           
          Started by oviejo, Today, 12:28 AM
          0 responses
          6 views
          0 likes
          Last Post oviejo
          by oviejo
           
          Working...
          X