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

close position at the close of the candle

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

    close position at the close of the candle

    Hello, with the strategy builder I am trying to make a system, which opens the position when the system is indicated, but I want it to close the position when the candle closes, the system only operates on one candle.

    I would appreciate your help. Thanks.

    #2
    Hello corman,

    Thanks for your post.

    You would need to run your strategy with Calculate.OnEachTick so that your code is executed on every tick (In real-time or Playback with market replay data). This would allow your coding to be as responsive as possible and allow your entry to occur intrabar. To then exit at the end of the bar requires knowing when the end of the bar occurs in the strategy builder. The best approach then would be to use a condition to check if the Misc current bar is the same as the bar where the entry occurred and if it is not then you have a new bar and you can then call the exit method. You can create an int type variable that you can save the current bar number in when you place the entry order.

    One thing to keep in mind is that the order processing occurs asynchronously and does take physical time to occur. Just because you call exit market does not meet at that tick you are out of the market Many ticks could occur before your order has been transmitted, received, placed, filled, and finally acknowledged back to your strategy. So while you can tell the strategy exactly when to execute, the order fill (time) may not be as exacting.
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    43 views
    0 likes
    Last Post jeronymite  
    Started by frankthearm, Today, 09:08 AM
    4 responses
    9 views
    0 likes
    Last Post frankthearm  
    Started by yertle, Today, 08:38 AM
    5 responses
    15 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by adeelshahzad, Today, 03:54 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by bill2023, Yesterday, 08:51 AM
    6 responses
    27 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X