Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Gaby V.NinjaTrader Customer Service

    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.
        Gaby V.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jaybedreamin, Today, 01:08 PM
        0 responses
        2 views
        0 likes
        Last Post jaybedreamin  
        Started by Rheiverson, 07-18-2024, 04:28 PM
        2 responses
        18 views
        0 likes
        Last Post Rheiverson  
        Started by p1kn1t, Today, 11:32 AM
        0 responses
        7 views
        0 likes
        Last Post p1kn1t
        by p1kn1t
         
        Started by Bob-Habanai, Today, 10:27 AM
        0 responses
        10 views
        0 likes
        Last Post Bob-Habanai  
        Started by bortz, 11-06-2023, 08:04 AM
        57 responses
        2,762 views
        0 likes
        Last Post bortz
        by bortz
         
        Working...
        X