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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      152 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      87 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      131 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      127 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      106 views
      0 likes
      Last Post CarlTrading  
      Working...
      X