Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unrepeatable, unexplained glitches

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

    Unrepeatable, unexplained glitches

    I have coded an indicator which draws arrows when certain conditions/patterns are met. It works perfectly 99.9% of the time. Occasionally, I will see some random glitch whereby I see the object is drawn under the wrong candle. Upon investigation I cannot find the source of the problem. I have prints on every bar. Reloading the data puts the objects in the correct place and In market replay on the same section of candlesticks, the problem does not repeat and I cannot repeat it.

    But the fact remains that every so often I see this glitch. I've never seen it play out live. The 2-3 times I've seen it is where I've gone to another tab or something than come back and noticed it. I happened yesterday and I took screenshots and grabbed the output.

    Please see screenshot. (Please ignore the green triangle, I omitted the code for that here). In essence, Bar 5405 is the trigger bar and here code runs that should draw a grey unicode triangle under the signal bar, in this case the signal bar is the prior bar, 5404.

    The object is drawn with this code(onpricechange):

    Code:
    if ((Trigger == true)
    && (CurrentBars[0] == (Bar_Long_Trigger))) // Only runs when the current bar is the trigger bar.
    {
    Draw.Text(this, @“Grey_Triangle” + Counter, true, @Unicode_Arrow, BarsAgo_Long_Signal, Low_Long_Signal, -10, MyBrush, myFont, TextAlignment.Center, null, null, 100);
    }
    I get this print on bar 5405 when the trigger condition is met:

    Code:
    Time 17:25:02.1490000
    CurrentBar 5405
    Trigger = true
    Bar_Long_Signal = 5404
    Bar_Long_Trigger = 5405
    BarsAgo_Long_Signal = 1
    1 bar later on bar 5406, I get this print (note the BarsAgo value changed as expected):

    Code:
    Time 17:27:09.0750000
    CurrentBar 5406
    Long_Signal = true
    Bar_Long_Signal = 5404
    Bar_Long_Trigger = 5405
    BarsAgo_Long_Signal = 2
    All makes total sense. Yet for some reason, NT drew this grey triangle under bar 4505. But I don’t know why. The section of the code that places the triangle is the BarsAgo_Long_Signal variable and when it was drawn it had a value of 1, but it's drawn as if the value was 0. The Print output is done directly before the Draw.Text so there is not chance the BarsAgo variable was somehow changed between the print and the drawing of the text.

    The fact I cannot repeat the bug on the same section of candlesticks with market replay and the same code tells me it's possible this is not at all related to my code? and just an unexplainable random rendering glitch? Is this possible?
    Attached Files
    Last edited by several; 10-25-2024, 04:00 AM.

    #2
    Hello several,

    You've mentioned the issue appears when the tab is not in focus, is this correct?

    This may be from the indicator being suspended.

    If you set IsSuspendedWhileInactive to true in State.Configure, and reload the script, can the behavior be reproduced?

    Is that the full output from the output window? (Meaning there is only 1 bar on the chart?)
    Was there another update after this that was not included?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi, This is not the full output I just posted what is relevant here. There's 5k+ bars on the chart.

      One thing I've just realised Currently, this is actually a strategy file. I did not yet convert it to an indicator but I assumed would act the same in relation to drawn objects.

      Comment


        #4
        Hello several,

        We request the full output from the output window saved as a text file (right-click the output window, select Save as) so that we can see everything happening in context.

        The behavior of indicators and strategies are different in regards to the IsSuspendedWhileInactive behavior.

        When the object is drawn, does the Date and time of the object shown in the Drawing Objects window match the output of the prints?

        If you create this as an indicator with IsSuspendedWhileInactive can the behavior be reproduced?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello several,

          When the object is drawn, does the Date and time of the object shown in the Drawing Objects window match the output of the prints?
          Yes. Over the weekend I will try and make the strategy file into an indicator. I have so many print outputs though, the file is huge.

          Comment


            #6
            Hello several,

            I would recommend reducing the Print() calls to a single call for this specific issue you are investigating.

            Alternatively, write the information to a text file with a C# StreamWriter.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            596 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            554 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X