Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with FirstBarOfSession

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

    Problem with FirstBarOfSession

    Hi

    I am fairly new to the whole programming thing, but I am stumbling around the "FirstBarOfSession"

    I read the "Trade Limit" sample strategy and everything made sense.

    In my own strategy, I have a tradecounter and I use the firstbarofsession just like in the trade limit strategy. But when I attach a print statement after my trade counter and I check the output window I see that I get a print message that the session is restarting every minute (as I am using 1 min data)

    Code:
    if (Bars.FirstBarOfSession && FirstTickOfBar );
                
                    tradecounter = 0;
                    condition1 = false;
                    condition2 = false;
                    Print("This is the start of the new session and the time is" + Time[0].ToString());
    and I check the output window I see that I get a print message that the session is restarting every minute (as I am using 1 min data)

    any ideas on what I am doing wrong

    #2
    eurostoxx trader,

    If you want all of those lines to only be evaluated when your if statement is true you need to include them inside { } brackets.

    Code:
    if (Condition)
    {
         // do something;
         // do something else;
    }
    You also should not be ending your if-statement with a semicolon.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      thanks josh

      that is solving a lot of my problem

      regards

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X