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

Entry or Exit Not executing when conditions are met

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

    Entry or Exit Not executing when conditions are met

    Hello,

    I have a strategy set up with entry and exits built in. Im noticing a trend. 15 minute NQ chart.

    Condition is met at 0733 but im not entered into my trade until 0800. Im assuming that its because im on a 15 min chart and the condition is met in a ongoing bar then it has to wait until a new bar starts until it acutllly executes.

    Same with exiting the same trade. Conditon to exit is met at 1032 but not exited until 1100.

    How can I enter and exit on the close of the same bar were the condition was met? Not 2 bars later.

    First photo is entering trade. As you can see the condition is met (blue circle) but trade not entered until 2 bars later.
    Second photo is exiting trade. Same issue.

    Any help would be appreciated.

    #2
    Hello amigatlin,

    Thanks for your note.

    If you are using Calculate.OnBarClose when enabling your strategy, the strategy will only process logic and execute orders at the close of a bar.

    To have the strategy calculate logic and execute orders intrabar you could use Calculate.OnPriceChange or Calculate.OnEachTick.

    See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

    Ultimately, debugging prints should be added to the script to fully understand how the strategy is processing logic and placing trades.

    To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.

    https://ninjatrader.com/support/foru...121#post791121​​

    Please let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Brandon,

      Thanks for the Reply. I tested out OnPriceChange and OnEachTick in it behaves the same way. I would like just to enter or exit the trade sooner than it is. Is there a way to force the trade on the currnent bar or intrabar?

      Comment


        #4
        Hello, thanks for the follow up. Please also make sure to enable Tick Replay if you are looking at historical trades (by default, historical trades all calculate OnBarClose)

        Chris L.NinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_ChrisL Thanks for the help. I was able to work things out.

          Comment


            #6
            Originally posted by amigatlin View Post
            NinjaTrader_ChrisL Thanks for the help. I was able to work things out.
            How did u fix this? I am having the same issue

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Stanfillirenfro, Today, 07:23 AM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by FitSpressoHonest, Today, 09:14 AM
            0 responses
            0 views
            0 likes
            Last Post FitSpressoHonest  
            Started by Davide999, 05-18-2023, 03:55 AM
            4 responses
            556 views
            1 like
            Last Post kcwasher  
            Started by rexsole, Today, 08:39 AM
            2 responses
            7 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            6 responses
            29 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X