Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Good day coders.
I have two versions of Double Stochastics that I am overlaying in different periods on the NT platform.
Even with the same settings, they plot differently, but they accomplish my goal. TOS has a Double Stoch, but it does not mimic the precision of the NT indicators and I'd like to have the same setup in TOS
I saw\how Fattails converted a Kelter from TOS to NT; is there someone who can convert the two codes below into TOS.
There is a subtle difference between the two.
Side note: if anyone knows how to plot a MA line in TOS with the Square style from NT, that would be fantastic!
This is the code for the larger DS in the picture:
//
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Double stochastics
/// </summary>
[Description("Double Stochastics")]
[Gui.Design.DisplayName("anaDoubleStochastics")]
public class anaDoubleStochastics : Indicator
{
#region Variables
private int period = 34;
private int periodEMA = 21;
private Color upColor = Color.Blue;
private Color downColor = Color.Red;
private int plot0Width = 2;
private PlotStyle plot0Style = PlotStyle.Line;
private DashStyle dash0Style = DashStyle.Solid;
private DataSeries p1;
private DataSeries p2;
private DataSeries p3;
#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.Gray, PlotStyle.Line, "K"));
Add(new Line(Color.LightSteelBlue, 90, "Upper"));
Add(new Line(Color.LightSteelBlue, 50, "Middle"));
Add(new Line(Color.LightSteelBlue, 10, "Lower"));
Lines[0].Pen.DashStyle = DashStyle.Dash;
Lines[1].Pen.DashStyle = DashStyle.Dash;
p1 = new DataSeries(this);
p2 = new DataSeries(this);
p3 = new DataSeries(this);
#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 K
{
get { return Values[0]; }
}
[Description("Select Period for Double Stochastics")]
[GridCategory("Options")]
[Gui.Design.DisplayName("Double Stoch Period")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
[Description("Select Period for Smoothing Average")]
[GridCategory("Options")]
[Gui.Design.DisplayName("EMA Period")]
public int PeriodEMA
{
get { return periodEMA; }
set { periodEMA = Math.Max(1, value); }
}
/// <summary>
/// </summary>
[XmlIgnore()]
[Description("Select color for rising Double Stochastics")]
[Category("Plot Colors")]
[Gui.Design.DisplayName("Double Stoch Rising")]
public Color UpColor
{
get { return upColor; }
set { upColor = value; }
}
// Serialize Color object
[Browsable(false)]
public string UpColorSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(upColor); }
set { upColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
}
/// <summary>
/// </summary>
[XmlIgnore()]
[Description("Select color for falling Double Stochastics")]
[Category("Plot Colors")]
[Gui.Design.DisplayName("Double Stoch Falling")]
public Color DownColor
{
get { return downColor; }
set { downColor = value; }
}
// Serialize Color object
[Browsable(false)]
public string DownColorSerialize
{
get { return NinjaTrader.Gui.Design.SerializableColor.ToString(downColor); }
set { downColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
}
/// <summary>
/// </summary>
[Description("Width for Double Stochastics.")]
[Category("Plot Parameters")]
[Gui.Design.DisplayNameAttribute("Line Width")]
public int Plot0Width
{
get { return plot0Width; }
set { plot0Width = Math.Max(1, value); }
}
/// <summary>
/// </summary>
[Description("DashStyle for Double Stochastics")]
[Category("Plot Parameters")]
[Gui.Design.DisplayNameAttribute("Plot Style")]
public PlotStyle Plot0Style
{
get { return plot0Style; }
set { plot0Style = value; }
}
/// <summary>
/// </summary>
[Description("DashStyle for Double Stochastics")]
[Category("Plot Parameters")]
[Gui.Design.DisplayNameAttribute("Dash Style")]
public DashStyle Dash0Style
{
get { return dash0Style; }
set { dash0Style = value; }
}
#endregion
}
}
#region NinjaScript generated code. Neither change nor remove.
This is the code for the two, faster DS' in the the picture:
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Double stochastics
/// </summary>
[Description("Double stochastics")]
[Gui.Design.DisplayName("DoubleStochastics")]
public class DoubleStochastics : Indicator
{
#region Variables
private int period = 10;
private DataSeries p1;
private DataSeries p2;
private DataSeries p3;
#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.Red, PlotStyle.Line, "K"));
Add(new Line(Color.Blue, 90, "Upper"));
Add(new Line(Color.Blue, 10, "Lower"));
Lines[0].Pen.DashStyle = DashStyle.Dash;
Lines[1].Pen.DashStyle = DashStyle.Dash;
p1 = new DataSeries(this);
p2 = new DataSeries(this);
p3 = new DataSeries(this);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
double r = MAX(High, Period)[0] - MIN(Low, Period)[0];
r = r.Compare(0, 0.000000000001) == 0 ? 0 : r;
#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 K
{
get { return Values[0]; }
}
[Description("")]
[GridCategory("Parameters")]
public int Period
{
get { return period; }
set { period = 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 DoubleStochastics[] cacheDoubleStochastics = null;
private static DoubleStochastics checkDoubleStochastics = new DoubleStochastics();
// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
public partial class Column : ColumnBase
{
/// <summary>
/// Double stochastics
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.DoubleStochastics DoubleStochastics(int period)
{
return _indicator.DoubleStochastics(Input, period);
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Double stochastics
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.DoubleStochastics DoubleStochastics(int period)
{
return _indicator.DoubleStochastics(Input, period);
}
/// <summary>
/// Double stochastics
/// </summary>
/// <returns></returns>
public Indicator.DoubleStochastics DoubleStochastics(Data.IDataSeries input, int period)
{
if (InInitialize && input == null)
throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
Thanks Rmejia.
The slow stochastic with my settings is perfect.
Its behavior is like that of the anaDoubleStochastic in NT.
The mid and faster lines, not so much.
They are true EMA double stochastics. Only need ofor TOS that has the same behavior as that of NT.