X

## Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com

 General Programming General NinjaScript programming questions.

 06-28-2012, 05:07 AM #1 solondon Junior Member   Join Date: Sep 2011 Posts: 14 Thanks: 1 Thanked 1 time in 1 post transparent plot Hi trying to set a plot to transparent so i only see it on certain conditions, the commented section just Hides both plots. Any ideas how i accomplish this thanks protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.MediumBlue), PlotStyle.Line, "LongProfitTarget")); Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "ShortProfitTarget")); Overlay = true; } /// /// Called on each bar update event (incoming tick) /// protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. LongProfitTarget.Set(Close[0]+ATR(5)[0]); ShortProfitTarget.Set(Close[0]-ATR(5)[0]); // if ((SMA(18)[0] >= SMA(18)[1] // && SMA(9)[0] >= SMA(9)[1]) // && (SMA(18)[1] < SMA(18)[2] || // SMA(9)[1] < SMA(9)[2]) // && (ADX(14)[0]>16 || CrossAbove(ADX(14), 16, 10))) // // PlotColors[0][0] = Color.MediumBlue; // else // PlotColors[0][0] = Color.Transparent; // // if ((SMA(18)[0] <= SMA(18)[1] // && SMA(9)[0] <= SMA(9)[1]) // && (SMA(18)[1] > SMA(18)[2] || // SMA(9)[1] > SMA(9)[2]) // && (ADX(14)[0]>16 || CrossAbove(ADX(14), 16, 10))) // // PlotColors[1][0] = Color.Orange; // else // PlotColors[1][0] = Color.Transparent; }
 06-28-2012, 05:14 AM #2 NinjaTrader_Bertrand NinjaTrader Customer Service     Join Date: Sep 2008 Location: Germany Posts: 22,421 Thanks: 252 Thanked 982 times in 964 posts solondon, I would suggest calling the .Reset() method on the Plot for the bar where you would not like to see a value visualized - http://www.ninjatrader.com/support/h...ries_class.htm Bertrand NinjaTrader Customer Service Use Kinetick, NinjaTrader’s preferred market data service - Learn More Free online training events - View Schedule
 06-29-2012, 06:42 AM #3 solondon Junior Member   Join Date: Sep 2011 Posts: 14 Thanks: 1 Thanked 1 time in 1 post hi i tried adding ShortProfitTarget.Reset(); but it dint make any difference, I cant find a working code example that does this, ie. show or hide the plot can you please help, thnx 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 { /// /// Enter the description of your new custom indicator here /// [Description("Enter the description of your new custom indicator here")] public class aaPipMaximizer1ProfitTarget : Indicator { #region Variables // Wizard generated variables private int aTRperiod = 5; // Default setting for ATRperiod // User defined variables (add any user defined variables below) #endregion /// /// This method is used to configure the indicator and is called once before any bar data is loaded. /// protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.MediumBlue), PlotStyle.Line, "LongProfitTarget")); Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "ShortProfitTarget")); Overlay = true; } /// /// Called on each bar update event (incoming tick) /// protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. LongProfitTarget.Set(Close[0]+ATR(5)[0]); ShortProfitTarget.Set(Close[0]-ATR(5)[0]); if ((SMA(18)[0] >= SMA(18)[1] && SMA(9)[0] >= SMA(9)[1]) && (SMA(18)[1] < SMA(18)[2] || SMA(9)[1] < SMA(9)[2]) && (ADX(14)[0]>16 || CrossAbove(ADX(14), 16, 10))) PlotColors[0][0] = Color.MediumBlue; else // LongProfitTarget.Reset(); PlotColors[0][0] = Color.Transparent; // if ((SMA(18)[0] <= SMA(18)[1] && SMA(9)[0] <= SMA(9)[1]) && (SMA(18)[1] > SMA(18)[2] || SMA(9)[1] > SMA(9)[2]) && (ADX(14)[0]>16 || CrossAbove(ADX(14), 16, 10))) PlotColors[0][0] = Color.Orange; else // ShortProfitTarget.Reset(); PlotColors[1][0] = Color.Transparent; } #region Properties [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries LongProfitTarget { get { return Values[0]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries ShortProfitTarget { get { return Values[1]; } } [Description("")] [GridCategory("Parameters")] public int ATRperiod { get { return aTRperiod; } set { aTRperiod = 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 aaPipMaximizer1ProfitTarget[] cacheaaPipMaximizer1ProfitTarget = null; private static aaPipMaximizer1ProfitTarget checkaaPipMaximizer1ProfitTarget = new aaPipMaximizer1ProfitTarget(); /// /// Enter the description of your new custom indicator here /// /// public aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(int aTRperiod) { return aaPipMaximizer1ProfitTarget(Input, aTRperiod); } /// /// Enter the description of your new custom indicator here /// /// public aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(Data.IDataSeries input, int aTRperiod) { if (cacheaaPipMaximizer1ProfitTarget != null) for (int idx = 0; idx < cacheaaPipMaximizer1ProfitTarget.Length; idx++) if (cacheaaPipMaximizer1ProfitTarget[idx].ATRperiod == aTRperiod && cacheaaPipMaximizer1ProfitTarget[idx].EqualsInput(input)) return cacheaaPipMaximizer1ProfitTarget[idx]; lock (checkaaPipMaximizer1ProfitTarget) { checkaaPipMaximizer1ProfitTarget.ATRperiod = aTRperiod; aTRperiod = checkaaPipMaximizer1ProfitTarget.ATRperiod; if (cacheaaPipMaximizer1ProfitTarget != null) for (int idx = 0; idx < cacheaaPipMaximizer1ProfitTarget.Length; idx++) if (cacheaaPipMaximizer1ProfitTarget[idx].ATRperiod == aTRperiod && cacheaaPipMaximizer1ProfitTarget[idx].EqualsInput(input)) return cacheaaPipMaximizer1ProfitTarget[idx]; aaPipMaximizer1ProfitTarget indicator = new aaPipMaximizer1ProfitTarget(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.ATRperiod = aTRperiod; Indicators.Add(indicator); indicator.SetUp(); aaPipMaximizer1ProfitTarget[] tmp = new aaPipMaximizer1ProfitTarget[cacheaaPipMaximizer1ProfitTarget == null ? 1 : cacheaaPipMaximizer1ProfitTarget.Length + 1]; if (cacheaaPipMaximizer1ProfitTarget != null) cacheaaPipMaximizer1ProfitTarget.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheaaPipMaximizer1ProfitTarget = 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 { /// /// Enter the description of your new custom indicator here /// /// [Gui.Design.WizardCondition("Indicator")] public Indicator.aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(int aTRperiod) { return _indicator.aaPipMaximizer1ProfitTarget(Input, aTRperiod); } /// /// Enter the description of your new custom indicator here /// /// public Indicator.aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(Data.IDataSeries input, int aTRperiod) { return _indicator.aaPipMaximizer1ProfitTarget(input, aTRperiod); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// /// Enter the description of your new custom indicator here /// /// [Gui.Design.WizardCondition("Indicator")] public Indicator.aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(int aTRperiod) { return _indicator.aaPipMaximizer1ProfitTarget(Input, aTRperiod); } /// /// Enter the description of your new custom indicator here /// /// public Indicator.aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(Data.IDataSeries input, int aTRperiod) { 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.aaPipMaximizer1ProfitTarget(input, aTRperiod); } } } #endregion```
 06-29-2012, 06:48 AM #4 NinjaTrader_Bertrand NinjaTrader Customer Service     Join Date: Sep 2008 Location: Germany Posts: 22,421 Thanks: 252 Thanked 982 times in 964 posts solondon, looking at your code - why do you set a value in the first place that you do not want to be set, so visualized? I would move the setting of value directly into your conditions for plotting then. Bertrand NinjaTrader Customer Service Use Kinetick, NinjaTrader’s preferred market data service - Learn More Free online training events - View Schedule
 06-29-2012, 08:40 AM #5 solondon Junior Member   Join Date: Sep 2011 Posts: 14 Thanks: 1 Thanked 1 time in 1 post the code was based on the only example i could find in your documentation http://www.ninjatrader.com/support/h...plotcolors.htm I tried it like that because what i think your suggesting doesnt work ie. if ((SMA(18)[0] >= SMA(18)[1] && SMA(9)[0] >= SMA(9)[1]) && (SMA(18)[1] < SMA(18)[2] || SMA(9)[1] < SMA(9)[2]) && (ADX(14)[0]>16 || CrossAbove(ADX(14), 16, 10))) LongProfitTarget.Set(Close[0]+ATR(5)[0]); 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 { /// /// Enter the description of your new custom indicator here /// [Description("Enter the description of your new custom indicator here")] public class aaPipMaximizer1ProfitTarget : Indicator { #region Variables // Wizard generated variables private int aTRperiod = 5; // Default setting for ATRperiod // User defined variables (add any user defined variables below) #endregion /// /// This method is used to configure the indicator and is called once before any bar data is loaded. /// protected override void Initialize() { Add(new Plot(Color.FromKnownColor(KnownColor.MediumBlue), PlotStyle.Line, "LongProfitTarget")); Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "ShortProfitTarget")); Overlay = true; } /// /// Called on each bar update event (incoming tick) /// protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. // LongProfitTarget.Set(Close[0]+ATR(5)[0]); // ShortProfitTarget.Set(Close[0]-ATR(5)[0]); if ((SMA(18)[0] >= SMA(18)[1] && SMA(9)[0] >= SMA(9)[1]) && (SMA(18)[1] < SMA(18)[2] || SMA(9)[1] < SMA(9)[2]) && (ADX(14)[0]>16 || CrossAbove(ADX(14), 16, 10))) LongProfitTarget.Set(Close[0]+ATR(5)[0]); if ((SMA(18)[0] <= SMA(18)[1] && SMA(9)[0] <= SMA(9)[1]) && (SMA(18)[1] > SMA(18)[2] || SMA(9)[1] > SMA(9)[2]) && (ADX(14)[0]>16 || CrossAbove(ADX(14), 16, 10))) ShortProfitTarget.Set(Close[0]-ATR(5)[0]); } #region Properties [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries LongProfitTarget { get { return Values[0]; } } [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries ShortProfitTarget { get { return Values[1]; } } [Description("")] [GridCategory("Parameters")] public int ATRperiod { get { return aTRperiod; } set { aTRperiod = 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 aaPipMaximizer1ProfitTarget[] cacheaaPipMaximizer1ProfitTarget = null; private static aaPipMaximizer1ProfitTarget checkaaPipMaximizer1ProfitTarget = new aaPipMaximizer1ProfitTarget(); /// /// Enter the description of your new custom indicator here /// /// public aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(int aTRperiod) { return aaPipMaximizer1ProfitTarget(Input, aTRperiod); } /// /// Enter the description of your new custom indicator here /// /// public aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(Data.IDataSeries input, int aTRperiod) { if (cacheaaPipMaximizer1ProfitTarget != null) for (int idx = 0; idx < cacheaaPipMaximizer1ProfitTarget.Length; idx++) if (cacheaaPipMaximizer1ProfitTarget[idx].ATRperiod == aTRperiod && cacheaaPipMaximizer1ProfitTarget[idx].EqualsInput(input)) return cacheaaPipMaximizer1ProfitTarget[idx]; lock (checkaaPipMaximizer1ProfitTarget) { checkaaPipMaximizer1ProfitTarget.ATRperiod = aTRperiod; aTRperiod = checkaaPipMaximizer1ProfitTarget.ATRperiod; if (cacheaaPipMaximizer1ProfitTarget != null) for (int idx = 0; idx < cacheaaPipMaximizer1ProfitTarget.Length; idx++) if (cacheaaPipMaximizer1ProfitTarget[idx].ATRperiod == aTRperiod && cacheaaPipMaximizer1ProfitTarget[idx].EqualsInput(input)) return cacheaaPipMaximizer1ProfitTarget[idx]; aaPipMaximizer1ProfitTarget indicator = new aaPipMaximizer1ProfitTarget(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.ATRperiod = aTRperiod; Indicators.Add(indicator); indicator.SetUp(); aaPipMaximizer1ProfitTarget[] tmp = new aaPipMaximizer1ProfitTarget[cacheaaPipMaximizer1ProfitTarget == null ? 1 : cacheaaPipMaximizer1ProfitTarget.Length + 1]; if (cacheaaPipMaximizer1ProfitTarget != null) cacheaaPipMaximizer1ProfitTarget.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheaaPipMaximizer1ProfitTarget = 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 { /// /// Enter the description of your new custom indicator here /// /// [Gui.Design.WizardCondition("Indicator")] public Indicator.aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(int aTRperiod) { return _indicator.aaPipMaximizer1ProfitTarget(Input, aTRperiod); } /// /// Enter the description of your new custom indicator here /// /// public Indicator.aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(Data.IDataSeries input, int aTRperiod) { return _indicator.aaPipMaximizer1ProfitTarget(input, aTRperiod); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// /// Enter the description of your new custom indicator here /// /// [Gui.Design.WizardCondition("Indicator")] public Indicator.aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(int aTRperiod) { return _indicator.aaPipMaximizer1ProfitTarget(Input, aTRperiod); } /// /// Enter the description of your new custom indicator here /// /// public Indicator.aaPipMaximizer1ProfitTarget aaPipMaximizer1ProfitTarget(Data.IDataSeries input, int aTRperiod) { 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.aaPipMaximizer1ProfitTarget(input, aTRperiod); } } } #endregion```
 06-29-2012, 09:36 AM #6 solondon Junior Member   Join Date: Sep 2011 Posts: 14 Thanks: 1 Thanked 1 time in 1 post needed the following in Onbarupdate if (CurrentBar < 20) return; thanks for the help, cant beleive i forgot this!
 The following user says thank you to solondon for this post:
 06-29-2012, 09:40 AM #7 NinjaTrader_Bertrand NinjaTrader Customer Service     Join Date: Sep 2008 Location: Germany Posts: 22,421 Thanks: 252 Thanked 982 times in 964 posts Glad to hear it works now for you. Bertrand NinjaTrader Customer Service Use Kinetick, NinjaTrader’s preferred market data service - Learn More Free online training events - View Schedule
 The following user says thank you to NinjaTrader_Bertrand for this post:

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News and Announcements     News and Announcements Application Technical Support     ATM Strategies (Discretionary Trading)     Automated Trading     Charting     Connecting     Installation and Licensing     Market Analyzer     Miscellaneous Support         Historical Version 7 Beta Threads             Critical Information - Please review             Version 7 Beta General Questions & Bug Reports         Historical NinjaTrader 6.5 Archive             Historical NinjaTrader 6.5 Beta Threads     Strategy Analyzer     SuperDOM and other Order Entry Windows NinjaScript Development Support     General Programming     Indicator Development     Strategy Development NinjaScript Educational Resources     Reference Samples     Tips NinjaScript File Sharing     NinjaScript File Sharing Discussion     Version 7 Indicators     Version 7 Strategies     Version 7 Miscellaneous Suggestions and Feedback     Suggestions And Feedback

 Similar Threads Thread Thread Starter Forum Replies Last Post solvmatic Charting 12 12-01-2011 03:10 PM nintra Suggestions And Feedback 5 11-18-2010 09:34 AM gg80108 Version 7 Beta General Questions & Bug Reports 1 06-04-2010 09:26 AM Wessel Version 7 Beta General Questions & Bug Reports 2 04-19-2010 11:33 AM yellowTrader Indicator Development 9 03-03-2009 11:22 AM

All times are GMT -6. The time now is 03:54 PM.

 -- Fixed Width ---- Fluid Width NinjaTrader Support Forum - Archive - Top