Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I was trying to develop an indicator that draws an up arrow under the price bar or a down arrow above the bar for when the CCI crosses above or below the 0 line. I came up with the code below so far but me not being a programmer I'm really struggling to move forward. Can anyone help me complete the indicator. I'm getting error CS1513 line 58 but I don't know how to fix it.
Thank you,
#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>
/// Draw Arrow when 50 and 14 CCI cross the zero line together
/// </summary>
[Description("Draw Arrow when 50 and 14 CCI cross the zero line together")]
public class MyCCICross : Indicator
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#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()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(CCI(14), 0, 1)
&& CrossAbove(CCI(50), 0, 1))
{
DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Lime);
}
// Condition set 2
if (CrossBelow(CCI(14), 0, 1)
&& CrossBelow(CCI(50), 0, 1))
{
DrawArrowDown("My down arrow" + CurrentBar, false, 0, 0, Color.Red);
}
#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 Plot0
{
get { return Values[0]; }
}
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = 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 MyCCICross[] cacheMyCCICross = null;
private static MyCCICross checkMyCCICross = new MyCCICross();
/// <summary>
/// Draw Arrow when 45 and 6 CCI cross the zero line together
/// </summary>
/// <returns></returns>
public MyCCICross MyCCICross(int myInput0)
{
return MyCCICross(Input, myInput0);
}
/// <summary>
/// Draw Arrow when 50 and 14 CCI cross the zero line together
/// </summary>
/// <returns></returns>
public MyCCICross MyCCICross(Data.IDataSeries input, int myInput0)
{
if (cacheMyCCICross != null)
for (int idx = 0; idx < cacheMyCCICross.Length; idx++)
if (cacheMyCCICross[idx].MyInput0 == myInput0 && cacheMyCCICross[idx].EqualsInput(input))
return cacheMyCCICross[idx];
// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
public partial class Column : ColumnBase
{
/// <summary>
/// Draw Arrow when 50 and 14 CCI cross the zero line together
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.MyCCICross MyCCICross(int myInput0)
{
return _indicator.MyCCICross(Input, myInput0);
}
/// <summary>
/// Draw Arrow when 50 and 14 CCI cross the zero line together
/// </summary>
/// <returns></returns>
public Indicator.MyCCICross MyCCICross(Data.IDataSeries input, int myInput0)
{
return _indicator.MyCCICross(input, myInput0);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Draw Arrow when 50 and 14 CCI cross the zero line together
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.MyCCICross MyCCICross(int myInput0)
{
return _indicator.MyCCICross(Input, myInput0);
}
/// <summary>
/// Draw Arrow when 45 and 6 CCI cross the zero line together
/// </summary>
/// <returns></returns>
public Indicator.MyCCICross MyCCICross(Data.IDataSeries input, int myInput0)
{
if (InInitialize && input == null)
throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
Actually Mr. Texas it is almost what I was looking for. Sorry for my poor explanation on my first trial. I wanted the Arrow to be drawn when both the 50 and 14 CCI (or 45 and 6 CCI as attached chart) crossed the 0 line at the same time. So 2 different speed CCIs cross the zero line together. It would also be nice to have the ability to change the period for both CCIs so I can try different combinations. Also nice would be to have it calculating as it happens and not only in the close of the bar. If it's possible I'd appreciate it.
Attached is a chart with a blue arrow indicating where the double cross I'm looking for is happening.
Wondering if you could add a color selectable zero line to this indicator. Never realized how accustomed my eyes have gotten to viewing that zero line on other indies.