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

Bars since entry??

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

    Bars since entry??

    I have a strategy that uses an exit if unrealized profit hits 20 ticks in 3 or less bars since entry. For some reason it's not respecting the 3 bar rule and sometimes exits at 5,6 or even 10 bars. I'm really stumped. FYI, I have the signal name blank so I don't have to setup an exit for multiple entry signals I have set up.

    #2
    Hello Tburg10,

    Thank you for your post.

    What is your current logic to determine if it's 3 bars or less since the entry? You could add print statements to understand the values used in your conditions and determine why the strategy sometimes exits at 5, 6, 10, etc. bars. For more info on adding prints to debug your script:


    If you provide a snippet of your script that shows the exit logic, I would be glad to provide you with an example Print() statement relevant to your logic.

    Please let me know if I may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. I'll have to figure out how to add prints. I'm using the builder not custom code. But here are a couple of screenshot showing the code.

      Comment


        #4
        Here they are
        Attached Files

        Comment


          #5
          Hello Tburg10,

          Thank you for those screenshots.

          Although you are using the Strategy Builder, you can still add prints for debugging. The link I previously shared also includes this video about adding prints in the Strategy Builder:


          That said, in this case I also suggest enabling TraceOrders from the Default Properties screen of the builder to get a better idea of which orders are being submitted and if any orders are being ignored and why. For more information on TraceOrders and how it works to send info to the NinjaScript Output window:Based on your screenshot, the exit should work when the BarsSinceEntryExecution is less than or equal to 3. That said, if you have multiple different types of orders in place, such as an exit order in addition to a stop loss/profit target, or an entry order in the opposite direction at the same time as an exit order, this could result in the exit being ignored. This is due to the "Internal Order Handling Rules that Reduce Unwanted Positions" that are described on the following help guide page:Trace Orders will tell you if an order is being ignored due to these rules, and that could help you to narrow down why the exit might be happening even when it is more than 3 bars past the entry execution.

          Please let me know if I may be of further assistance.
          Emily C.NinjaTrader Customer Service

          Comment


            #6
            Thank you so much. That info will help greatly!

            Comment


              #7
              I see this rule for ignored rules... A position is open and an order submitted by a set method (SetStopLoss() for example) is active.

              I do have an emergency stop loss set so if a rule fails I can never lose more than 22 ticks. But I have several exit rules programmed and most of the time they seem to be respected.

              I'll definitely get the debugging and trace orders setup and hopefully that will help me solve this mystery.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by businessman1929, 04-29-2024, 01:28 PM
              2 responses
              21 views
              0 likes
              Last Post businessman1929  
              Started by bltdavid, 03-27-2023, 05:32 AM
              18 responses
              346 views
              0 likes
              Last Post ETFVoyageur  
              Started by NM_eFe, Today, 05:15 PM
              0 responses
              4 views
              0 likes
              Last Post NM_eFe
              by NM_eFe
               
              Started by vitaly_p, Today, 05:09 PM
              0 responses
              4 views
              0 likes
              Last Post vitaly_p  
              Started by cmtjoancolmenero, Today, 05:05 PM
              0 responses
              2 views
              0 likes
              Last Post cmtjoancolmenero  
              Working...
              X