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

InvalidOperationException from Draw.TriangleUp

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

    InvalidOperationException from Draw.TriangleUp

    I have a simple indicator that analyzes a renko bar and then draw up or down triangles at appropriate times. The renko bar is pretty simple and does not use the 'remove bar' option.

    I receive an exception in the following scenario:
    - I am connnected to NinjaTrader Continuum.
    - I open an existing workspace that has 4 windows open with a total of 6 charts.
    - There are two charts that have my indicator running.
    - During the initial load of the chart the exception below is received once.
    (My indicator catches this exception in the OnBarUpdate method when calling
    Draw.TriangleUp (or Down).

    The line of code that bombs:
    HTML Code:
    if (CurrentBar == 0)
        return;
    ....
    Draw.TriangleDown(this, CurrentBar.ToString(), true, 0, High[0], Brushes.Red);
    The exception:
    HTML Code:
    System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.Max(IEnumerable`1 source)
       at NinjaTrader.Gui.Chart.ChartControl.get_PanelWidthPixels()
       at NinjaTrader.Gui.Chart.ChartControl.get_CanvasRight()
       at NinjaTrader.Gui.Chart.ChartControl.GetXBySlotIndex(Double slotIndex)
       at NinjaTrader.Gui.Chart.ChartControl.GetXByBarIndex(ChartBars chartBars, Int32 barIndex)
       at NinjaTrader.NinjaScript.DrawingTools.DrawingTool.CreateChartAnchor(NinjaScriptBase ownerNinjaScript, Int32 barsAgo, DateTime time, Double y)
       at NinjaTrader.NinjaScript.DrawingTools.Draw.ChartMarkerCore[T](NinjaScriptBase owner, String tag, Boolean isAutoScale, Int32 barsAgo, DateTime time, Double yVal, Brush brush, Boolean isGlobal, String templateName)
       at NinjaTrader.NinjaScript.DrawingTools.Draw.TriangleUp(NinjaScriptBase owner, String tag, Boolean isAutoScale, Int32 barsAgo, Double y, Brush brush)
       at NinjaTrader.NinjaScript.Indicators.GRenkoTail.OnBarUpdate()
    Any ideas?

    Thanks,
    Gary

    #2
    Hello GaryAlbers,

    Thank you for your post.

    I am not seeing that exception using your instructions and code provided. Can you provide detail on a chart you use this indicator on?
    For example:
    Instrument: ES 12-16
    Period and Value: 4 Renko

    In addition, could you provide the full code for this indicator? If so, you can send it over to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H' in the subject line and a reference to this thread in the body of the email.

    Comment


      #3
      I believe the error only occurs when an established chart is saved in a workspace and then the next day, when I open the workspace, Ninja is loading the data to fill chart.
      I have Ninja set to record the data and when I reopen the workspace the next day,
      it seems that filling the gap between when I last had this chart open and current price is the problem.
      That is the only time I have received this particular exception.

      I use ninzaRenko on NQ 12-16 . free at: http://ninza.co/product/ninzarenko
      setting of 6, 2.

      See email for indicator code.

      Gary

      Comment


        #4
        I wonder if this crash occurance comes from the SAME PROBLEM that I am having in my code... My problem is discussed here in my thread...

        Comment


          #5
          KhaosTrader,

          I don't think we are experiencing the same problem but to be sure, can you please post the actual exception output you get in your output window? I looked through your post and did not see it.

          Thanks,
          Gary

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CortexZenUSA, Today, 12:53 AM
          0 responses
          1 view
          0 likes
          Last Post CortexZenUSA  
          Started by CortexZenUSA, Today, 12:46 AM
          0 responses
          1 view
          0 likes
          Last Post CortexZenUSA  
          Started by usazencortex, Today, 12:43 AM
          0 responses
          5 views
          0 likes
          Last Post usazencortex  
          Started by sidlercom80, 10-28-2023, 08:49 AM
          168 responses
          2,266 views
          0 likes
          Last Post sidlercom80  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X