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

time based order entry

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

    time based order entry

    Hello. I'm currently working in Unmanaged framework. Based on various signals, the strategy generates buys or sells, and each order effectively has a stop and profit target associated with it. However, I would like to add a condition such that if after a given amount of time the stop or profit target hasn't been hit, then I close that particular trade. For example,suppose I buy one unit. If after 24 periods the stop or profit target hasn't been reached, then I would like to sell that unit. Does anyone have any examples of this?

    #2
    Hello stewarco,

    Thank you for your note.

    What you could do is save the current bar plus 24 to a variable when you enter a position, then later in the script check if the current bar is greater than that variable, and if so exit the position.

    I’ve put together a snippet of how you could do this in the managed approach, to do this in the unmanaged approach you’d just swap the managed order methods with the unmanaged order methods.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by stewarco View Post
      Hello. I'm currently working in Unmanaged framework. Based on various signals, the strategy generates buys or sells, and each order effectively has a stop and profit target associated with it. However, I would like to add a condition such that if after a given amount of time the stop or profit target hasn't been hit, then I close that particular trade. For example,suppose I buy one unit. If after 24 periods the stop or profit target hasn't been reached, then I would like to sell that unit. Does anyone have any examples of this?
      BarsSinceEntryExecution()?

      ref: https://ninjatrader.com/support/help...yexecution.htm

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by alifarahani, Today, 09:40 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by RookieTrader, Today, 09:37 AM
      4 responses
      17 views
      0 likes
      Last Post RookieTrader  
      Started by PaulMohn, Today, 12:36 PM
      0 responses
      5 views
      0 likes
      Last Post PaulMohn  
      Started by love2code2trade, 04-17-2024, 01:45 PM
      4 responses
      40 views
      0 likes
      Last Post love2code2trade  
      Started by junkone, Today, 11:37 AM
      3 responses
      23 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X