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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        127 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        73 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        115 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        109 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        88 views
        0 likes
        Last Post CarlTrading  
        Working...
        X