Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Crash

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

    Crash

    I'm responsible & obviously I'm not including prior code to the following; just not exactly sure what it needs

    Not readily finding reference library material on the topic.

    protected override void OnBarUpdate()
    {

    //Add your custom indicator logic here.

    double candleHi = Math.Max(High[0], Low[0]);
    double candleLo = Math.Min(High[0], Low[0]);
    double body = Math.Abs(Open[0] - Close[0]);
    Value[0] = ((body / (candleHi - candleLo)) *100);
    double percent = Value[0];

    if
    statements follow...

    all else is confirmed in order, i.e. was chart load tested prior to adding any OnBarUpDate logic.

    The Log reports nothing but on trying to load onto a chart the chart freezes & never recovers [until I shut down and remove the indicator file manually].

    What am I missing here; or perhaps direct me to a library reference please sir?

    Thanx!
    JM

    #2
    I see nothing to cause the issue here. You could simplify though:
    double candleHi = High[0];
    double candleLo = Low[0];
    or just skip that and use:
    Value[0] = ((body / (High[0] - Low[0])) *100);
    unless you need to use candleHi and candleLo variables later.
    Add print statements at spots in your code to see what is happening.
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      There's nothing in this code that would make your chart freeze. There's a possible Divide by zero if the open, close, high, low are the same price which would result in NaN

      a lot of the code is unnecessary:

      Code:
      var range = High[0] - Low[0];
      ver bodySize = Math.Abs(Open[0] - Close[0]);
      
      if(range > 0) {
         var percent = bodySize / range * 100;
         Value[0] = percent;
      }
      The problem is more likely elsewhere in your code.
      Last edited by kevinenergy; 07-13-2023, 11:16 AM.

      Comment


        #4
        Divide by zero could happen, and should be trapped by added code, but shouldn't freeze the chart. Error is likely elsewhere as pointed out.
        eDanny
        NinjaTrader Ecosystem Vendor - Integrity Traders

        Comment


          #5
          Thank you guys, Kevin the possible zero could most certainly come to life on a tick chart. Extra thanx on that heads up!

          JM

          Comment


            #6
            As far as the freeze thing goes I've simply never had that issue. Killed my whole day yesterday...

            Comment


              #7
              Hello JM,

              Thanks for your post.

              As other community members have noted, the code you should wouldn't necessarily cause the platform to freeze.

              You could reference High[0] to get the candle's high price and Low[0] to get the candle's low price as eDanny mentioned.

              See this PriceSeries help guide page for more information about accessing OHLCV values: https://ninjatrader.com/support/help...riceseries.htm

              To determine what code is causing the freezing issue to occur, you could reduce your code and add prints to the script to debug it. Remove or comment out sections of code, recompile, and test to see if the behavior persists. Once you remove/comment out a section of code and the behavior stops then it is likely the section of commented out code that was causing the behavior. You could then narrow in on the offending code by debugging that section of code further.

              Below is a link to a forum post that demonstrates how to use prints to understand behavior.
              https://ninjatrader.com/support/foru...121#post791121
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment


                #8
                Thank you Brandon, Even with the above corrections I still have this freeze going on... Gonna follow through on the isolation sequence as you suggest, meanwhile I'm also running the Microsoft Process monitor...
                Thanx !
                JM

                Comment


                  #9
                  OK I'm on to the problem....

                  I have read this: https://ninjatrader.com/support/help...g_with_brushes .htm

                  commenting out the brush logic as noted here stops the problem and is verified. I have [ assumedly ] correctly followed the parameters as outlined in the above thread.

                  In State.SetDefaults I have

                  UpBrush = Brushes.DarkGreen;
                  DownBrush = Brushes.Maroon;


                  In Properties I have

                  [NinjaScriptProperty]
                  [XmlIgnore]
                  [Display(Name="UpBrush", Description="UpBrush Color", Order=3, GroupName="Parameters")]
                  public Brush UpBrush
                  { get; set; }

                  [Browsable(false)]
                  public string UpBrushSerializable
                  {
                  get { return Serialize.BrushToString(UpBrush); }
                  set { UpBrush = Serialize.StringToBrush(value); }
                  }

                  [NinjaScriptProperty]
                  [XmlIgnore]
                  [Display(Name="DownBrush", Description="DownBrush Color", Order=4, GroupName="Parameters")]
                  public Brush DownBrush
                  { get; set; }

                  [Browsable(false)]
                  public string DownBrushSerializable
                  {
                  get { return Serialize.BrushToString(DownBrush); }
                  set { DownBrush = Serialize.StringToBrush(value); }
                  }
                  ​​

                  Chart Render Issue?

                  Once compiled, If I attempt to open the Indicators window on any chart, the chart will freeze, even with completely empty OnBarUpdate logic. Once this occurs, it is necessary in each case to reinstall NinjaTrader using the repair option.

                  I have a process monitor file if ya'll would like to see it. (The log reports no issues...)

                  Also, if it matters, I'm running a 4 yr old Windows 10 12 core...

                  Thanx

                  JM
                  Last edited by johnMoss; 07-14-2023, 09:16 AM.

                  Comment


                    #10
                    I think I inadvertently hit the wrong reply button & killed the unanswered highlight of this thread... So just checkin'...

                    Comment


                      #11
                      Hello johnMoss,

                      The code you have suggested looks fine to me and I would not expect any issue.

                      I've tested that code and I am not able to reproduce. Below is a link to a video of the test.


                      I recommend you exclude all open source indicators from compilation. Then restart NinjaTrader.


                      Then create a new test indicator with only the code you have posted added. Let me know if the behavior is not the same as in the video.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thank you Chelsea,
                        and especially for the trouble you went to here... I will try that and record it as well. If your suggestion is effective, I will go back in and reload the indicators, sections at a time, to isolate the offender & report back.

                        Happy Friday
                        JM

                        Comment


                          #13
                          OK.... Better die a fool than a coward... Rather than quietly walk away from this thread in shame here's the confessional; and my apologies for wasting people's time, but I'll concede logic rewrites were very helpful... Look what I did, and also didn't include above, maybe see anything wrong in this picture??

                          Defaults:

                          soundAlert = false;

                          Props:

                          [Display(Name = "Sound Alert", Description = "Sound alerts activated", Order = 2, GroupName = "Parameters")]
                          get { return soundAlert; }
                          set { soundAlert = value; }


                          As I saw this I'm like, Really?? Lord...

                          Thanx Ya'll

                          John
                          Last edited by johnMoss; 07-15-2023, 03:51 PM.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          599 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          344 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
                          558 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          557 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X