Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
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)
Stochastic with 3 time frames input ability
Updated August 15, 2017
Stochastic with 3 time frames input ability
July 9th, 2017, 06:33 PM
Boca Raton
Posts: 1 since Jul 2017
Thanks Given: 0
Thanks Received: 0
Need to have 3 input for Stochastic in the same indicator window. Pic show is Mt4
I keep the %K and hide %D and use 3 time frames
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
July 11th, 2017, 06:22 AM
Dublin Ireland
Experience: Intermediate
Platform: Ninja, TOS
Broker: RCG Direct/Continuum
Trading: ZB
Posts: 18 since Mar 2012
Thanks Given: 4
Thanks Received: 7
Do you want 3 different period lengths for %K or do you want 3 different Aggregation periods ie Weeks, Days and Minutes?
If you just want 3 different periods see the code below: Diff Aggregations would be more complicated.
declare lower;
input over_bought = 80;
input over_sold = 20;
input KPeriod1= 10;
input KPeriod2= 7;
input KPeriod3= 3;
input priceH = high;
input priceL = low;
input priceC = close;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
def lowest_k1 = Lowest(priceL, KPeriod1);
def lowest_k2 = Lowest(priceL, KPeriod2);
def lowest_k3 = Lowest(priceL, KPeriod3);
def c1 = priceC - lowest_k1;
def c2 = priceC - lowest_k2;
def c3 = priceC - lowest_k3;
def c21 = Highest(priceH, KPeriod1) - lowest_k1;
def c22 = Highest(priceH, KPeriod2) - lowest_k2;
def c23 = Highest(priceH, KPeriod3) - lowest_k3;
def FastK1 = if c21 != 0 then c1 / c21 * 100 else 0;
def FastK2 = if c22 != 0 then c2 / c22 * 100 else 0;
def FastK3 = if c23 != 0 then c3 / c23 * 100 else 0;
plot FullK1 = MovingAverage(averageType, FastK1, slowing_period);
plot FullK2 = MovingAverage(averageType, FastK2, slowing_period);
plot FullK3 = MovingAverage(averageType, FastK3, slowing_period);
plot OverBought = over_bought;
plot OverSold = over_sold;
FullK1.SetDefaultColor(GetColor(5));
FullK2.SetDefaultColor(GetColor(0));
FullK3.SetDefaultColor(GetColor(3));
OverBought.SetDefaultColor(GetColor(1));
OverSold.SetDefaultColor(GetColor(1));
July 14th, 2017, 03:41 PM
Dallas, Texas
Posts: 43 since Jun 2015
Thanks Given: 2
Thanks Received: 32
Stocktrader
Do you want 3 different period lengths for %K or do you want 3 different Aggregation periods ie Weeks, Days and Minutes?
Here's the multiple timeframe stoch code....
declare lower;
input over_bought = 80;
input over_sold = 20;
input KPeriod = 8;
input DPeriod = 3;
input slowing_period = 3;
input averageType = AverageType.SIMPLE;
input Period1 = aggregationPeriod.FIVE_MIN;
input Period2 = aggregationPeriod.THIRTY_MIN;
input Period3 = aggregationPeriod.HOUR;
input HideK = no;
input HideD = yes;
# TF1
def T1L = low(period = Period1);
def T1H = high(period = Period1);
def T1C = close(period = Period1);
def TF1_lowest_k = Lowest(T1L, KPeriod);
def TF1_c1 = T1C - TF1_lowest_k;
def TF1_c2 = Highest(T1H, KPeriod) - TF1_lowest_k;
def TF1_FastK = if TF1_c2 != 0 then TF1_c1 / TF1_c2 * 100 else 0;
plot TF1_FullK =
if HideK then double.nan
else MovingAverage(averageType, TF1_FastK, slowing_period);
plot TF1_FullD = if HideD then double.nan
else MovingAverage(averageType, TF1_FullK, DPeriod);
# TF2
def T2L = low(period = Period2);
def T2H = high(period = Period2);
def T2C = close(period = Period2);
def TF2_lowest_k = Lowest(T2L, KPeriod);
def TF2_c1 = T2C - TF2_lowest_k;
def TF2_c2 = Highest(T2H, KPeriod) - TF2_lowest_k;
def TF2_FastK = if TF2_c2 != 0 then TF2_c1 / TF2_c2 * 100 else 0;
plot TF2_FullK =
if HideK then double.nan
else MovingAverage(averageType, TF2_FastK, slowing_period);
plot TF2_FullD = if HideD then double.nan
else MovingAverage(averageType, TF2_FullK, DPeriod);
# TF3
def T3L = low(period = Period3);
def T3H = high(period = Period3);
def T3C = close(period = Period3);
def TF3_lowest_k = Lowest(T3L, KPeriod);
def TF3_c1 = T3C - TF3_lowest_k;
def TF3_c2 = Highest(T3H, KPeriod) - TF3_lowest_k;
def TF3_FastK = if TF3_c2 != 0 then TF3_c1 / TF3_c2 * 100 else 0;
plot TF3_FullK =
if HideK then double.nan
else MovingAverage(averageType, TF3_FastK, slowing_period);
plot TF3_FullD = if HideD then double.nan
else MovingAverage(averageType, TF3_FullK, DPeriod);
# OB / OS
plot OverBought = over_bought;
plot OverSold = over_sold;
OverBought.setdefaultColor(color.WHITE);
OverBought.hidetitle();
OverBought.hidebubble();
OverSold.setdefaultColor(color.WHITE);
OverSold.hidetitle();
OverSold.hidebubble();
plot Midline = (OverBought + OverSold) / 2;
Midline.setdefaultColor(color.WHITE);
Midline.setstyle(curve.MEDIUM_DASH);
Midline.hidetitle();
Midline.hidebubble();
August 15th, 2017, 07:28 PM
Murfreesboro, TN, USA
Experience: Intermediate
Platform: ThinkorSwim
Broker: Thinkorswim
Trading: emini ES
Posts: 8 since Feb 2017
Thanks Given: 2
Thanks Received: 22
Thank you for writing and sharing this code. This fits my needs perfectly.
I was looking for a triple time frame stochastic. I use 12%k, without %d, typically on 5-2-1 minute and Daily-30-5 minute charts.
Last Updated on August 15, 2017