Converting a Ninja Trader indicator to mql4.

 

Hello, I have an indicator writing for Ninja Trader platform, and I would like to convert it to use in my Mt4 platform.. Is it possible?

I don`t know so much about programming, so I`m asking for help, if it is possible and someone is able to help me, if it is not so hard, I would be very very appreciate.

 

I`m doing my best in trying to write copying from the CSV file (Ninja Trader) to the mql4 language, but I`m not having success...

 Again, if someone is able to help me, I would be very thankful, and still trying to do it for my own knowing...

 

I attached the CSV file in my post..

 

Thank you

Angelo. 

Files:
 
mrangelo:

Hello, I have an indicator writing for Ninja Trader platform, and I would like to convert it to use in my Mt4 platform.. Is it possible?

I don`t know so much about programming, so I`m asking for help, if it is possible and someone is able to help me, if it is not so hard, I would be very very appreciate.

 

I`m doing my best in trying to write copying from the CSV file (Ninja Trader) to the mql4 language, but I`m not having success...

 Again, if someone is able to help me, I would be very thankful, and still trying to do it for my own knowing...

 

I attached the CSV file in my post..

No file attached.
 

Oops!..I`m sorry, I forgot to zip it.. 

It`s updated now.

 

Thank you. 

 
@mrangelo: sorry, we help people learn how-to code in mql4. If you're looking for someone to code-examples and give it to you, then you're in the wrong place. Someone in the jobs section could convert this for you. If you're interested in converting this yourself then you'll have to learn mql4. I recommend the book, article, code-base.
 

Thank you.

I`m already reading the books and articles about mql4, some things I can do, but some things are still complicated to me.

Anyway, thanks for replying, I`ll continue to try, if some (more) doubts come, sure I`ll ask for help.

 

Thank you again. 

 
mrangelo: indicator writing for Ninja Trader platform, and I would like to convert it to use in my Mt4 platform.. Is it possible?

First you'll have to create an offline renko chart - mq4 only has time based chart. - search

If that code isn't just the cci, you'll have to translate that code to mql4 - they'll have to know both languages.

If that code (I didn't look at it closely) just shows the cci - look in your mq4 indicators or in the codebase for the cci.

 
WHRoeder:

First you'll have to create an offline renko chart - mq4 only has time based chart. - search

If that code isn't just the cci, you'll have to translate that code to mql4 - they'll have to know both languages.

If that code (I didn't look at it closely) just shows the cci - look in your mq4 indicators or in the codebase for the cci.


I have already the offline renko chart in the mt4.

 The code just shows the CCI, but instead of showing the current CCI point, it shows the possible high and low until the next candle open, I mean, when the CCI reach one of these points, as it works with renko bars, the next candle will open, consequently the next point of CCI, and so on.

So I put it overloaded with the native CCI and get the point where the current CCI is, and the possible high and low. 

 

Please i need some assistance with converting this Ninja indicator to MQL4. (NPSqueeze Bandwith histogram indicator)

Will appreciate and thanks in advance.

#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>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class NPSqueeze : Indicator
    {
        #region Variables
        // Wizard generated variables
            private int length = 20; // Default setting for Length
            private double bBDev = 2; // Default setting for BBDev
            private double kCDev = 1.5; // Default setting for KCDev
        // 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.Bar, "Squeeze"));
            Overlay                             = false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        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.
                        double value = Bollinger(bBDev,length).Upper[0]-KeltnerChannel(kCDev,length).Upper[0] ;
            Squeeze.Set(value);
        }

        #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 Squeeze
        {
            get { return Values[0]; }
        }

        [Description("BB and KC average length")]
        [GridCategory("Parameters")]
        public int Length
        {
            get { return length; }
            set { length = Math.Max(1, value); }
        }

        [Description("BB deviations")]
        [GridCategory("Parameters")]
        public double BBDev
        {
            get { return bBDev; }
            set { bBDev = Math.Max(0, value); }
        }

        [Description("KC deviation in ATR's")]
        [GridCategory("Parameters")]
        public double KCDev
        {
            get { return kCDev; }
            set { kCDev = Math.Max(0, 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 NPSqueeze[] cacheNPSqueeze = null;

        private static NPSqueeze checkNPSqueeze = new NPSqueeze();

        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public NPSqueeze NPSqueeze(double bBDev, double kCDev, int length)
        {
            return NPSqueeze(Input, bBDev, kCDev, length);
        }

        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public NPSqueeze NPSqueeze(Data.IDataSeries input, double bBDev, double kCDev, int length)
        {
            if (cacheNPSqueeze != null)
                for (int idx = 0; idx < cacheNPSqueeze.Length; idx++)
                    if (Math.Abs(cacheNPSqueeze[idx].BBDev - bBDev) <= double.Epsilon && Math.Abs(cacheNPSqueeze[idx].KCDev - kCDev) <= double.Epsilon && cacheNPSqueeze[idx].Length == length && cacheNPSqueeze[idx].EqualsInput(input))
                        return cacheNPSqueeze[idx];

            lock (checkNPSqueeze)
            {
                checkNPSqueeze.BBDev = bBDev;
                bBDev = checkNPSqueeze.BBDev;
                checkNPSqueeze.KCDev = kCDev;
                kCDev = checkNPSqueeze.KCDev;
                checkNPSqueeze.Length = length;
                length = checkNPSqueeze.Length;

                if (cacheNPSqueeze != null)
                    for (int idx = 0; idx < cacheNPSqueeze.Length; idx++)
                        if (Math.Abs(cacheNPSqueeze[idx].BBDev - bBDev) <= double.Epsilon && Math.Abs(cacheNPSqueeze[idx].KCDev - kCDev) <= double.Epsilon && cacheNPSqueeze[idx].Length == length && cacheNPSqueeze[idx].EqualsInput(input))
                            return cacheNPSqueeze[idx];

                NPSqueeze indicator = new NPSqueeze();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.BBDev = bBDev;
                indicator.KCDev = kCDev;
                indicator.Length = length;
                Indicators.Add(indicator);
                indicator.SetUp();

                NPSqueeze[] tmp = new NPSqueeze[cacheNPSqueeze == null ? 1 : cacheNPSqueeze.Length + 1];
                if (cacheNPSqueeze != null)
                    cacheNPSqueeze.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheNPSqueeze = 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>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.NPSqueeze NPSqueeze(double bBDev, double kCDev, int length)
        {
            return _indicator.NPSqueeze(Input, bBDev, kCDev, length);
        }

        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public Indicator.NPSqueeze NPSqueeze(Data.IDataSeries input, double bBDev, double kCDev, int length)
        {
            return _indicator.NPSqueeze(input, bBDev, kCDev, length);
        }
    }
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public partial class Strategy : StrategyBase
    {
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.NPSqueeze NPSqueeze(double bBDev, double kCDev, int length)
        {
            return _indicator.NPSqueeze(Input, bBDev, kCDev, length);
        }

        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public Indicator.NPSqueeze NPSqueeze(Data.IDataSeries input, double bBDev, double kCDev, int length)
        {
            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.NPSqueeze(input, bBDev, kCDev, length);
        }
    }
}
Reason: