Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit On Close with Multi Time Frame Strategy

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

  • NinjaTrader_Joydeep
    replied
    Hello Alex,
    Yes, true. In such scenario you have to custom code it further using the GetNextBeginEnd method.
    http://www.ninjatrader.com/support/h...xtbeginend.htm

    Leave a comment:


  • anachronist
    replied
    Originally posted by NinjaTrader_Joydeep
    You can also use LastBarOfSession to check it
    Good point, but if the strategy uses CalculateOnBarClose=true, by the time LastBarOfSession=true, it's too late.
    -Alex

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello Alex,
    You can also use LastBarOfSession to check it.

    Code:
    BarsArray[0].LastBarOfSession

    Leave a comment:


  • anachronist
    replied
    Originally posted by NinjaTrader_Joydeep View Post
    Hello mithnadril,
    In backtesting ... in a multi series environment the Exit on close is triggered on the primary bar only.
    That would explain the strange behavior I'm seeing. Using only day-session bars, I have 60 minute bars and 1 minute bars. It doesn't seem to matter how I set "Exit on close seconds", my position always exits on the first bar of the next day. I expected the internal logic to use whatever finest granularity is available to the strategy to determine when to exit on close.

    I guess I need to use GetNextBeginEnd to calculate when the strategy is 1 bar from the last bar of the session, and send an exit order for any open position at that time.

    -Alex

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello mithnadril,
    In backtesting orders are submitted at the end of the bar. If you submit the order in the last bar of the session then orders get executed on the next day. However in a multi series environment the Exit on close is triggered on the primary bar only and as such you will have a scenario like this.

    Please further custom code your strategy and please make sure you are not submitting any entry order at the last bar of session.

    Leave a comment:


  • mithnadril
    replied
    oops... the line 82 should read private int OrderBars =1 ... this change was from my own testing, the actual version is attached.

    The screen shows the trades tab ordered using the exit name. The date format ist german, Day . Month . Year, Ths sample uses FDAX data with default session template.

    the screenshot was made with start Jan 1, 2012, Data Series 5 minutes
    Attached Files

    Leave a comment:


  • NinjaTrader_Joydeep
    replied
    Hello mithnadril,
    To assist you further can you post a screenshot depicting the scenario you are facing.

    Also in your sample code you are submitting the orders on the primary bar series only and not in the secondary series.

    I look forward to assisting you further.

    Leave a comment:


  • mithnadril
    started a topic Exit On Close with Multi Time Frame Strategy

    Exit On Close with Multi Time Frame Strategy

    Hello,

    I oberserved strange executions in the strategy analyzer when I use a MTF strategy with unmanaged orders. If the orders are placed in the secondary time frame, the entry order is executed on the bar of the next day and the exit order is executed immediately. The entry and exit times in the Trades tab show an exit time before the entry time.

    Attached is a sample strategy I used to pinpoint the problem, it is just the plain order logic, anything else removed.

    changing line 82 to "private int OrderBars = 0;" shows the correct result.
    Attached Files

Latest Posts

Collapse

Topics Statistics Last Post
Started by ezrollin, Today, 08:51 PM
1 response
21 views
0 likes
Last Post bltdavid  
Started by Rubix, Today, 09:31 PM
0 responses
15 views
0 likes
Last Post Rubix
by Rubix
 
Started by ark321, Today, 05:12 PM
1 response
21 views
0 likes
Last Post NinjaTrader_EricB  
Started by futurenow, Today, 09:08 PM
0 responses
4 views
0 likes
Last Post futurenow  
Started by fafafdenis, Today, 04:56 PM
1 response
5 views
0 likes
Last Post NinjaTrader_EricB  
Working...
X