Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change the color of horizonal line

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

    Change the color of horizonal line

    I want to change the color of the horizontal line based on conditions but the entire line color is just showing the value based on the current bar. For previous bars it is not showing the color according to the EMA values of those bars. .

    protected override void OnBarUpdate()
    {

    if (BarsInProgress != 0)
    return;

    if (CurrentBar < 5)
    return;


    if (ema_3[0] > ema_13[0] && ema_3[0] < ema_50[0])
    {
    MyBrush = Brushes.Yellow;
    }
    if (ema_3[0] > ema_13[0] && ema_3[0] > ema_50[0])
    {
    MyBrush = Brushes.Green;
    }
    if (ema_3[0] < ema_13[0] && ema_3[0] > ema_50[0])
    {
    MyBrush = Brushes.Yellow;
    }
    if (ema_3[0] < ema_13[0] && ema_3[0] < ema_50[0])
    {
    MyBrush = Brushes.Red;
    }
    Draw.HorizontalLine(this, "tag1", 0.1, MyBrush,DashStyleHelper.Solid,15,false);

    }
    }
    }
    Am I missing anything?​
    Last edited by alpurik; 06-22-2024, 08:06 PM.

    #2
    Hello alpurik,

    Thank you for your post.

    When MyBrush gets updated, it will change the color of the entire drawing object with the tag "tag1". You cannot change the color for just a segment/portion of a single Draw.HorizontalLine() drawing object.

    To have a different color for different segments of the object, you would need to create separate Draw.HorizontalLine or Draw.Line() objects. Then, each line could have its own color.

    Please let us know if you have any further questions.

    Comment


      #3
      Thanks Gaby. Can you please let me know what object should I use to generate a horizontal line like the one at the bottom of the image below which changes the color based on the respective bar?
      Attached Files

      Comment


        #4
        Hello,

        The screenshot looks like custom rendering using SharpDX. The Help Guide page for custom rendering is below:



        We also have SampleCustomRender included in the platform which demonstrates custom rendering shapes and text using SharpDX.

        Please let us know if you have any further questions.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        151 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        303 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        243 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        345 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        174 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X