Apparently until I resolve that earlier one I cant.
I tried using /* */ to make it invisible and also the icons that do it but that wont let me either.
There must be a way. is there?
#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.Indicator; using NinjaTrader.Gui.Chart; using NinjaTrader.Strategy; #endregion // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Indicator { /// <summary> /// MACD current bar color depends on length compared to prior histogram bar /// </summary> [Description("MACD current bar color depends on length compared to prior histogram bar")] public class MACDhistogramBarRecolor : Indicator { #region Variables private int fast = 8; private int slow = 18; private int smooth = 9; private DataSeries fastEma; private DataSeries slowEma; private Color UpBar = Color.Lime; //********************* private Color DownBar = Color.Red;//************************* #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { //****** here you'll need to add a plot object for each different color bar you'd like Add(new Plot(Color.Green, "Macd")); Add(new Plot(Color.DarkViolet, "Avg")); Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "Diff")); Add(new Line(Color.Blue, 0, "Zero line")); //******if you wanted another plot named "UpBar" you could add the following line: //*****Add(new Plot(new Pen(Color.RoyalBlue, 1), PlotStyle.Bar, "UpBar")); Add(new Plot(new Pen(Color.RoyalBlue, 1), PlotStyle.Bar, "UpBar")); Add(new Plot(new Pen(Color.Black, 1), PlotStyle.Bar, "DownBar")); fastEma = new DataSeries(this); slowEma = new DataSeries(this); } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBar == 0) { fastEma.Set(Input[0]); slowEma.Set(Input[0]); Value.Set(0); Avg.Set(0); Diff.Set(0); } else { fastEma.Set((2.0 / (1 + Fast)) * Input[0] + (1 - (2.0 / (1 + Fast))) * fastEma[1]); slowEma.Set((2.0 / (1 + Slow)) * Input[0] + (1 - (2.0 / (1 + Slow))) * slowEma[1]); double macd = fastEma[0] - slowEma[0]; double macdAvg = (2.0 / (1 + Smooth)) * macd + (1 - (2.0 / (1 + Smooth))) * Avg[1]; //***** this is where the plot values are set Value.Set(macd); Avg.Set(macdAvg); Diff.Set(macd - macdAvg); // Condition set 1 //***** Adding plots needs to be done in Initialize(), not here in OnBarUpdate(). //***** This is where you set the value of the plot. //***** I'm not exactly sure what this condition means, but it looks like MACD > MACD one bar ago, //**** thus we'll set UpBar to the current value. if ( MACD(8, 18, 9)[0] > MACD(8, 18, 9)[1]) Add(new Plot(new Pen(Color.Aqua, 2), PlotStyle.Bar, "MACD")); { UpBar.Set(MACD(8, 18, 9)[0]); } // Condition set 2 //***** for if MACD is falling if ( MACD(8, 18, 9)[0] < MACD(8, 18, 9)[1]) Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "MACD")); { //*** need to add an associated plot for this statement to work DownBar.Set(MACD(8, 18, 9)[0]); } //Condition set 3 if (MACD(8, 18, 9)[0]>0) Add(new Plot(new Pen(Color.DarkCyan, 2), PlotStyle.Bar, "MACD")); //Condition set4 if (MACD(8, 18, 9)[0]<0) Add(new Plot(new Pen(Color.Silver, 2), PlotStyle.Bar, "MACD")); } { } } #region Properties /// <summary> /// </summary> [Browsable(false)] [XmlIgnore()] public DataSeries Avg { get { return Values[1]; } } /// <summary> /// </summary> [Browsable(false)] [XmlIgnore()] public DataSeries Default { get { return Values[0]; } } /// <summary> /// </summary> [Browsable(false)] [XmlIgnore()] public DataSeries Diff { get { return Values[2]; } } /// <summary> /// </summary> [Description("Number of bars for fast EMA")] [Category("Parameters")] public int Fast { get { return fast; } set { fast = Math.Max(1, value); } } [Category("Visual")]//******************************** private Color UpBar { get{return UpBar;} set {UpBar=value;} } //**************************************** /// <summary> /// </summary> [Description("Number of bars for slow EMA")] [Category("Parameters")] public int Slow { get { return slow; } set { slow = Math.Max(1, value); } } /// <summary> /// </summary> [Description("Number of bars for smoothing")] [Category("Parameters")] public int Smooth { get { return smooth; } set { smooth = Math.Max(1, 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 MACDhistogramBarRecolor[] cacheMACDhistogramBarRecolor = null; private static MACDhistogramBarRecolor checkMACDhistogramBarRecolor = new MACDhistogramBarRecolor(); /// <summary> /// MACD current bar color depends on length compared to prior histogram bar /// </summary> /// <returns></returns> public MACDhistogramBarRecolor MACDhistogramBarRecolor(int fast, int slow, int smooth) { return MACDhistogramBarRecolor(Input, fast, slow, smooth); } /// <summary> /// MACD current bar color depends on length compared to prior histogram bar /// </summary> /// <returns></returns> public MACDhistogramBarRecolor MACDhistogramBarRecolor(Data.IDataSeries input, int fast, int slow, int smooth) { checkMACDhistogramBarRecolor.Fast = fast; fast = checkMACDhistogramBarRecolor.Fast; checkMACDhistogramBarRecolor.Slow = slow; slow = checkMACDhistogramBarRecolor.Slow; checkMACDhistogramBarRecolor.Smooth = smooth; smooth = checkMACDhistogramBarRecolor.Smooth; if (cacheMACDhistogramBarRecolor != null) for (int idx = 0; idx < cacheMACDhistogramBarRecolor.Length; idx++) if (cacheMACDhistogramBarRecolor[idx].Fast == fast && cacheMACDhistogramBarRecolor[idx].Slow == slow && cacheMACDhistogramBarRecolor[idx].Smooth == smooth && cacheMACDhistogramBarRecolor[idx].EqualsInput(input)) return cacheMACDhistogramBarRecolor[idx]; MACDhistogramBarRecolor indicator = new MACDhistogramBarRecolor(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; indicator.Input = input; indicator.Fast = fast; indicator.Slow = slow; indicator.Smooth = smooth; indicator.SetUp(); MACDhistogramBarRecolor[] tmp = new MACDhistogramBarRecolor[cacheMACDhistogramBarRecolor == null ? 1 : cacheMACDhistogramBarRecolor.Length + 1]; if (cacheMACDhistogramBarRecolor != null) cacheMACDhistogramBarRecolor.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheMACDhistogramBarRecolor = tmp; Indicators.Add(indicator); 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> /// MACD current bar color depends on length compared to prior histogram bar /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.MACDhistogramBarRecolor MACDhistogramBarRecolor(int fast, int slow, int smooth) { return _indicator.MACDhistogramBarRecolor(Input, fast, slow, smooth); } /// <summary> /// MACD current bar color depends on length compared to prior histogram bar /// </summary> /// <returns></returns> public Indicator.MACDhistogramBarRecolor MACDhistogramBarRecolor(Data.IDataSeries input, int fast, int slow, int smooth) { return _indicator.MACDhistogramBarRecolor(input, fast, slow, smooth); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// <summary> /// MACD current bar color depends on length compared to prior histogram bar /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.MACDhistogramBarRecolor MACDhistogramBarRecolor(int fast, int slow, int smooth) { return _indicator.MACDhistogramBarRecolor(Input, fast, slow, smooth); } /// <summary> /// MACD current bar color depends on length compared to prior histogram bar /// </summary> /// <returns></returns> public Indicator.MACDhistogramBarRecolor MACDhistogramBarRecolor(Data.IDataSeries input, int fast, int slow, int smooth) { 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.MACDhistogramBarRecolor(input, fast, slow, smooth); } } } #endregion
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bmartz, 03-12-2024, 06:12 AM
|
5 responses
32 views
0 likes
|
Last Post Today, 08:34 AM | ||
Started by Aviram Y, Today, 05:29 AM
|
4 responses
13 views
0 likes
|
Last Post
by Aviram Y
Today, 07:57 AM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
3 responses
28 views
0 likes
|
Last Post Today, 07:41 AM | ||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:30 AM | ||
Started by cls71, Today, 04:45 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:25 AM |
Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one’s financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.
CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates.
Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.
Comment