• Тинькофф Банк-лучшие банковские продукты еще выгоднее
    Выбирайте продукт от банка Тинькофф
  • Уважаемые форумчане, друзья и посетители!
    Поступило предложение ( ссылка на обсуждение ) на сбор средств поддержания форума в рабочем состоянии с 1 июня ( оплата хостинга, бэкап ежедневный на другой хостинг и тд), отчетность будет предоставляться ежемесячно. Пока на ЮMoney ( яндекс деньги), доступно картой перевод, далее добавлю другие способы. Сумму перевода указывайте на ваш выбор исходя из своих возможностей.
    Форум продолжает свою работу благодаря Вашим пожертвованиям.

STSn Индикатор

Alkor135

Member
NinjaTrader
Решил написать индикатор STSn MATRIX. Это тоже самое, что и GENESIS MATRIX, но без генезисных наворотов (только одна матрица).
Так как в программировании я не профессионал, то любая помощь приветствуется.
Для упрощения задачи решил взять за основу индикатор RGBars, который стащил с вольумтрейда. Спасибо тому, кто его там выложил!
 

Вложения

  • RGBars.zip
    2 КБ · Просмотры: 6
Т.к. индикатора TVI под NT не существует, решил начать с CCI.
Вот что получилось.
Блин, еще бы высоту подвального индикатора научиться регулировать.

Код:
#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>
    /// STSn CCI (GENESIS MATRIX CCI)
    /// </summary>
    [Description("STSn CCI (GENESIS MATRIX CCI)")]
    public class STSnCCI : Indicator
    {
        #region Variables
        // Wizard generated variables
            private int period_CCI = 20; // Default setting for Period_CCI
        // 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(new Pen(Color.FromKnownColor(KnownColor.Black),5), PlotStyle.Bar, "Plot0"));
            Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "Center0"));
            CalculateOnBarClose = false;
            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.
            Plot0.Set(1); // Значение индикатора
            if (CCI(period_CCI)[0]>0) PlotColors[0][0] = Color.Green;  // Если CCI>0 рисуем зеленым                                        
            else PlotColors[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 Period_CCI
        {
            get { return period_CCI; }
            set { period_CCI = Math.Max(1, value); }
        }
        #endregion
 

Вложения

  • STSnCCI.zip
    5,6 КБ · Просмотры: 4
Следующий Т3.
Вот, что получилось:
Код:
#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>
    /// STSn T3 (GENESIS MATRIX T3)
    /// </summary>
    [Description("STSn T3 (GENESIS MATRIX T3)")]
    public class STSnT3 : Indicator
    {
        #region Variables
        // Wizard generated variables
            private int period_T3 = 8; // Default setting for Period_T3
        // 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(new Pen(Color.FromKnownColor(KnownColor.Black),5), PlotStyle.Bar, "Plot0"));
            Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "Center0"));
            CalculateOnBarClose = false;
            Overlay                = false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if( CurrentBar < 1 ) return; //Не понял зачем эта строка, но индикатор без неё ничего не рисует
            Plot0.Set(1); //Значение индикатора
            if( T3(period_T3,3,0.7)[0] > T3(period_T3,3,0.7)[1]) PlotColors[0][0] = Color.Green; //Если Т3 восходящая, рисуем зеленым
                else PlotColors[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 Period_T3
        {
            get { return period_T3; }
            set { period_T3 = Math.Max(1, value); }
        }
        #endregion
    }
}
 

Вложения

  • STSnT3.zip
    5,8 КБ · Просмотры: 4
Ну и последний индикатор на который хватает моих знаний по программированию :wink:
Gann High Low MATRIX
Код:
#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>
    /// STSn GannHiLo (GENESIS MATRIX GHL)
    /// </summary>
    [Description("STSn GannHiLo (GENESIS MATRIX GHL)")]
    public class STSnGHL : Indicator
    {
        #region Variables
        // Wizard generated variables
        // 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(new Pen(Color.FromKnownColor(KnownColor.Black),5), PlotStyle.Bar, "Plot0"));
            Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "Center0"));
            CalculateOnBarClose = false;
            Overlay                = false;
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            Plot0.Set(1); // Значение индикатора
            if( GannHiLoActivator()[0] < Close[0] ) PlotColors[0][0] = Color.Green; //Цена выше чем GHL, рисуем зеленым
            else PlotColors[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]; }
        }
        #endregion
    }
}
 

Вложения

  • STSnGHL.zip
    5,2 КБ · Просмотры: 7
Итог на картинке.
Может кто знает как объединить все три индикатора в один подвальчик?
А ещё, у меня не получилось передать параметры для GHL чтобы можно было менять период.
2016-02-29_154350.png
 
Может кто знает как объединить все три индикатора в один подвальчик?
GКогда устанавливаете индикатор, в окне свойств есть свойство Panel. У всех трех индикаторов поставьте одну какую-нибудь панель. Они объединятся.

А ещё, у меня не получилось передать параметры для GHL чтобы можно было менять период.
Внизу скрипта в #region Properties добавьте код
Код:
        [Description("Период")]
        [GridCategory("Parameters")]
        public int Period
        {
            get { return period; }
            set { period = Math.Max(1, value); }
        }
вверху скрипта в #region Variables добавьте
Код:
private int                                period    = 14;
 
GКогда устанавливаете индикатор, в окне свойств есть свойство Panel. У всех трех индикаторов поставьте одну какую-нибудь панель. Они объединятся.
Попробовал, но они все сливаются в одну. Совсем не айс.


Внизу скрипта в #region Properties добавьте код
Код:
        [Description("Период")]
        [GridCategory("Parameters")]
        public int Period
        {
            get { return period; }
            set { period = Math.Max(1, value); }
        }
вверху скрипта в #region Variables добавьте
Код:
private int                                period    = 14;
Это я пробовал, но когда пытаюсь передать период в GannHiLoActivator, компилятор ругается.
Спасибо за вариант.
 
Назад
Верх Низ