• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to modify order limits for next trading day?

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

    How to modify order limits for next trading day?

    Hi,

    I would like to do following szenario in a 1-minute chart: I set a stop loss oder for an open position at 100. The quote does not fall below the stop. On the next day I want to set it to 99. I use "Bars.IsLastBarOfSession" which works great for backtesting. But in realtime usage (TWS) I run into the problem that the modification is made in the first seconds of the new day. This leads to execution based on the old stop (from previous day at 100).

    My code is quite simple:

    if ( Bars.IsLastBarOfSession && Position.MarketPosition == MarketPosition.Short ) {
    SetStopLoss( "SL", CalculationMode.Percent, NextDaysSL, false );
    SetProfitTarget( "PT", CalculationMode.Percent, NextDaysPT );
    }

    Any ideas or suggestions?

    Martin

    #2
    Hello Martin,

    Your inquiry is that you want to trigger an action at the end of a day before the session closes instead of when the new bar opens at the start of the next session, is this correct?

    Is the script running with Calculate set to 'On bar close'?

    If so, the actions are triggering after the bar has closed and the new bar opens (at the start of new session).

    If you want to trigger actions before the bar closes, you will need Calculate set to 'On each tick', or you would need to add 1 tick intra-bar granularity, and trigger the action before the bar closes.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,

      yes, the script runs "On bar close".

      What I basically want is that when the trading day is over (and no more tick is going to come) I want to modify the order. So that from the very first tick of the next day the new limits apply.

      I totally get your point with "On each tick" but how do I know when the day is over?

      Is there a way to set a timer? Somthing like "on Midnight modify orders"...

      Martin

      Comment


        #4
        Hello Martin,

        OnBarUpdate is driven by data. It triggers when the bar closes when Calculate is 'On bar close', or when the price changes after a tick is received with 'On price change', or every time a tick is received with 'On each tick'.

        If the session is closed, there will no data to cause OnBarUpdate to trigger.

        If you want to trigger actions after the session is closed, you would need to make a timer and have this trigger a method outside of OnBarUpdate.

        Most likely any order submissions or modifications will be rejected by the brokerage if the session is closed.

        Below is a public link to an example of a timer.
        https://ninjatrader.com/support/foru...445#post496445
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by SAITON, Today, 09:03 PM
        0 responses
        1 view
        0 likes
        Last Post SAITON
        by SAITON
         
        Started by suprsnipes, Today, 08:26 PM
        0 responses
        5 views
        0 likes
        Last Post suprsnipes  
        Started by RobertoPaez, Today, 06:47 PM
        0 responses
        7 views
        0 likes
        Last Post RobertoPaez  
        Started by catinabag, Today, 06:45 PM
        0 responses
        4 views
        0 likes
        Last Post catinabag  
        Started by darkgreen, Today, 03:35 PM
        0 responses
        9 views
        0 likes
        Last Post darkgreen  
        Working...
        X