Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with "half trading" day

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

    Problems with "half trading" day

    Hello

    An issue occurred with my trading strategy. It seems that the trading strategy

    has a problem with “half trading” days (e.g. 24th of December). That means that my trading strategy is programmed in that way that after every trading day all variables will be reset in order to be clear for the next trading day. I even have implemented a
    query to avoid possible confusions regarding variable settings of the previous day and the next trading day as follows:


    protected override void OnBarUpdate()
    { …

    if (
    Bars.FirstBarOfSession && // Display only once a session
    FirstTickOfBar && // at first Tick of a bar
    CurrentBar > 0 && // My preference to start after the first bar of the session
    Time[0].DayOfWeek != DayOfWeek.Saturday && // No weekends
    Time[0].DayOfWeek != DayOfWeek.Sunday // No weekends
    )
    {
    //RENEWABLE VARIABLE AREA - RESET VARIABLES
    ResetVariables();
    }
    if (Time[0].DayOfWeek != Time[1].DayOfWeek)
    {
    ResetVariables();
    //RENEWABLE VARIABLE AREA - RESET VARIABLES
    }

    }
    But even with this queries the trading strategy on “half trading” days trades the next day with the same variable settings like the
    day before. It seems like the strading strategy does not realize that a new trading day or better a new trading session started and therefore
    the strategy trades with “old” variable settings of the days before.

    Do anybody has an idea how to prevent this issue I described above?

    Many thanks,


    bye


    Rob

    #2
    There isn't anything that's standing out (I could be missing something) with the code shown here as something wrong. The individual case will likely need to be debugged.

    I did want to point out
    CurrentBar > 0 && // My preference to start after the first bar of the session

    This statement is for all bars on the chart, not just the current session.
    For bars since the session begin: http://www.ninjatrader.com/support/h...ncesession.htm

    For tips on debugging: http://www.ninjatrader.com/support/f...ead.php?t=3418

    You'll want to use print statements and drawing objects to determine why the values were not reset on the 24th.

    What is your Calculate on bar close set to?
    LanceNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    639 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    572 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X