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

BackBrushes + ColorFromARGB not showing up on chart

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

    BackBrushes + ColorFromARGB not showing up on chart

    Hi there!

    I've configured some custom brushes in a script, but none of them are showing up in my chart when I'm connected to my broker and trading live. They worked in replay mode though. Here's what I have on the code side:

    Code:
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public class Feb152024 : Strategy
        {​
    
    (...)
    
    //  Define all brushes here
            private Brush ENV_online;    
            private Brush ENV_lowPower;        
            private    Brush ENV_offline;
            
            private    Brush trendArrow_up_3;
            private    Brush trendArrow_up_2;
            private    Brush trendArrow_up_1;    
            private    Brush trendArrow_0;
            private    Brush trendArrow_down_1;    
            private    Brush trendArrow_down_2;    
            private    Brush trendArrow_down_3;
            
            private    Brush bidGap_firstGap_line;
            private    Brush bidGap_secondGap_line;
            private    Brush bidGap_thirdGap_line;
            
            private    Brush askGap_firstGap_line;
            private    Brush askGap_secondGap_line;
            private    Brush askGap_thirdGap_line;​
    
    (...)
    
    protected override void OnStateChange()
                {​
    
    (...)
    
    else if (State == State.Configure)
                    //  Configure is called after a user adds an object to the applied list of objects.
                    // • Add additional data series via AddDataSeries()
                    // • Declare custom resources
                    {
                        //  Configure the colors of the brushes in this space
                        ENV_online = new SolidColorBrush(Color.FromArgb(255, 3, 3, 20));                ENV_online.Freeze();
                        ENV_lowPower = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));                ENV_lowPower.Freeze();
                        ENV_offline = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));                    ENV_offline.Freeze();
                        
                        trendArrow_up_3 = new SolidColorBrush(Color.FromArgb(255, 83, 58, 233));        trendArrow_up_3.Freeze();
                        trendArrow_up_2 = new SolidColorBrush(Color.FromArgb(255, 55, 38, 155));        trendArrow_up_2.Freeze();
                        trendArrow_up_1 = new SolidColorBrush(Color.FromArgb(255, 27, 19, 77));            trendArrow_up_1.Freeze();
                        trendArrow_0 = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));                trendArrow_0.Freeze();
                        trendArrow_down_1 = new SolidColorBrush(Color.FromArgb(255, 55, 16, 65));        trendArrow_down_1.Freeze();
                        trendArrow_down_2 = new SolidColorBrush(Color.FromArgb(255, 110, 33, 130));        trendArrow_down_2.Freeze();
                        trendArrow_down_3 = new SolidColorBrush(Color.FromArgb(255, 166, 50, 195));        trendArrow_down_3.Freeze();
                        
                        bidGap_firstGap_line = new SolidColorBrush(Color.FromArgb(150, 191, 0, 0));        bidGap_firstGap_line.Freeze();
                        bidGap_secondGap_line = new SolidColorBrush(Color.FromArgb(150, 128, 0, 0));    bidGap_secondGap_line.Freeze();
                        bidGap_thirdGap_line = new SolidColorBrush(Color.FromArgb(150, 64, 0, 0));        bidGap_thirdGap_line.Freeze();
                        
                        askGap_firstGap_line = new SolidColorBrush(Color.FromArgb(150, 31, 198, 0));    askGap_firstGap_line.Freeze();
                        askGap_secondGap_line = new SolidColorBrush(Color.FromArgb(150, 8, 144, 0));    askGap_secondGap_line.Freeze();
                        askGap_thirdGap_line = new SolidColorBrush(Color.FromArgb(150, 10, 93, 0));        askGap_thirdGap_line.Freeze();
                        
                    }​
    
    
    (...)
    
    protected override void OnBarUpdate()
            {​
    (...)
    //  Color the background given the price span and gap target indicators
                if (gap_target_signal == "*" && price_span_signal == "*")         {    BackBrushes[0] = ENV_online;    ENV_status = "Online";    }
                else if (gap_target_signal == "" && price_span_signal == "*")     {    BackBrushes[0] = Brushes.Black;    ENV_status = "Low power";    }
                else if (gap_target_signal == "*" && price_span_signal == "")    {    BackBrushes[0] = Brushes.Black;    ENV_status = "Low power";    }
                else {    BackBrushes[0] = ENV_offline;    ENV_status = "offline";    }​
    I had just restarted Ninjatrader 8 to start my trading day with this new script and the background doesn't seem to show those custom colors I've been setting.

    Any suggestions on how to trouble shoot this?

    #2
    Hello Spiderbird,

    Thanks for your post.

    Since your question is related to a custom NinjaScript strategy, I have moved this forum thread to the Strategy Development section of the forums.

    So we may accurately assist, please answer all the questions below.

    What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)​

    Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?

    Based on the code you shared it seems that these are private Brushes that are not set from the UI, is that correct?

    Have you added debugging prints to the script to see exactly how the logic is behaving?

    We look forward to assisting further.
    Last edited by NinjaTrader_BrandonH; 02-15-2024, 11:38 AM.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello Spiderbird,

      Thanks for your post.

      Since your question is related to a custom NinjaScript strategy, I have moved this forum thread to the Strategy Development section of the forums.

      So we may accurately assist, please answer all the questions below.

      What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)​

      Do you receive an error on screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?

      Based on the code you shared it seems that these are private Brushes that are not set from the UI, is that correct?

      Have you added debugging prints to the script to see exactly how the logic is behaving?

      We look forward to assisting further.
      Hi Brandon!

      Thanks for taking the time to respond. Here are the answers you're looking for:

      Version: 8.0.27.1 64-bit
      Errors: No errors on the screen. No particular errors in the Log file. There are just default messages showing my person starting and stopping strategies.

      Based on the code you shared it seems that these are private Brushes that are not set from the UI, is that correct?
      Correct. It's all Ninjascript in a custom strategy. But, I have tried Brushes.Black, Brushes.Blue instead of custom brushes. Even those don't seem to print to the background.

      Have you added debugging prints to the script to see exactly how the logic is behaving?
      I have. I double checked to make sure that the strings in that custom bit of code were triggering properly and that the background color is defined correctly.

      Here's a sample from a debugging script that uses the same code (just a different strategy name)

      ===============
      gap_BT_count: 0
      ema5_down_count: 6
      ---
      gap_AT_count: 0
      ema5_up_count: 0
      ---
      BackBrushes[0]: #FF000000
      ===============​

      So it's working, but the chart isn't coloring right. My options are to:

      1. Download the latest release (Latest release 8.1.2.1) and see if that does the trick or
      2. Close the chart, reopen a new one and try the strategy again.

      Maybe both? What do you recommend?

      Comment


        #4
        Hello Spiderbird,

        Thanks for your notes.

        NinjaTrader 8.0.27.1 is an old version of NinjaTrader. The current versions of NinjaTrader are 8.0.28.0 and 8.1.2.1.

        First, please update NinjaTrader to 8.0.28.0 or 8.1.2.1 depending on your preference, and test to see if the behavior persists.

        To update NinjaTrader
        • Shutdown all programs including NinjaTrader *important
        • Download NinjaTrader from the link below
        • Double click the downloaded file to execute it
        • Follow the on screen instructions
        • Restart NinjaTrader
        ​You can read about changes to this release in the release notes linked below.


        In the prints you shared, I do not see where you are printing out the 'gap_target_signal' or 'price_span_signal' which are used in the conditions to set the BackBrush in the code you shared in post # 1.

        Please add prints to the script (one line above the conditions) that prints out all the values being used to set the BackBrush and within those conditions, add a print below BackBrushes[0] = x to confirm the condition triggering.

        ​Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hi Brandon,

          Upgrading to 8.1.2.1 did the trick! Background is coloring as expected now.
          Thanks for taking the time and effort to respond to my inquiry on such short notice. Much appreciated. Saved me a ton of headaches.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Jonafare, 12-06-2012, 03:48 PM
          5 responses
          3,984 views
          0 likes
          Last Post rene69851  
          Started by Fitspressorest, Today, 01:38 PM
          0 responses
          2 views
          0 likes
          Last Post Fitspressorest  
          Started by Jonker, Today, 01:19 PM
          0 responses
          2 views
          0 likes
          Last Post Jonker
          by Jonker
           
          Started by futtrader, Today, 01:16 PM
          0 responses
          6 views
          0 likes
          Last Post futtrader  
          Started by Segwin, 05-07-2018, 02:15 PM
          14 responses
          1,791 views
          0 likes
          Last Post aligator  
          Working...
          X