NexusFi: Find Your Edge


Home Menu

 





CCI Cross Zero Line Indicator


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one ThatManFromTexas with 4 posts (15 thanks)
    2. looks_two yiman with 3 posts (2 thanks)
    3. looks_3 Senna with 3 posts (1 thanks)
    4. looks_4 trs3042 with 2 posts (0 thanks)
      Best Posters
    1. looks_one ThatManFromTexas with 3.8 thanks per post
    2. looks_two wldman with 1 thanks per post
    3. looks_3 yiman with 0.7 thanks per post
    4. looks_4 Senna with 0.3 thanks per post
    1. trending_up 13,137 views
    2. thumb_up 19 thanks given
    3. group 5 followers
    1. forum 13 posts
    2. attach_file 6 attachments




 
Search this Thread

CCI Cross Zero Line Indicator

  #1 (permalink)
 Senna 
Los Angeles, CA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, 6E, TF
Posts: 8 since Feb 2010
Thanks Given: 2
Thanks Received: 4

Hi guys,

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];

lock (checkMyCCICross)
{
checkMyCCICross.MyInput0 = myInput0;
myInput0 = checkMyCCICross.MyInput0;

if (cacheMyCCICross != null)
for (int idx = 0; idx < cacheMyCCICross.Length; idx++)
if (cacheMyCCICross[idx].MyInput0 == myInput0 && cacheMyCCICross[idx].EqualsInput(input))
return cacheMyCCICross[idx];

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

MyCCICross[] tmp = new MyCCICross[cacheMyCCICross == null ? 1 : cacheMyCCICross.Length + 1];
if (cacheMyCCICross != null)
cacheMyCCICross.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheMyCCICross = 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>
/// 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");

return _indicator.MyCCICross(input, myInput0);
}
}
}
#endregion

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Exit Strategy
NinjaTrader
Are there any eval firms that allow you to sink to your …
Traders Hideout
NexusFi Journal Challenge - April 2024
Feedback and Announcements
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
38 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
  #3 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,348


@NickFaria
... ask and yea shall receive ...


TMFTCCIwArrows.zip


I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
  #4 (permalink)
 Senna 
Los Angeles, CA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, 6E, TF
Posts: 8 since Feb 2010
Thanks Given: 2
Thanks Received: 4

That's it. Thank you Mr Texas.

Started this thread Reply With Quote
  #5 (permalink)
 Senna 
Los Angeles, CA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG
Trading: ES, 6E, TF
Posts: 8 since Feb 2010
Thanks Given: 2
Thanks Received: 4

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.

Thank you again,

Nick Faria

Attached Thumbnails
Click image for larger version

Name:	Double CCI Cross.JPG
Views:	462
Size:	266.2 KB
ID:	39626  
Started this thread Reply With Quote
  #6 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,348


NickFaria View Post
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.

Thank you again,

Nick Faria



TMFTCCIwArrowsv2.zip

Updated 11:19 Central

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
Thanked by:
  #7 (permalink)
 
trs3042's Avatar
 trs3042 
Holland, Michigan
 
Experience: None
Platform: ninjatrader
Broker: CQG
Trading: Acoustic Guitar
Posts: 1,617 since Jun 2009
Thanks Given: 23,764
Thanks Received: 5,616


ThatManFromTexas View Post
Attachment 39638

Attachment 39640

Updated 11:19 Central

Hello @TMFT,

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.

TIA,

Rick

Attached Files
Elite Membership required to download: TMFTCCIwArrowsv2.zip
Reply With Quote
  #8 (permalink)
 
ThatManFromTexas's Avatar
 ThatManFromTexas 
Houston,Tx
 
Experience: Advanced
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: TF
Posts: 2,265 since Feb 2010
Thanks Given: 1,206
Thanks Received: 4,348


trs3042 View Post
Hello @TMFT,

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.

TIA,

Rick

Do you want it to do anything besides show color? In the past I wrote different versions that would show EMA Slope, Moving average Cross overs, etc.

Look through Jeff Castille's thread on the CCI. There are lots of examples there.

Let me know.

Regards,
TMFT

I'm just a simple man trading a simple plan.

My daddy always said, "Every day above ground is a good day!"
Reply With Quote
Thanked by:
  #9 (permalink)
 
trs3042's Avatar
 trs3042 
Holland, Michigan
 
Experience: None
Platform: ninjatrader
Broker: CQG
Trading: Acoustic Guitar
Posts: 1,617 since Jun 2009
Thanks Given: 23,764
Thanks Received: 5,616


ThatManFromTexas View Post
Do you want it to do anything besides show color? In the past I wrote different versions that would show EMA Slope, Moving average Cross overs, etc.

Look through Jeff Castille's thread on the CCI. There are lots of examples there.

Let me know.

Regards,
TMFT

Just color would be fine.

Thanks,

Rick

Reply With Quote
  #10 (permalink)
 yiman 
London
 
Experience: Intermediate
Platform: ninjatrader, multicharts, MT4
Broker: IB, PFG Best
Trading: 6E, EMD, TF
Posts: 265 since Jul 2009
Thanks Given: 111
Thanks Received: 158



ThatManFromTexas View Post
@NickFaria
... ask and yea shall receive ...


Attachment 39617

Attachment 39618

Thanks TMFT just what i was looking for

Reply With Quote
Thanked by:




Last Updated on August 23, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts