Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Paint Bar help.

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

    Paint Bar help.

    I was wondering if anyone knew of the proper code for an indicator that will do this.

    If current bar close is up and previous bars close was up paint current bar Blue
    Other wise paint bar Cyan (as chosen in data series)

    If current bar close is down and previous bars close was down paint current bar Red
    Other wise paint bar Pink (as chosen in data series)

    Sorry i have no code writting ability.

    I guess you could call this indicator (Heat Bars).. As you get successive closes in on direction it paints bar a brighter color if not it paints bar chosen in the data series for up and down bars.
    I would use this at support/resistance as a trigger to enter on a range chart..

    Thanks for any help or direction

    #2
    Hello davidjrjr,

    Thank you for your post.

    The code would be the following:
    Code:
    			if(Close[0] > Open[0] && Close[1] > Open[1])
    				BarColor = Color.Blue;
    			if(Close[0] < Open[0] && Close[1] < Open[1])
    				BarColor = Color.Red;
    For information on the BarColor please visit the following link: http://www.ninjatrader.com/support/h...7/barcolor.htm

    Please let me know if you have any questions.

    Comment


      #3
      Ok Thanks
      I'll give a try.
      I should be able to copy and paste into new ind script?

      Comment


        #4
        Hello davidjrjr,

        Thank you for your response.

        That is correct, but paste it into the OnBarUpdate() method.

        Comment


          #5
          Sorry, seems I am doing something wrong.

          Here is where i am at but it will not compile.

          protectedoverridevoid OnBarUpdate()
          {
          Add(
          new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
          Overlay =
          false;
          }
          ///<summary>
          /// Called on each bar update event (incoming tick)
          ///</summary>
          protectedoverridevoid OnBarUpdate()
          {
          if(Close[0] > Open[0] && Close[1] > Open[1])
          BarColor = Color.Blue;
          if(Close[0] < Open[0] && Close[1] < Open[1])
          BarColor = Color.Red;
          // Use this method for calculating your indicator values. Assign a value to each
          // plot below by replacing 'Close[0]' with your own formula.
          Plot0.Set(Close[0]);

          Comment


            #6
            Hello davidjrjr,

            Thank you for your response.

            Please send me a screenshot of the error with the name and description fields clearly readable.

            To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CRTL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

            Comment


              #7
              Click image for larger version

Name:	heatbars.JPG
Views:	1
Size:	160.7 KB
ID:	869849

              Hope I did this right,, thanks

              Comment


                #8
                Hello davidjrjr,

                Thank you for your response.

                You have two OnBarUpdate() methods defined in your code and no Initialize() method. Your HEATBARS indicator code should reflect the code listed below. You can find this indicator attached to this post as well. To import please first go to Tools > Edit NinjaScript > Indicator > select the HEATBARS > Delete > then Cancel > then download the attached .zip file to your Desktop > then go to File > Utilities > Import NinjaScript and select the HEATBARS.zip file on your desktop.
                Code:
                #region Using declarations
                using System;
                using System.ComponentModel;
                using System.Diagnostics;
                using System.Drawing;
                using System.Drawing.Drawing2D;
                using System.Xml.Serialization;
                using NinjaTrader.Cbi;
                using NinjaTrader.Data;
                using NinjaTrader.Gui.Chart;
                #endregion
                
                // This namespace holds all indicators and is required. Do not change it.
                namespace NinjaTrader.Indicator
                {
                    /// <summary>
                    /// 
                    /// </summary>
                    [Description("")]
                    public class HEATBARS : Indicator
                    {
                        #region Variables
                        
                        #endregion
                
                        /// <summary>
                        /// This method is used to configure the indicator and is called once before any bar data is loaded.
                        /// </summary>
                        protected override void Initialize()
                        {
                            
                        }
                
                        /// <summary>
                        /// Called on each bar update event (incoming tick)
                        /// </summary>
                        protected override void OnBarUpdate()
                        {
                			if(Close[0] > Open[0] && Close[1] > Open[1])
                				BarColor = Color.Blue;
                			if(Close[0] < Open[0] && Close[1] < Open[1])
                				BarColor = Color.Red;
                        }
                
                        #region Properties
                        
                        #endregion
                    }
                }
                
                #region NinjaScript generated code. Neither change nor remove.
                // This namespace holds all indicators and is required. Do not change it.
                namespace NinjaTrader.Indicator
                {
                    public partial class Indicator : IndicatorBase
                    {
                        private HEATBARS[] cacheHEATBARS = null;
                
                        private static HEATBARS checkHEATBARS = new HEATBARS();
                
                        /// <summary>
                        /// 
                        /// </summary>
                        /// <returns></returns>
                        public HEATBARS HEATBARS()
                        {
                            return HEATBARS(Input);
                        }
                
                        /// <summary>
                        /// 
                        /// </summary>
                        /// <returns></returns>
                        public HEATBARS HEATBARS(Data.IDataSeries input)
                        {
                            if (cacheHEATBARS != null)
                                for (int idx = 0; idx < cacheHEATBARS.Length; idx++)
                                    if (cacheHEATBARS[idx].EqualsInput(input))
                                        return cacheHEATBARS[idx];
                
                            lock (checkHEATBARS)
                            {
                                if (cacheHEATBARS != null)
                                    for (int idx = 0; idx < cacheHEATBARS.Length; idx++)
                                        if (cacheHEATBARS[idx].EqualsInput(input))
                                            return cacheHEATBARS[idx];
                
                                HEATBARS indicator = new HEATBARS();
                                indicator.BarsRequired = BarsRequired;
                                indicator.CalculateOnBarClose = CalculateOnBarClose;
                #if NT7
                                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
                #endif
                                indicator.Input = input;
                                Indicators.Add(indicator);
                                indicator.SetUp();
                
                                HEATBARS[] tmp = new HEATBARS[cacheHEATBARS == null ? 1 : cacheHEATBARS.Length + 1];
                                if (cacheHEATBARS != null)
                                    cacheHEATBARS.CopyTo(tmp, 0);
                                tmp[tmp.Length - 1] = indicator;
                                cacheHEATBARS = tmp;
                                return indicator;
                            }
                        }
                    }
                }
                
                // This namespace holds all market analyzer column definitions and is required. Do not change it.
                namespace NinjaTrader.MarketAnalyzer
                {
                    public partial class Column : ColumnBase
                    {
                        /// <summary>
                        /// 
                        /// </summary>
                        /// <returns></returns>
                        [Gui.Design.WizardCondition("Indicator")]
                        public Indicator.HEATBARS HEATBARS()
                        {
                            return _indicator.HEATBARS(Input);
                        }
                
                        /// <summary>
                        /// 
                        /// </summary>
                        /// <returns></returns>
                        public Indicator.HEATBARS HEATBARS(Data.IDataSeries input)
                        {
                            return _indicator.HEATBARS(input);
                        }
                    }
                }
                
                // This namespace holds all strategies and is required. Do not change it.
                namespace NinjaTrader.Strategy
                {
                    public partial class Strategy : StrategyBase
                    {
                        /// <summary>
                        /// 
                        /// </summary>
                        /// <returns></returns>
                        [Gui.Design.WizardCondition("Indicator")]
                        public Indicator.HEATBARS HEATBARS()
                        {
                            return _indicator.HEATBARS(Input);
                        }
                
                        /// <summary>
                        /// 
                        /// </summary>
                        /// <returns></returns>
                        public Indicator.HEATBARS HEATBARS(Data.IDataSeries input)
                        {
                            if (InInitialize && input == null)
                                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
                
                            return _indicator.HEATBARS(input);
                        }
                    }
                }
                #endregion
                Attached Files

                Comment


                  #9
                  Originally posted by davidjrjr View Post
                  Sorry, seems I am doing something wrong.

                  Here is where i am at but it will not compile.

                  protectedoverridevoid OnBarUpdate()
                  {
                  Add(
                  new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                  Overlay =
                  false;
                  }
                  ///<summary>
                  /// Called on each bar update event (incoming tick)
                  ///</summary>
                  protectedoverridevoid OnBarUpdate()
                  {
                  if(Close[0] > Open[0] && Close[1] > Open[1])
                  BarColor = Color.Blue;
                  if(Close[0] < Open[0] && Close[1] < Open[1])
                  BarColor = Color.Red;
                  // Use this method for calculating your indicator values. Assign a value to each
                  // plot below by replacing 'Close[0]' with your own formula.
                  Plot0.Set(Close[0]);
                  It will not compile, or it will not color the bars? Which.

                  Comment


                    #10
                    Thanks,
                    But,, It doesnt to seem to work or any thing being indicated.

                    It downloaded and imported fine. I added it to chart assigned it to price but no
                    color changes.

                    Sorry for being so much bother..

                    Am i missing something?

                    Comment


                      #11
                      There is a small bug in the Heat Bars, please replace OnBarUpdate() with

                      Code:
                      [COLOR=Blue]protected override void[/COLOR] OnBarUpdate()         
                      {             
                           [COLOR=Navy][COLOR=Blue]if[/COLOR]([/COLOR]CurrentBar < 1)  [COLOR=Green]// necessary addition, otherwise the indicator will not work[/COLOR]
                                [COLOR=Blue]return[/COLOR];
                          [COLOR=Blue] if[/COLOR](Close[0] > Open[0] && Close[1] > Open[1])                 
                                BarColorSeries[-Displacement]  = Color.Blue;   [COLOR=Green]// recommended  [/COLOR]        
                           [COLOR=Blue]if[/COLOR](Close[0] < Open[0] && Close[1] < Open[1])                 
                               BarColorSeries[-Displacement]  = Color.Red;     [COLOR=Green]// recommended[/COLOR]
                      }

                      Comment


                        #12
                        Thank You Thank You Thank You!!

                        Works perefectly!


                        Thanks

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Tim-c, Today, 03:54 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post Tim-c
                        by Tim-c
                         
                        Started by FrancisMorro, Today, 03:24 AM
                        0 responses
                        2 views
                        0 likes
                        Last Post FrancisMorro  
                        Started by Segwin, 05-07-2018, 02:15 PM
                        10 responses
                        1,771 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
                        945 views
                        0 likes
                        Last Post spwizard  
                        Working...
                        X