Double Stochs for TOS - ThinkOrSwim | futures io social day trading
futures io futures trading


Double Stochs for TOS
Updated: Views / Replies:863 / 3
Created: by KySt Attachments:3

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Double Stochs for TOS

  #1 (permalink)
Elite Member
Accokeek, USA
 
Futures Experience: Beginner
Platform: NT & TOS
Favorite Futures: ES
 
Posts: 32 since Mar 2011
Thanks: 6 given, 12 received

Double Stochs for TOS

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);

PlotsConfigurable = false;
}

/// <summary>
/// </summary>
protected override void OnStartUp()
{
Plots[0].Pen.Width = plot0Width;
Plots[0].PlotStyle = plot0Style;
Plots[0].Pen.DashStyle = dash0Style;
}

/// <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;

if (r == 0)
p1.Set(CurrentBar == 0 ? 50 : p1[1]);
else
p1.Set(Math.Min(100, Math.Max(0, 100 * (Close[0] - MIN(Low, Period)[0]) / r)));

p2.Set(EMA(p1, periodEMA)[0]);

double s = MAX(p2, Period)[0] - MIN(p2, Period)[0];
s = s.Compare(0, 0.000000000001) == 0 ? 0 : s;

if (s == 0)
p3.Set(CurrentBar == 0 ? 50 : p3[1]);
else
p3.Set(Math.Min(100, Math.Max(0, 100 * (p2[0] - MIN(p2, Period)[0]) / s)));

K.Set(EMA(p3, periodEMA)[0]);

if(CurrentBar < 1)
{
PlotColors[0][0] = upColor;
return;
}
else if (Rising(K))
PlotColors[0][0] = upColor;
else
PlotColors[0][0] = downColor;
}

#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;

if (r == 0)
p1.Set(CurrentBar == 0 ? 50 : p1[1]);
else
p1.Set(Math.Min(100, Math.Max(0, 100 * (Close[0] - MIN(Low, Period)[0]) / r)));

p2.Set(EMA(p1, 3)[0]);

double s = MAX(p2, Period)[0] - MIN(p2, Period)[0];
s = s.Compare(0, 0.000000000001) == 0 ? 0 : s;

if (s == 0)
p3.Set(CurrentBar == 0 ? 50 : p3[1]);
else
p3.Set(Math.Min(100, Math.Max(0, 100 * (p2[0] - MIN(p2, Period)[0]) / s)));

K.Set(EMA(p3, 3)[0]);
}

#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();

/// <summary>
/// Double stochastics
/// </summary>
/// <returns></returns>
public DoubleStochastics DoubleStochastics(int period)
{
return DoubleStochastics(Input, period);
}

/// <summary>
/// Double stochastics
/// </summary>
/// <returns></returns>
public DoubleStochastics DoubleStochastics(Data.IDataSeries input, int period)
{
if (cacheDoubleStochastics != null)
for (int idx = 0; idx < cacheDoubleStochastics.Length; idx++)
if (cacheDoubleStochastics[idx].Period == period && cacheDoubleStochastics[idx].EqualsInput(input))
return cacheDoubleStochastics[idx];

lock (checkDoubleStochastics)
{
checkDoubleStochastics.Period = period;
period = checkDoubleStochastics.Period;

if (cacheDoubleStochastics != null)
for (int idx = 0; idx < cacheDoubleStochastics.Length; idx++)
if (cacheDoubleStochastics[idx].Period == period && cacheDoubleStochastics[idx].EqualsInput(input))
return cacheDoubleStochastics[idx];

DoubleStochastics indicator = new DoubleStochastics();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
indicator.Period = period;
Indicators.Add(indicator);
indicator.SetUp();

DoubleStochastics[] tmp = new DoubleStochastics[cacheDoubleStochastics == null ? 1 : cacheDoubleStochastics.Length + 1];
if (cacheDoubleStochastics != null)
cacheDoubleStochastics.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheDoubleStochastics = 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>
/// 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)
{
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");

return _indicator.DoubleStochastics(input, period);
}
}
}
#endregion


Much Thanks, KySt

Attached Thumbnails
Double Stochs for TOS-two-doublestochs.jpg  
Reply With Quote
 
  #2 (permalink)
1.Fibs 2.??? 3.Profit
Puerto Rico
 
Futures Experience: Intermediate
Platform: thinkorswim
Broker/Data: TD Ameritrade
Favorite Futures: ES
 
rmejia's Avatar
 
Posts: 384 since Oct 2010
Thanks: 3,597 given, 421 received


KySt View Post
I have two versions of Double Stochastics that I am overlaying in different periods on the NT platform.

Is the second double stochastics one of the default NinjaTrader indicators or custom?

Attached Thumbnails
Double Stochs for TOS-cl-03-15-800-tick-1_21_2015.jpg  
Reply With Quote
 
  #3 (permalink)
1.Fibs 2.??? 3.Profit
Puerto Rico
 
Futures Experience: Intermediate
Platform: thinkorswim
Broker/Data: TD Ameritrade
Favorite Futures: ES
 
rmejia's Avatar
 
Posts: 384 since Oct 2010
Thanks: 3,597 given, 421 received


The faster lines look like regular exponential stochastics but don't know the settings from your chart to compare:

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


 
Code
declare lower;

input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.EXPONENTIAL;

plot SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullK;
SlowK.setDefaultColor(GetColor(5));

plot SlowD = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullD;
SlowD.setDefaultColor(GetColor(0));

plot OverBought = over_bought;
OverBought.SetDefaultColor(GetColor(1));

plot OverSold = over_sold;
OverSold.SetDefaultColor(GetColor(1));



# Slow Line
input N2_Period = 21;
input R2_Period = 5;

def Ln2 = Lowest(low, N2_Period);
def Hn2 = Highest(high, N2_Period);
def Y2 = ((close - Ln2)/(Hn2 - Ln2)) * 100;
def X2 = ExpAverage(Y2, R2_period);


def Lxn = Lowest(x2, n2_period);
def Hxn = Highest(x2, n2_period);
def DSS = ((X2 - Lxn)/(Hxn - Lxn)) * 100;


def DSSb = ExpAverage(Dss, R2_period);
#DSSb.setdefaultColor(Color.GREEN);

plot DSSsignal = DSSb[1];
DSSsignal.AssignValueColor(if DSSb>DSSsignal then Color.Cyan else Color.Red);
DSSsignal.SetLineWeight(3);

Reply With Quote
The following user says Thank You to rmejia for this post:
 
  #4 (permalink)
Elite Member
Accokeek, USA
 
Futures Experience: Beginner
Platform: NT & TOS
Favorite Futures: ES
 
Posts: 32 since Mar 2011
Thanks: 6 given, 12 received

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.

-Ky

Reply With Quote

Reply



futures io > > > > Double Stochs for TOS

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Double top/Double bottom intraday in YM market AJAdio Emini Index Futures Trading 2 November 24th, 2014 09:22 PM
Double Top / Double Bottom indicator for Multicharts / Tradestation, one available? PositiveDeviant MultiCharts 12 February 15th, 2012 02:10 AM
Double bottom and Double top with DIV benbrooke NinjaTrader Programming 36 December 6th, 2011 01:29 PM
DOUBLE DOUBLE STOCHASTICS Jeff Castille The Elite Circle 112 September 5th, 2011 12:40 AM
Get the EMA of a double value??? Curbfeeler NinjaTrader Programming 4 April 9th, 2010 05:21 PM


All times are GMT -4. The time now is 11:36 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-17 in 0.14 seconds with 20 queries on phoenix via your IP 54.221.73.186