Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnbarBarUpdate() boolean resetting to true

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

    OnbarBarUpdate() boolean resetting to true

    Hi,

    I am new to coding.
    I have a problem with boolean resetting to true, here goes-

    #region Variables

    private bool t1 = true;
    private bool t2 = false;
    private bool t3 = false;
    private bool t4 = false;
    .
    .
    .
    .
    #endregion

    protected override void Initialize()
    {
    CalculateOnBarClose = true;

    ExitOnCloseSeconds = 30;


    SMA(Close, Fast).Plots[0].Pen.Color = Color.Orange;
    SMA(Close, Slow).Plots[0].Pen.Color = Color.Green;

    Add(SMA(Close, Fast));
    Add(SMA(Close, Slow));
    }

    protected override void OnBarUpdate()
    {
    Condition Sets
    .
    .
    .
    .
    .

    if(t1 == true)
    t1 = false;
    t2 = true;
    {
    if (t1 == true)
    if (t2 == false)
    if (t3 == false)
    if (t4 == false)
    if(t2 == true)
    t2 = false;
    } t3 = true;
    {
    if (t1 == true)
    if (t2 == false)
    if (t3 == false)
    if (t4 == false)

    if(t3 == true)
    t3 = false;
    t4 = true;
    }


    On next bar update all t1 through t4 are resetting to true, even though these been set in coding.
    I searched the forum but found no solution.
    Thanks.

    #2
    Hello,

    Thank you for your forum post.

    Just wanted to let you know that we received your note and that someone will respond in the morning.

    Thank You for your patience.
    BrettNinjaTrader Product Management

    Comment


      #3
      Welcome to our forums, please simplify and debug your NS code with Prints to check which code portion creates the issues for you -

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      51 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      275 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X