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 cmoran13, Yesterday, 01:02 PM
      0 responses
      25 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      17 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      160 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      95 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      148 views
      2 likes
      Last Post CaptainJack  
      Working...
      X