Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I use NinjaScript to change candle wick color?

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

    How can I use NinjaScript to change candle wick color?

    How do I access this property using NinjaScript? It's not the same as CandleOutlineBrush.
    Attached Files

    #2
    Hello armybender,


    Currently in NinjaTrader CandleOutlineBrush is the only way to program candle wicks to change color conditionally.
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      Shawn,

      It turns out there's a "stroke2" property I was able to access to alter the wick directly.

      CandleOutlineBrush takes care of the body, but the "stroke2" option is just the wicks.

      Thanks,

      Adam

      Comment


        #4
        Would you be so kind as to reply with your code for changing the wick colors conditionally? Thanks

        Comment


          #5
          Code

          Originally posted by user_456 View Post
          Would you be so kind as to reply with your code for changing the wick colors conditionally? Thanks


          Code:
          /// This section gets added at the top of the indicator
             
            // Define a Chart object to refer to the chart on which the indicator resides
            private Chart chartWindow;
             
             
            /// This gets called in a custom function that is called on in “State.Historical”
            //Obtain the Chart on which the indicator is configured
            chartWindow = Window.GetWindow(this.ChartControl.Parent) as Chart;
             
            if (chartWindow == null)
            {
            Print("chartWindow == null");
            return;
            }
             
             
            /// This is called after a button press, but could be called at any time – this actually hides the wicks
            foreach (var obj in chartWindow.ActiveChartControl.ChartObjects)
            {
            var wicks = obj as ChartBars;
            if (wicks != null)
            {
            switch (wicks.Properties.ChartStyle.Stroke2.Brush.ToString())
            {
            case "#FF000000":
            {
            wicks.Properties.ChartStyle.Stroke2.Brush = Brushes.Transparent;
            break;
            }
            case "#00FFFFFF":
            {
            wicks.Properties.ChartStyle.Stroke2.Brush = Brushes.Black;
            break;
            }
            default:
            {                                                           
            wicks.Properties.ChartStyle.Stroke2.Brush = Brushes.Black;
            break;
            }
            }
            }
            }
            chartWindow.ActiveChartControl.InvalidateVisual();
            ForceRefresh();

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by PaulMohn, Today, 03:49 AM
          0 responses
          4 views
          0 likes
          Last Post PaulMohn  
          Started by inanazsocial, Today, 01:15 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by rocketman7, Today, 02:12 AM
          0 responses
          10 views
          0 likes
          Last Post rocketman7  
          Started by dustydbayer, Today, 01:59 AM
          0 responses
          2 views
          0 likes
          Last Post dustydbayer  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          23 views
          0 likes
          Last Post trilliantrader  
          Working...
          X