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

Exit and entry in the same bar

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

    Exit and entry in the same bar

    I have a strategy that can exit from de actual position and send a new order in the same bar for a new trader (or close a position and send a entry order in de the same bar). For example, there is a long position openned and it's necesary to close this position and then to send a StopOrder for a new posibility. I know the property "Entries per direction" but it is only for entries and I need to close a position and to send a order for new trade in the same bar. How can I do it?
    Thanks in advance.

    #2
    Originally posted by soyjesus View Post
    I have a strategy that can exit from de actual position and send a new order in the same bar for a new trader (or close a position and send a entry order in de the same bar). For example, there is a long position openned and it's necesary to close this position and then to send a StopOrder for a new posibility. I know the property "Entries per direction" but it is only for entries and I need to close a position and to send a order for new trade in the same bar. How can I do it?
    Thanks in advance.

    There are a few ways.
    1. Use OnBarUpdate() to set flags for what your entry condtion should be, then use OnMarketData() to place the orders, depending on the value of the flags. That means, of course, that you cannot backtest or optimize, unless you do it manually using Market Replay.
    2. Use COBC = false.
    3. Use a multi-timeframe setup, and make orders using the barSeries with finer granularity.
    Just remember that the first 2 methods will be pretty processor-intensive, as they are going to be processing every tick that comes in, instead of just once per bar.
    Last edited by koganam; 04-01-2012, 06:40 PM. Reason: Corrected grammar

    Comment


      #3
      Koganam,

      thank you very much for your help!

      But as you write the first 2 methods are more cpu-intensive, therefore I use the COBC=true.

      With the multidataseries I know I have 5 add(...) I would understand but this is not how I have to do it.

      Do you know how one can do in the script so that the "flat-condition" is in OnExecution but this work "together" with OnBarUpdate-conditions? Maybe to put all conditions to OnExecution? Or how to refer from one to other? "Conditions in onbarupdate and flat in onexecution, then do...."

      Thank you
      Tony

      Originally posted by koganam View Post
      There are a few ways.
      1. Use OnBarUpdate() to set flags for what your entry condtion should be, then use OnMarketData() to place the orders, depending on the value of the flags. That means, of course, that you cannot backtest or optimize, unless you do it manually using Market Replay.
      2. Use COBC = false.
      3. Use a multi-timeframe setup, and make orders using the barSeries with finer granularity.

      Just remember that the first 2 methods will be pretty processor-intensive, as they are going to be processing every tick that comes in, instead of just once per bar.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,606 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      8 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      4 views
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      13 views
      0 likes
      Last Post Javierw.ok  
      Working...
      X