#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")]
publicclass NPSqueeze : Indicator
{
#region Variables
// Wizard generated variablesprivateint length = 20; // Default setting for Lengthprivatedouble bBDev = 2; // Default setting for BBDevprivatedouble 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>protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Bar, "Squeeze"));
Overlay = false;
}
/// <summary>/// Called on each bar update event (incoming tick)/// </summary>protectedoverridevoid 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 removepublic DataSeries Squeeze
{
get { return Values[0]; }
}
[Description("BB and KC average length")]
[GridCategory("Parameters")]
publicint Length
{
get { return length; }
set { length = Math.Max(1, value); }
}
[Description("BB deviations")]
[GridCategory("Parameters")]
publicdouble BBDev
{
get { return bBDev; }
set { bBDev = Math.Max(0, value); }
}
[Description("KC deviation in ATR's")]
[GridCategory("Parameters")]
publicdouble 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;
privatestatic 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);
}
}
}
私はコードがボックスを描画し、ろうそくパターンが閉じた検出された後に一度だけテキストを印刷するために必要なものを知ることができますか?
mq4の水平線を 自分の値で作る方法。
NinjaのインジケータをMQL4, MT4に変換するのを手伝ってください。
Rgds
OK
コーダーの皆さん、こんにちは。
私は、翌日の外国為替ペアの価格を予測するためのMATLABコードを開発しました。今、私は、日付、時間、シンボル、シグナル(買い=1、売り=1、0=何もしない)を含む.csvファイルを読み取ることができるmql4の専門家が必要です。
私はあなたが私のためにそれを提供する場合、感謝されるでしょう。
ありがとう、マリアム。
二重投稿は やめましょうすでに別のスレッドを開いていたんですね。
フォーラムの一般的なルールとベストプラクティス。- 一般 - MQL5プログラミングフォーラム (2017)