Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Convert form 7 to 8 please. Klinger osc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Convert form 7 to 8 please. Klinger osc


    // Usage of this indicator is described at:
    // http://www.paritech.com/education/te...th/klinger.asp


    //================================================== ================================================== =
    // OpenSource code distributed under the CDDL v1.0 (http://www.opensource.org/licenses/cddl1.php)
    //================================================== ================================================== =
    //
    // Enjoy this OpenSource NinjaScript v6.0 indicator! May it help bring you great amounts of profit!

    // If you have profited from this code, then please consider a suitable donation of any amount to its
    // Initial Developer and/or other Contributors. Contact information given below.

    // Also, feel free to email enhancement suggestions to:
    // Initial Developer: SBG Trading Corp., Ben Letto, www.affordableindicators.com March 7, 2008
    //
    //================================================== ================================================== =



    #region Using declarations
    using System;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.ComponentModel;
    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>
    /// KVO
    /// </summary>
    [Description(@"http://www.paritech.com/education/technical/indicators/strength/klinger.asp")]
    [Gui.Design.DisplayName("KlingerOscillator")]
    public class KlingerOscillator : Indicator
    {
    #region Variables
    // Wizard generated variables
    private int fastPeriod = 34; // Default setting for FastPeriod
    private int slowPeriod = 55; // Default setting for SlowPeriod
    // User defined variables (add any user defined variables below)
    int Trend=0, PrevTrend;
    double cm=0.0,PrevCM,dm=0.0,PrevDM;
    DataSeries vf;
    #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.OrangeRed), PlotStyle.Line, "KO"));
    Add(new Plot(Color.FromKnownColor(KnownColor.BurlyWood), PlotStyle.Line, "Signal"));
    Add(new Line(Color.FromKnownColor(KnownColor.DarkRed), 0, "Zero"));
    CalculateOnBarClose = true;
    Overlay = false;
    PriceTypeSupported = false;
    vf = new DataSeries(this);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    { if(CurrentBar<3) return;

    if(High[0]+Low[0]+Close[0] > High[1]+Low[1]+Close[1]) Trend = 1; else Trend=-1;
    dm = High[0]-Low[0];
    if(Trend == PrevTrend) cm = PrevCM+dm; else cm = PrevDM+dm;
    if(cm != 0) vf.Set(Volume[0]*2*Math.Abs((dm/cm)-1.0)*Trend*100);
    KO.Set(EMA(vf,fastPeriod)[0] - EMA(vf,SlowPeriod)[0]);
    Signal.Set(EMA(KO,13)[0]);

    PrevTrend = Trend;
    PrevCM = cm;
    PrevDM = dm;

    }

    #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 KO
    {
    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 Signal
    {
    get { return Values[1]; }
    }

    [Description("fast ema period for volume force")]
    [Category("Parameters")]
    public int FastPeriod
    {
    get { return fastPeriod; }
    set { fastPeriod = Math.Max(1, value); }
    }

    [Description("slow ema period for volume force")]
    [Category("Parameters")]
    public int SlowPeriod
    {
    get { return slowPeriod; }
    set { slowPeriod = 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 KlingerOscillator[] cacheKlingerOscillator = null;

    private static KlingerOscillator checkKlingerOscillator = new KlingerOscillator();

    /// <summary>
    /// http://www.paritech.com/education/te...th/klinger.asp
    /// </summary>
    /// <returns></returns>
    public KlingerOscillator KlingerOscillator(int fastPeriod, int slowPeriod)
    {
    return KlingerOscillator(Input, fastPeriod, slowPeriod);
    }

    /// <summary>
    /// http://www.paritech.com/education/te...th/klinger.asp
    /// </summary>
    /// <returns></returns>
    public KlingerOscillator KlingerOscillator(Data.IDataSeries input, int fastPeriod, int slowPeriod)
    {
    checkKlingerOscillator.FastPeriod = fastPeriod;
    fastPeriod = checkKlingerOscillator.FastPeriod;
    checkKlingerOscillator.SlowPeriod = slowPeriod;
    slowPeriod = checkKlingerOscillator.SlowPeriod;

    if (cacheKlingerOscillator != null)
    for (int idx = 0; idx < cacheKlingerOscillator.Length; idx++)
    if (cacheKlingerOscillator[idx].FastPeriod == fastPeriod && cacheKlingerOscillator[idx].SlowPeriod == slowPeriod && cacheKlingerOscillator[idx].EqualsInput(input))
    return cacheKlingerOscillator[idx];

    KlingerOscillator indicator = new KlingerOscillator();
    indicator.SetUp();
    indicator.CalculateOnBarClose = CalculateOnBarClose;
    indicator.Input = input;
    indicator.FastPeriod = fastPeriod;
    indicator.SlowPeriod = slowPeriod;

    KlingerOscillator[] tmp = new KlingerOscillator[cacheKlingerOscillator == null ? 1 : cacheKlingerOscillator.Length + 1];
    if (cacheKlingerOscillator != null)
    cacheKlingerOscillator.CopyTo(tmp, 0);
    tmp[tmp.Length - 1] = indicator;
    cacheKlingerOscillator = 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>
    /// http://www.paritech.com/education/te...th/klinger.asp
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.KlingerOscillator KlingerOscillator(int fastPeriod, int slowPeriod)
    {
    return _indicator.KlingerOscillator(Input, fastPeriod, slowPeriod);
    }

    /// <summary>
    /// http://www.paritech.com/education/te...th/klinger.asp
    /// </summary>
    /// <returns></returns>
    public Indicator.KlingerOscillator KlingerOscillator(Data.IDataSeries input, int fastPeriod, int slowPeriod)
    {
    return _indicator.KlingerOscillator(input, fastPeriod, slowPeriod);
    }

    }
    }

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    public partial class Strategy : StrategyBase
    {
    /// <summary>
    /// http://www.paritech.com/education/te...th/klinger.asp
    /// </summary>
    /// <returns></returns>
    [Gui.Design.WizardCondition("Indicator")]
    public Indicator.KlingerOscillator KlingerOscillator(int fastPeriod, int slowPeriod)
    {
    return _indicator.KlingerOscillator(Input, fastPeriod, slowPeriod);
    }

    /// <summary>
    /// http://www.paritech.com/education/te...th/klinger.asp
    /// </summary>
    /// <returns></returns>
    public Indicator.KlingerOscillator KlingerOscillator(Data.IDataSeries input, int fastPeriod, int slowPeriod)
    {
    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.KlingerOscillator(input, fastPeriod, slowPeriod);
    }

    }
    }
    #endregion

    #2
    Hi Rocket, thanks for posting.

    The support team can not provide conversion service. Other members of the community will need to convert this to NinjaTrader 8.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      I actually converted a kllinger indie a while back for NT8. I dunno if it is the exact same as what you are looking for or not? If it is not, I am not interested in doing it for a different indie, but you can check it out to see if it is what you need.

      Attached is a comparison in image of the NT7 I converted from, and the comparison of the two on a chart.

      The location of the indicator is HERE.

      Click image for larger version

Name:	2020-12-20_134013.png
Views:	275
Size:	650.7 KB
ID:	1172970

      Attached Files

      Comment


        #4
        Thank you forrestang

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X