• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disappeaaring panel plots

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

    Disappeaaring panel plots

    Scenario: I have an indicator that collects statistics that are displayed in a panel plot. I added a function where the statistics will reset at a bar where I draw a diamond of a particular name on the chart. All this works fine.

    Problem: Here is the strange bit. If I roll the chart forward (to the right) where the diamond is off past the left edge and press f5 the panel displays fine. The panel displays correctly. If I scroll the chart back (to the left) to the point where the diamond is displayed on the chart the plot in the entire panel disappears (except my vertical line) even the part that was displayed correctly. I didn't press f5 just rolled the chart using the thumb bar. I have Print statements in my code for debug purposes so my code was not executed again according to the output window after the initial display or the scroll back.

    I would say it is a bug in my code but can't see how if the chart displays correctly and only when I scroll back (left) to the reset point the panel plot disappears. This one has me scratching my head. It is repeatable and does it every time.

    Here is a code snippet:

    private string resetName = "reset";
    Add(new Plot(new Pen(Color.Green, 2), PlotStyle.Bar, "Value"));
    Add(new Line(Color.Indigo, 0, "Zero line"));

    // Only do this for the chart time frame not any added time frames
    if (BarsInProgress == 0)
    {
    // Does a diamond draw object of the requested name exist on the chart and only do this once
    if (DrawObjects[resetName] != null && DrawObjects[resetName].DrawType == DrawType.Diamond && !ResetDone)
    {
    ResetBars = 0;
    // Get the diamond attributes
    IDiamond Diamond = (IDiamond)DrawObjects[resetName];
    // If you found it
    if (Diamond != null)
    {
    Find out the bar number to perform the reset at
    ResetBars = Diamond.BarsAgo;
    // Get the color of the drawn diamond to use for the same color of the vertical line
    DiamondColor = Diamond.Color;
    }

    // If you have a reset bar and that was drawn on the current bar or lower and you have not reset the counters before
    if (ResetBars >= 0 && Times[BarsInProgress][0] >= Time[ResetBars] && !ResetDone)
    {
    // Reset the counters
    Print("1.6 reset Processed " + Time [0] + " " + Times[BarsInProgress][0]);
    // Don't do this code again (only once per f5 or initial display)
    ResetDone = true;
    // Debug code
    Print("1.7 reset done " + Times[BarsInProgress][0] + " ResetBars " + ResetBars + " CurrentBar " + CurrentBar + " --------------------------------");
    // Reset counters code here
    }
    // Draw a vertical on the chart of the same color as the diamond to show a reset was performed here
    DrawVerticalLine(resetName + "_vl", 0, DiamondColor, DashStyle.Solid, 1);
    }

    I set the only plot using:
    Values[0].Set(PlotValue);

    Happy to send screen shorts.

    #2
    CT,

    Thank you for you post.

    I would like to test this on my end, is the sample code provided the reproducible part?

    Additionally, are you overriding the Plot method in the script?

    Are you adding any additional data series?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      CT,

      Thank you for you post.

      I would like to test this on my end, is the sample code provided the reproducible part?

      Additionally, are you overriding the Plot method in the script?

      Are you adding any additional data series?
      Cal

      Yes I do override the plot attributes - PlotColors, width, etc.

      Additional data series, yes, What I am testing with has one other time-frame hence the check for barsarray = 0.

      Comment


        #4
        Cal

        I sent you 3 screen images to the support e-mail with your name on them.

        Cheers

        Comment


          #5
          Thanks CT,

          I will review this and get back to you
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            version

            I am running the 64 bit of 7.0.1000.22

            Comment


              #7
              Cal

              I figured it out!!! As I was making a widget to send you I was cutting out code and a thought occurred to me so I checked it out.

              I was doing a divide by zero. If the diamond was on the chart page being displayed it would kill the panel due to an invalid plot value. However if the diamond was not on the displayed chart page it would load the invalid plot value into the data series and would only barf when it tried to draw the chart data with the bar including the invalid data when it was scrolled to. The scroll back was handled by the Ninja Trader program not my indicator but I loaded the bad data into the data (Values[0].Set(xx)) that made it croak later.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by iq200, 03-11-2018, 07:49 PM
              24 responses
              1,004 views
              0 likes
              Last Post mrlucky1x  
              Started by DavidHP, Today, 08:18 PM
              0 responses
              1 view
              0 likes
              Last Post DavidHP
              by DavidHP
               
              Started by liquid150, Today, 06:20 AM
              1 response
              10 views
              0 likes
              Last Post User1104  
              Started by liquid150, Today, 06:22 AM
              1 response
              17 views
              0 likes
              Last Post lexusfood  
              Started by geo9419, 05-09-2019, 02:39 PM
              9 responses
              320 views
              1 like
              Last Post jgoarm
              by jgoarm
               
              Working...
              X