Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

background color

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

    background color

    hi,

    i coded myIndicator.

    there are the plot and four DrawHorizontalLines. everytime the plot enter one of the four zones there should be a different backgroundcolor within the indicator extra panel.

    when i code this with a value then it works exact:

    code:
    double value5 = myIndicator(Period)[0];
    ( if (value5 >= 3.5)
    {
    BackColor = Color.White;
    }

    else if(value5 >= 1.56)
    {
    BackColor = Color.Blue;
    }
    else if(value5 >= 1.29)
    {
    BackColor = Color.Green;
    }

    else if(value5 < 1.29)
    {
    BackColor = Color.Yellow;
    }
    BUT when i code this with calculation instead with a value it works not exact (color changes too late, color change but not in zone ;for example):

    something from the code:
    protected override void OnBarUpdate()

    double value5 = myIndicator(Period)[0];

    double high = value3 + (value4 * 3);
    double medium = value3 + (value4 * 2);
    double low = value3 + (value4 * 0.5 );
    double verylow = value3 - (value4 * 2);

    ( if (value5 >= high)
    {
    BackColor = Color.White;
    }

    else if(value5 >= medium)
    {
    BackColor = Color.Blue;
    }
    else if(value5 >= low)
    {
    BackColor = Color.Green;
    }

    else if(value5 < verylow)
    {
    BackColor = Color.Yellow;
    }

    Thank you for help.

    #2
    Hello nt_dd,

    One thing to check here is the types are all doubles for all your value* variables. If you're mixing integer and doubles, you might not get calculations as you expect. Then, start simplifying and printing all values here so you can verify everything is what you expect.

    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    161 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    309 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    245 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    349 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X