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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        566 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X