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 Stanfillirenfro, Today, 07:23 AM
    2 responses
    9 views
    0 likes
    Last Post Stanfillirenfro  
    Started by rexsole, Today, 08:39 AM
    2 responses
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    6 responses
    29 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by gbourque, Today, 06:39 AM
    2 responses
    14 views
    0 likes
    Last Post gbourque  
    Started by trilliantrader, Yesterday, 03:01 PM
    3 responses
    31 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X