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

doji

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

    doji

    I wrote an indicator to color dojis yellow intrabar.
    It works except the wick on the doji is the same gray color as my non doji wicks.
    How do I tell it to color doji wicks yellow too?

    This is what I have that skips wicks:
    if (Close[0]==Open[0]==true)
    BarColor = Color.Yellow;;
    if (Close[0]<Open[0]==true)
    BarColor = Color.Violet;
    if (Close[0]>Open[0]==true)
    BarColor = Color.LimeGreen;

    I tried adding && WickColor=Color.Yellow; after BarColor=Color.Yellow but there is no such word.

    #2
    Hello simpletrades,

    Thank you for your post.

    You can use CandleOutlineColorSeries.Set(CurrentBar, Color.Blue); to set the wick and outline color.

    Please let me know if you have any questions.

    Comment


      #3
      won't that outline all bars not just dojis?

      Comment


        #4
        Hello simpletrades,

        Thank you for your response.

        No, you can use this to set the color of the CurrentBar as the desired color for the Wick and Outline.

        Please let me know if you have any questions.

        Comment


          #5
          I tried this and from the bar that I load and apply it all bars from then on keep yellow outlines before and after the bar closes.
          I only want dojis to be colored yellow

          Comment


            #6
            Hello simpletrades,

            Thank you for your response.

            Please provide your indicator so we may investigate this matter further. You can attach your indicator to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your Indicator > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.

            I look forward to your repsonse.

            Comment


              #7
              I loaded the indicator just on the last 2 bars after your reply came.
              Everything is outlined even though these aren't dojis
              The code I adapted from something I found.
              // This namespace holds all indicators and is required. Do not change it.
              namespace NinjaTrader.Indicator
              {
              /// <summary>
              /// This indicator colors bars. Reversal bars are also identified.
              /// </summary>
              [Description("This indicator adjusts the bar color")]
              [Gui.Design.DisplayName("nfsCandles")]
              public class dojis2 : Indicator
              {
              #region Variables
              //private Color candleOutlineUp = Color.Lime;
              //private Color candleOutlineDown = Color.OrangeRed;
              private Color candleOutlineDoji = Color.Yellow;
              #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()
              {
              CalculateOnBarClose = false;
              Overlay = true;
              AutoScale = true;
              PriceTypeSupported = false;
              DisplayInDataBox = false;
              PaintPriceMarkers = false;

              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
              //if (Close[0]>Open[0])
              // CandleOutlineColor = candleOutlineUp;
              //if (Close[0]<Open[0])
              // CandleOutlineColor = candleOutlineDown;
              if (Close[0]==Open[0]==true)
              BarColor = Color.Yellow;
              if (Close[0]<Open[0]==true)
              BarColor = Color.Violet;
              if (Close[0]>Open[0]==true)
              BarColor = Color.LimeGreen;
              if (Close[0]==Open[0]==true)
              CandleOutlineColorSeries.Set(CurrentBar, Color.Yellow);

              }

              #region Properties
              /// <summary>
              /// </summary>
              //[Description("Select Candle Outline Color")]
              //[Category("Colors")]
              //[Gui.Design.DisplayName("Candle Outline Up")]
              //public Color CandleOutlineUp
              //{
              // get { return candleOutlineUp; }
              // set { candleOutlineUp = value; }
              //}

              // Serialize Color object
              // [Browsable(false)]
              //public string CandleOutlineUpSerialize
              // {
              // get { return NinjaTrader.Gui.Design.SerializableColor.ToString( candleOutlineUp); }
              // set { candleOutlineUp = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
              // }

              /// <summary>
              /// </summary>


              /// <summary>
              /// </summary>
              [Description("Select Candle Outline Color")]
              [Category("Colors")]
              [Gui.Design.DisplayName("Candle Outline Doji")]
              public Color CandleOutlineDoji
              {
              get { return candleOutlineDoji; }
              set { candleOutlineDoji = value; }
              }

              // Serialize Color object
              [Browsable(false)]
              public string CandleOutlineDojiSerialize
              {
              get { return NinjaTrader.Gui.Design.SerializableColor.ToString( candleOutlineDoji); }
              set { candleOutlineDoji = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
              }

              #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 dojis2[] cachedojis2 = null;

              private static dojis2 checkdojis2 = new dojis2();

              /// <summary>
              /// This indicator adjusts the bar color
              /// </summary>
              /// <returns></returns>
              public dojis2 dojis2()
              {
              return dojis2(Input);
              }

              /// <summary>
              /// This indicator adjusts the bar color
              /// </summary>
              /// <returns></returns>
              public dojis2 dojis2(Data.IDataSeries input)
              {
              if (cachedojis2 != null)
              for (int idx = 0; idx < cachedojis2.Length; idx++)
              if (cachedojis2[idx].EqualsInput(input))
              return cachedojis2[idx];

              lock (checkdojis2)
              {
              if (cachedojis2 != null)
              for (int idx = 0; idx < cachedojis2.Length; idx++)
              if (cachedojis2[idx].EqualsInput(input))
              return cachedojis2[idx];

              dojis2 indicator = new dojis2();
              indicator.BarsRequired = BarsRequired;
              indicator.CalculateOnBarClose = CalculateOnBarClose;
              #if NT7
              indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
              indicator.MaximumBarsLookBack = MaximumBarsLookBack;
              #endif
              indicator.Input = input;
              Indicators.Add(indicator);
              indicator.SetUp();

              dojis2[] tmp = new dojis2[cachedojis2 == null ? 1 : cachedojis2.Length + 1];
              if (cachedojis2 != null)
              cachedojis2.CopyTo(tmp, 0);
              tmp[tmp.Length - 1] = indicator;
              cachedojis2 = 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>
              /// This indicator adjusts the bar color
              /// </summary>
              /// <returns></returns>
              [Gui.Design.WizardCondition("Indicator")]
              public Indicator.dojis2 dojis2()
              {
              return _indicator.dojis2(Input);
              }

              /// <summary>
              /// This indicator adjusts the bar color
              /// </summary>
              /// <returns></returns>
              public Indicator.dojis2 dojis2(Data.IDataSeries input)
              {
              return _indicator.dojis2(input);
              }
              }
              }

              // This namespace holds all strategies and is required. Do not change it.
              namespace NinjaTrader.Strategy
              {
              public partial class Strategy : StrategyBase
              {
              /// <summary>
              /// This indicator adjusts the bar color
              /// </summary>
              /// <returns></returns>
              [Gui.Design.WizardCondition("Indicator")]
              public Indicator.dojis2 dojis2()
              {
              return _indicator.dojis2(Input);
              }

              /// <summary>
              /// This indicator adjusts the bar color
              /// </summary>
              /// <returns></returns>
              public Indicator.dojis2 dojis2(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.dojis2(input);
              }
              }
              }
              #endregion
              Attached Files
              Last edited by simpletrades; 02-06-2017, 10:23 AM.

              Comment


                #8
                Hello simpletrades,

                Thank you for your response.

                You need to alternate the color. So use an if else, if Close == Open then color yellow, else another color.

                Please let me know if you have any questions.

                Comment


                  #9
                  Almost.
                  I use a black background and my dataseries has black candle outlines and gainsboro wicks.
                  By adding the line else CandleOutlineColorSeries.Set(CurrentBar, Color.Gainsboro);
                  I see wicks but the outlines are gainsboro and if I use color.black the candles look fine but I cant see the wicks?

                  Comment


                    #10
                    Hello simpletrades,

                    Thank you for your response.

                    Attached is a basic example that shows the wick and outline properly changing on each bar. please let me know if you have any questions on how to implement this after reviewing the attached indicator.

                    You can import the attached indicator by downloading the .zip to your desktop > then go to File in the NinjaTrader 7 Control Center > Utilities > Import NinjaScript > select the downloaded .zip file.

                    Please let me know if you have any questions.
                    Attached Files

                    Comment


                      #11
                      I'm still really confused.
                      For starters why does the first if use an ! but not the second if statement before thisOrThat?
                      I tried replacing if (!thisOrThat) with if (Open[0]=Close[0]) but got error messages.

                      protected override void OnBarUpdate()
                      {
                      if (!thisOrThat) //if (Open[0]=Close[0])//
                      {
                      CandleOutlineColorSeries.Set(CurrentBar, Color.Orange);
                      thisOrThat = true;
                      }
                      else if (thisOrThat)
                      {
                      CandleOutlineColorSeries.Set(CurrentBar, Color.Purple);//Purple
                      thisOrThat = false;
                      }

                      Comment


                        #12
                        Hello simpletrades,

                        Thank you for your response.

                        An exclamation mark in front of a bool signifies false, so !thisOrThat is the same as thisOrThat == false.
                        For your condition you need to use Close[0] == Open[0] not Close = Open.

                        Please let me know if you have any questions.

                        Comment


                          #13
                          I'm still lost.
                          It makes the doji go on and off intrabar which I want but it was coloring the outlines of all candles orange too so I tried playing with gainsboro and transparent and true and false for the up candles and down ones but I still mostly don't see wicks and # 1a is outlning gainsboro on both up and down bars and has wicks.
                          It seems on some the left half of the chart is when I played around at first and got outlines but at least I had wicks too but I don't remember the settings.
                          .
                          What I'm after is a doji tthat goes on and off intrabar as needed and up and down candles with wicks but no noticeable outline
                          Attached Files

                          Comment


                            #14
                            Hello simpletrades,

                            Thank you for your response.

                            Please attach your indicator to your response.

                            You can attach your indicator to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your Indicator > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.

                            I look forward to your response.

                            Comment


                              #15
                              here it is, thanks
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Christopher_R, Today, 12:29 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post Christopher_R  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              166 responses
                              2,235 views
                              0 likes
                              Last Post sidlercom80  
                              Started by thread, Yesterday, 11:58 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post thread
                              by thread
                               
                              Started by jclose, Yesterday, 09:37 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post jclose
                              by jclose
                               
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              10 responses
                              1,415 views
                              0 likes
                              Last Post Traderontheroad  
                              Working...
                              X