Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

CrossBelow

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

    CrossBelow

    I coded up a simple strategy that says short if price crosses below (CrossBelow)
    the low of the day, then enter short.

    So today, at 2:22pm, UPS stock hit its day low at 118.07, but never crossed below, and yet the strategy shorted at 118.07.

    What is wrong here and how can I avoid this?

    #2
    Hello, thanks for the post.

    The condition must have become true when the price hit the low. Can you please share your IF statement that determines your short market entry?

    I look forward to your reply.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      hey, thanks for the response.

      Why does it come true if the price did not cross below? Thats what this code tells it to do. It does not say to short at or below, but only when it crosses below. I could not find any tick in any exchange that crossed below the mentioned price in my previous post.

      Am I wrong?

      If (CrossBelow(Low, CurrentDayOHL1.CurrentLow, 1)

      {
      EnterShort(Convert.ToInt32(100), @"short");
      }

      Comment


        #4
        Hello. Thank you for the reply.

        This condition will never become true when running properly. The low of the day will never cross below the CurrentDayOHL because they will always be the same value. The reason it activated for you was a special case where the strategy's OnBarUpdate was called before the OnBarUpdate for CurrentDayOHL was called, causing the cross above to become true. You must use the Update() method to make sure the OnBarUpdate method is called and updated for any indicators that are used in the strategies OnBarUpdate.

        Again though, this condition will never become true when the code is running properly.

        Please let us know if you have any questions.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Chris, thanks for the reply.

          All code is followed by OnBarUpdate. I don't see what is wrong here. Can you provide me an example of how it should be?

          Comment


            #6
            Hello.

            Thank you for the reply.

            I can provide an example if you reply with what you would like to do.

            I look forward to your reply.
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            59 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            21 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            10 views
            0 likes
            Last Post cre8able  
            Working...
            X