Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Many text drawings causing problems

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

    Many text drawings causing problems

    Hi,

    I have a nice indicator that annotates my charts, writing up setups, targets, stops, reasons for setup disqualifications, rating of setups as trade progresses, potential trade problem and warnings with cancel reasons,, etc...

    It works great for a couple thousand bars, however if I load a lot of bars, like 180 days worth of data on a 610 crude oil tick chart, well.. I get a lot of crazy errors and it crashes. I spent most of today debugging why it was crashing, writing tons of error handling code, and I figured out that if I just stopped writing text drawings the problems went away....


    I like looking through past data and seeing how setups developed and my indicator handled different situations, that is why i would like 180 days of data. If I run on 10 or 20 days, it doesnt seem to be a problem.


    I have a good computer, Dual Xeon, with 24 cores, 64 gigs ram and SSD. So my resources are plenty.. However, I really would like to have these annotations with text drawings. Is there a workaround? I wouldn't be surprised if I had maybe few thousand drawing objects on my charts...

    #2
    Hello KhaosTrader,

    Are you running out of memory?
    When NinjaTrader crashes what are the error messages you get?

    Are are all of the drawing objects necessary? (could you remove objects from earlier in the chart to reduce the load on resources or do need to be able to see these annotations 180 days back?)

    If you are running of memory, drawing thousands of objects is not the way to go. This will cause the computer to run heavy load on the CPU as well as all of the objects have to be loaded in memory, and the OnRender triggered for each separately.

    My suggestion, would be to create an array (like a list, dictionary, or keyvaluepair) that stores all of the annotations. Then custom draw only those that are in view of the chart in OnRender by using logic with the bar number the annotation is saved with (or date).
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      No I am not running out of memory, so that is not the problem. Yes, over the weekend I did create a list array that holds all the tag names of each drawing, and then as new setups come I delete old ones...

      That works to a point, but i get wierd errors sometimes also, like render errors and such. If I use no drawings things are fast and fine -- that is using plots which have multiple colors and shapes to signify meaning. This is not really as nice, but of course, if i run a strategy, I would need to do it that way anyway, as I would be loading tons of data, and the overhead of creating and deleting drawobjects would not be good.

      I think there is a lot of overhead and issues with many draw objects, I am using mostly text and lines. Can you ask development what best practices there are for having several thousand draw objects that are created by instantated objects that are passed the Indicator object?

      again my computer has 64 gigs of ram, and 32 cores (two 16 core XEON processors). There is no way a 18k+ dollar server should be brought to its knees by using drawobjects.

      Thanks in advance.

      Comment


        #4
        Originally posted by KhaosTrader View Post
        Hi,

        No I am not running out of memory, so that is not the problem.

        That works to a point, but i get wierd errors sometimes also, like render errors and such. If I use no drawings things are fast and fine --

        again my computer has 64 gigs of ram, and 32 cores (two 16 core XEON processors). There is no way a 18k+ dollar server should be brought to its knees by using drawobjects.

        Thanks in advance.
        Are you disposing objects?

        Which video card?

        Some sample code that creates the problem would be very helpful here.

        Maybe also post those weird errors in trace.

        Comment


          #5
          Hi sledge,

          Thank you for helping with your questions, I am happy to answer...

          I have been commenting out codes and doing try catch blocks like crazy for the last few hours, I am getting a lot of null exceptions.. If i comment it out in one place it pops up in another... realize, if I keep the number of bars to 1k or so, its no problem, its just if i do tons of bars like 180 days or so...

          As far as video cards, I have two NVIDIA Quadro K2200 cards, each with 3 monitors attached...

          Maybe I should look at driver updating....I will do that next.

          ** note that I am also running windows 10.


          Errors are now like this:

          16-12-04 15:05:42:320|1|32|Order entry hot keys disabled
          2016-12-04 15:05:42:321|1|4|Auto close enabled=False
          2016-12-04 15:06:53:694|1|2|My CQG: Primary connection=Connected, Price feed=Connected
          2016-12-04 15:06:53:845|1|2|Time to auto close position='00:00:00', Enabled=False
          2016-12-04 15:06:53:845|1|2|Using HDS (hds-us-002.ninjatrader.com/31655)
          2016-12-04 15:06:53:850|1|4|Auto connecting 'My FXCM'...
          2016-12-04 15:06:53:857|1|2|My FXCM: Primary connection=Connecting, Price feed=Connecting
          2016-12-04 15:06:54:151|2|16|Cought Error QuantumCalc = System.NullReferenceException: Object reference not set to an instance of an object.
          at NinjaTrader.NinjaScript.Indicators.KhaosIndicators .Khaos_Quantum_Calculator.OnBarUpdate()
          2016-12-04 15:06:54:152|2|16|Cought Error QuantumCalc = System.NullReferenceException: Object reference not set to an instance of an object.
          at NinjaTrader.NinjaScript.Indicators.KhaosIndicators .Khaos_Quantum_Calculator.OnBarUpdate()
          2016-12-04 15:06:54:152|2|16|Cought Error QuantumCalc = System.NullReferenceException: Object reference not set to an instance of an object.
          at NinjaTrader.NinjaScript.Indicators.KhaosIndicators .Khaos_Quantum_Calculator.OnBarUpdate()

          Comment


            #6
            Sledge,

            I forgot to add am setting all my instantiated custom objects to null in the State==Terminated and also in the State == configure events..

            Comment


              #7
              Originally posted by KhaosTrader View Post
              Sledge,

              I forgot to add am setting all my instantiated custom objects to null in the State==Terminated and also in the State == configure events..
              Did you, at any time, open a dialog box while this was running?
              Last edited by koganam; 12-04-2016, 05:01 PM.

              Comment


                #8
                No, i just sat and waited and watched all the errors come to the ninjatrader log window..

                Actually, I have noticed that these errors occur when I start the ninjatrader with a chart loaded with 180 days, I believe if the chart is already loaded there are no errors.... I have to verify this, as when this happens i close it to restart it , so i can clear logs. I just notice that if i have a 20 days chart which loads fine, then put it to 180 days, no errors come that I can remember... so.. i will test more but I believe this error occurs on ninjatrader launching with a chart with lots of bars (180 days).

                Comment


                  #9
                  Ok Did a little bit more of testing...

                  If I launch Ninjatrader where it loads a chart automatically, and that chart has 180 days of data, errors occur. If I launch it with few bars (1000 bars) no errors..

                  If I luanch it with 1000 bar chart, and then load 180 days of data no errors...

                  So it seems that errors occur from the launching sequence or something.

                  Comment


                    #10
                    Hello KhaosTrader,

                    When NinjaTrader crashes what are the error messages you get?

                    Do you have to restart NinjaTrader when it crashes?

                    Are you custom rendering objects in OnRender with SharpDX?
                    Are brushes being reused or recreated on each pass of OnRender?
                    Are you using Bars.GetBar to get bar numbers based on the visible part of the screen?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi,

                      Yes often it crashes...on the startup where I have it load a default workspace with lots of bars... this occurs even if i am deleting many drawobjects.. I am keeping approximately 500 or so, if i cut that down, its better, but still gives me null exceptions.

                      The crash error I get is "ninja trader has stopped working. A problem caused the program to stop working correctly, windows will close the program and notify you if a solution is available." then i get an unhandled microsoft .net framwork exception occurred in ninjatrader.exe [13184].. (if i click debug).. i hit debug and I get an unhandled exception of type "System.Accessviolationexception" occured in SharpDX.Direct2d1.dll

                      System.AccessViolationException was unhandled
                      Message: An unhandled exception of type 'System.AccessViolationException' occurred in
                      SharpDX.Direct2D1.dll
                      Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.



                      In my code, I am not using custom rendering in OnRender with SharpDX..

                      I am not using Bars.GetBar...

                      I use an object that I instantiate once which holds all my custom brushes, I pass that object to my other objects such that they all use that one instantiated object which holds my custom brush definitions... So I keep my custom brushes defined to a minimum.


                      When the fatal crash happens, I have to go to my documents folder, and delete the default workspace so that I can launch ninjatrader without a crash..


                      Below is how I am using draw.text.. maybe i am doing something incorrectly?

                      Code:
                      						string labelTag = "Replace" + Indicator.CurrentBar; 						
                      						Text MyText = Draw.Text(Indicator, labelTag, false, "]Rr[", BarsBack,
                      			                    Indicator.Low[BarsBack], 0, Brushes.Black, Quantum_ColorsAndFonts.Font_StopLabelFont_Big, TextAlignment.Center,
                      			                    Brushes.Black, Brushes.Cyan, 55);	
                      								MyText.IsSeparateZOrder = true;
                      								MyText.ZOrder = 9999999;
                      						Last_Setup_Long.LabelList_TradeDisqualifyInfo.Add(labelTag);						
                      					}
                      Last edited by KhaosTrader; 12-04-2016, 05:55 PM.

                      Comment


                        #12
                        Are you freezing the custom brushes before you use them?

                        Comment


                          #13
                          Yes when the object is instantiated, it assigns and freezes.

                          Comment


                            #14
                            I wonder if the person in this thread is having the same sort of problem I am having

                            Comment


                              #15
                              Hello KhaosTrader,

                              The error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." may indicate that this is an issue with memory.

                              Are you 100% certain that NinjaTrader is not running out of memory?

                              What is the memory usage of NinjaTrader before it crashes?
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              168 responses
                              2,262 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by WeyldFalcon, 12-10-2020, 06:48 PM
                              14 responses
                              1,429 views
                              0 likes
                              Last Post Handclap0241  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              41 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X