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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      168 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      322 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      246 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      350 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X