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

Hollow Candles

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

    Hollow Candles

    Hi

    Could you please help me mod my indicator, its basically a smoothed Heiken Ashi. What I would like to do is have hollow candles if....

    When a blue candle closed higher than it opens

    When a red candle closed lower than it opens.

    How can I do this please.

    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>
        /// HEKICOL
        /// </summary>
        [Description("HEKICOL")]
        public class HEKICOL : Indicator
        {
            #region Variables
            // Wizard generated variables
                private Color upcol = Color.Blue; // Default setting for LongColour
                private Color dncol = Color.Red; // Default setting for ShortColour
                private int barWidth = 1; // Default setting for BarWidth
            // User defined variables (add any user defined variables below)
    			private DataSeries		haClose;
    			private DataSeries		haOpen;
    			private DataSeries		icolor;
    		
            #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()
            {
                Overlay				= true;
    			haClose				= new DataSeries(this);
    			haOpen				= new DataSeries(this);
    			icolor				= new DataSeries(this);
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
    			double CompBars = 6 ;
    			//Color UpCol = Color.FromArgb(15,90,180);
    			//Color DnCol = Color.FromArgb(255,50,50);
    			//Color icolor = Color.FromArgb(255,50,50);
    			/*If LongColour = 0 then upcol = RGB(15,90,180)
    			Else UpCol = LongColour;
    
    			If ShortColour = 0 then dncol = RGB(255,50,50)
    			Else DnCol = ShortColour;*/
    
    			
    			if (CurrentBar == 1)
    			{
    				haOpen[0] = Open[0];
    				haClose[0] = (Open[0] + High[0] + Low[0] + Close[0])/4; 
    			}
    
    			if (CurrentBar > 1)
    			{
    				haClose[0] = (Open[0] + High[0] + Low[0] + Close[0])/4; 
    				haOpen[0] = (haOpen[1] + haClose[1])/2;
    
    				if (haClose[0] > haOpen[0])
    					icolor[0] = 1;
    				else icolor[0] = 2;
    				/////////////////////////////////////////
    				if (icolor[0] == 1)
    				{
    					BarColor = UpCol;
    				}
    				if (icolor[0] == 2)
    				{
    					BarColor = DnCol;
    				}
    				////////////////////////////////////////
    	
    				for (int x = 1; x <= CompBars; x++)
    				{
    					if  ((haOpen[0] <= Math.Max(haOpen[x],haClose[x])) &&
    					(haOpen[0] >= Math.Min(haOpen[x],haClose[x])) &&
    					(haClose[0] <= Math.Max(haOpen[x],haClose[x])) &&
    					(haClose[0] >= Math.Min(haOpen[x],haClose[x]))) 
    					icolor[0] = icolor[x];
    				}
    				if (icolor[0] == 1)
    				{
    					BarColor = UpCol;
    					CandleOutlineColor = UpCol;
    				}
    				if (icolor[0] == 2)
    				{
    					BarColor = DnCol;
    					CandleOutlineColor = DnCol;
    				}
    
    			}
    		}
    
            #region Properties
    		
    		[XmlIgnore()]
            [Description("Color for up")]
            [GridCategory("Parameters")]
            public Color UpCol
            {
                get { return upcol; }
                set { upcol = value; }
            }
    		
    		// Serialize our Color object
    		[Browsable(false)]
    		public string UpColSerialize
    		{
    			get { return NinjaTrader.Gui.Design.SerializableColor.ToString(upcol); }
    			set { upcol = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
    		}
    
    		[XmlIgnore()]
    		[Description("Color for painted region")]
            [GridCategory("Parameters")]
            public Color DnCol
            {
                get { return dncol; }
                set { dncol = value; }
            }
    		
    		[Browsable(false)]
    		public string DnColSerialize
    		{
    			get { return NinjaTrader.Gui.Design.SerializableColor.ToString(dncol); }
    			set { dncol = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
    		}
    		
    
            [Description("")]
            [GridCategory("Parameters")]
            public int BarWidth
            {
                get { return barWidth; }
                set { barWidth = Math.Max(1, value); }
            }
            #endregion
        }
    }

    #2
    Hello lucyjoy,

    Thanks for your post.

    I think you can accomplish this by modifying the code:

    Code:
    				if (icolor[0] == 1)
    				{
    					BarColor = UpCol;
    					CandleOutlineColor = UpCol;
    					[COLOR="Blue"]if (haClose[0] > haOpen[0]) BarColor = Color.Transparent;[/COLOR]
    				}
    				if (icolor[0] == 2)
    				{
    					BarColor = DnCol;
    					CandleOutlineColor = DnCol;
    					[COLOR="blue"]if (haClose[0] < haOpen[0]) BarColor = Color.Transparent;[/COLOR]
    				}
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul

      Thats great advice, worked perfect

      Thank you

      Lucy

      Comment


        #4
        Smoothed Heikin Ashi indicator

        A smoothed Heikin-Ashi indicator with additional options

        - candle formula DanValcu or modified according to Sylvain Vervoort
        - smoothing with 34 different moving averages
        - optional display of original chart bars along with Heikin-Ashi bars

        is availabe as a free download here:



        The indicator comes open source, so you can evaluate the code.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by helpwanted, Today, 03:06 AM
        0 responses
        3 views
        0 likes
        Last Post helpwanted  
        Started by Brevo, Today, 01:45 AM
        0 responses
        6 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        5 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X