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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    42 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    25 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    162 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    98 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    157 views
    2 likes
    Last Post CaptainJack  
    Working...
    X