Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Lines are listed in Drawing Objects list but not showing on chart

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

    Lines are listed in Drawing Objects list but not showing on chart

    I making an indicator that draws lines at swing highs. If it finds equal highs, the lines are drawn in a different color to show that there is more than 1 high at that point

    I find a swing high
    I check to see if it is the first swing high at that price
    If it is, I look back to see if there is an equal high that isn't a swing high. If I find one, I draw a line from the equal high to the swing high. Then start a new line at that price that is a different color

    if it's not the first swing high at that level, I draw a line from the last swing high to the current one, then start a new line at that price that is a different color

    In the top image you can see that there are 2 lines that are in the Drawing Object list that didn't draw on the chart. But when I click on a line to bring up the Drawing Object list, then close the box, the lines show up. That's the bottom image

    My code is below
    What am I doing wrong?


    Click image for larger version

Name:	image.png
Views:	125
Size:	193.5 KB
ID:	1296976

    Click image for larger version

Name:	image.png
Views:	66
Size:	176.1 KB
ID:	1296977

    PHP Code:
            protected override void OnBarUpdate()
            {
                if (CurrentBar < 2)    return;        
                
                if(CurrentBar == 3)
                    startTime = DateTime.Now.Ticks;
                                        
                if ((High[1] >= High[0]) && (High[1] >= High[2]))                        //    FOUND SWING HIGH
                {
                    AddSwingHigh();
                }
    
                if (swingHighs.Count > 0)                                                //    GO THRU LIST AND DRAW ANY OPEN SWING HIGH LINES
                    for (x = swingHighs.Count - 1; x >= 0 ; x--)                        
                    {
                                            
                        DrawSwingHighs(
                            swingHighs[x].swingHLValue,
                            swingHighs[x].swingHLStartTime,
                            Time[0],
                            swingHighs[x].eqhlCount);
    
                        if(High[0] > swingHighs[x].swingHLValue)                        //    CHECK FOR END OF SWING HIGH
                        {                                    
                            swingHighs.RemoveAt(x);                                         // REMOVE SWING HIGH FROM LIST
                        }    
                    }
    
                if (Count - 2 == CurrentBar)
                {
                    DrawTextBox1();
                    Print("IFVGComboTest  " + (DateTime.Now.Ticks - startTime)/10000);    //    PRINT INDICATOR LOAD TIME
                }
            }
    //==================================================================================================    
    //==================================================================================================
            
    
    //==================================================================================================    
            private void AddSwingHigh()
            {
                    if (swingHighs.Count(a => a.swingHLValue == High[1]) == 0)        //    FOUND NEW SWING HIGH
                    {
    
                        CheckBackForEqualHigh();                                    //    CHECK BACK TO SEE IF PRIOR EQUAL HIGHS
    
                        swingHL v = new swingHL();
                        v.eqhlCount = eqhlCount + 1;    
                        v.swingHLStartTime = Time[1];
                        v.swingHLEndTime = Time[0];
                        v.swingHLValue = High[1];
                        swingHighs.Add(v);                                            //    ADD NEW SWING HIGH TO LIST
    
                        swingHighs.Sort((y, x) => x.swingHLStartTime.CompareTo(y.swingHLStartTime));            
                    }
                    else                                                            //    FOUND ADDITIONAL SWING HIGH
                    {
                        int x = swingHighs.FindIndex(a => a.swingHLValue == High[1]);    
                                            
                        DrawSwingHighs(swingHighs[x].swingHLValue,                    //    DRAW SWING HIGH FROM PRIOR SWING HIGH TO CURRENT SWING HIGH
                            swingHighs[x].swingHLStartTime,
                            Time[1],
                            swingHighs[x].eqhlCount);            
    
                        swingHighs[x].swingHLStartTime = Time[1];
                        swingHighs[x].swingHLEndTime = Time[1];
                        swingHighs[x].eqhlCount = swingHighs[x].eqhlCount + 1;    
                        
                    }
            }
                    
            
    //==================================================================================================    
            private void CheckBackForEqualHigh()
            {
                eqhlCount = 0;
                for ( int i = 2 ; i <= CurrentBar ; i++)
                {    
                    if(High[i] > High[1])                                            //    STOP CHECKING BACK
                    {
                        break;
                    }
                    else if(High[i] == High[1])                                        //    FOUND PRIOR EQUAL HIGH
                    {
                        DrawSwingHighs(                                                //    DRAW SWING HIGH LINE FROM PRIOR EQUAL HIGH TO CURRENT SWING HIGH
                            High[i],
                            Time[i],
                            Time[1],
                            1);
                        eqhlCount = 1;
                    }
                }
            }
    
    //==================================================================================================    
            private void DrawSwingHighs(double price, DateTime start, DateTime end, int strength)
            {
                Draw.Line(this, "swingHigh-" + start, false,
                start,
                price,
                end,
                price,
                strength == 1 ?  Brushes.Green : strength == 2 ?  Brushes.Lime : Brushes.Cyan,
                strength == 1 ? DashStyleHelper.Dash : DashStyleHelper.Solid,
                strength == 1 ? 1 : swingHLLineThickness,
                true);
            }
    &#8203; 
    

    #2
    Hello cre8able,

    Thank you for your post.

    It's possible that if no data was coming in, the chart may not have refreshed until you clicked on the line.

    Could you please create a simple reduced test script without the excess logic just draws a line every 10 bars (or something similar) and see if this reproduces the issue?

    I look forward to assisting further.

    Comment


      #3
      thanks Gaby
      I found a different way to program it and it works fine now

      Comment

      Latest Posts

      Collapse

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