NexusFi: Find Your Edge


Home Menu

 





Stochastic with 3 time frames input ability


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one Stocktrader with 1 posts (0 thanks)
    2. looks_two DrPatrick with 1 posts (0 thanks)
    3. looks_3 devildriver6 with 1 posts (1 thanks)
    4. looks_4 Eaglenest with 1 posts (0 thanks)
    1. trending_up 3,110 views
    2. thumb_up 1 thanks given
    3. group 4 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread

Stochastic with 3 time frames input ability

  #1 (permalink)
Eaglenest
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

Attached Thumbnails
Click image for larger version

Name:	Stocahstic 3 timeframes MT4 example.png
Views:	296
Size:	8.5 KB
ID:	237457  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 Stocktrader 
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));

Reply With Quote
  #3 (permalink)
devildriver6
Dallas, Texas
 
Posts: 43 since Jun 2015
Thanks Given: 2
Thanks Received: 32



Stocktrader View Post
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();

Reply With Quote
Thanked by:
  #4 (permalink)
 DrPatrick 
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.

Follow me on Twitter Reply With Quote




Last Updated on August 15, 2017


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts