[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

here we go again cci



PureBytes Links

Trading Reference Links


using System; 
using System.Reflection; 
using System.Windows.Forms; 
using System.Diagnostics; 
using Tradevec.Base.Data; 
using System.ComponentModel; 
using System.Drawing; 
using Tradevec.Base; 
using System.Drawing; 
 
[assembly: AssemblyKeyName("")] 
 
[Description("This Indicator plots Commodity Channel Index")] 
public class CCI : Indicator 
{ 
  #region Output parameters. Don't include in this region any code except output parameters 
       [Output("CCI", Style_Line, Region_NewOne, KnownColor.Red)] public double Plot1; 
       [Output("CCI Long", Style_Line, Region_NewOne, KnownColor.Blue, PriceBox=false)] public double Plot2; 
       [Output("CCI Short", Style_Line, Region_NewOne, KnownColor.Red, PriceBox=false)] public double Plot3; 
     #endregion Output parameters 
 
    public void Main 
    ( 
          [Description("Bar Series")] BarSeries Bars, 
          [Description("Length"), DefaultValue(20)] Int32 Length, 
          [Description("CCI Long"), DefaultValue(100)] Int32 CCILong, 
          [Description("CCI Short"), DefaultValue(-100)] Int32 CCIShort, 
          [Description("CCI is in overbought territory"), DefaultValue(false)] Boolean CCIOverboughtAlert, 
          [Description("CCI is in oversold territory"), DefaultValue(false)] Boolean CCIOversoldAlert, 
          [Description("CCI has crossed over zero"), DefaultValue(false)] Boolean CCICrossedOverZeroAlert, 
          [Description("CCI has crossed under zero"), DefaultValue(false)] Boolean CCICrossedUnderZeroAlert 
 
     ) 
    { 
        if (Bars.Count <= Length)  
        { 
            Plot1 = Plot2 = Plot3 = 0; 
            CCISerie.Add(Plot1); 
        } 
        else 
        { 
            Plot1 = Functions.CCI(Bars, Length); 
            CCISerie.Add(Plot1); 
            Plot2 = CCILong; 
            Plot3 = CCIShort; 
        } 
 
        if (CCIOverboughtAlert && Plot1 > Plot2) 
            Alert("CCI is in overbought territory"); 
        else 
        if (CCIOversoldAlert && Plot1 < Plot3) 
            Alert("CCI is in oversold territory"); 
 
        if (CCICrossedOverZeroAlert && (Plot1 > 0 && CCISerie[1] <= 0))  
             Alert("CCI has crossed over zero"); 
        else if (CCICrossedUnderZeroAlert && (Plot1 < 0 && CCISerie[1] >= 0))  
             Alert("CCI has crossed under zero"); 
    } 
 
    private SimpleNumericSeries CCISerie = new SimpleNumericSeries(); 
     
}