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

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 FrancisMorro, Today, 03:24 AM
    0 responses
    1 view
    0 likes
    Last Post FrancisMorro  
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,770 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    31 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    944 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    11 views
    0 likes
    Last Post Max238
    by Max238
     
    Working...
    X