Premier Stochastic Oscillator

cool thanks
I added it to the bottom of the Inputs i see the aggregation was added but it doesn't work, this is what i have so far
# inputs:
input Line1 = 0.9;
input Line2 = 0.2;
input StochLength = 8;
input Period = 25;
input agg = AggregationPeriod.weeK;
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I’m missing something here In thinking something that has to do with the actual indicator, I can’t figure it out, let me know thanks
 
I looked through different codes that have MTF and it seems i need more than that 1 line of code, I had a feeling it wasn't going to be that easy
 
Once you define the agg period then you have to use it in your calculations.
Example of a price defined as closing price of a day time period
input agg = AggregationPeriod.DAY;
def price = close(period = agg);
 
Once you define the agg period then you have to use it in your calculations.
Example of a price defined as closing price of a day time period
input agg = AggregationPeriod.DAY;
def price = close(period = agg);
After this is defined is there a specific area in the code that it has to go, like in a certain order ?
 
this is all I have, and it doesn't work
/ Indicator
# // ==========================
#
# Technical Analysis of Stocks & Commodities
# August, 2008
# Premier Stochastic Oscillator by Lee Leibfarth
# pp 30 - 36
# ported by R Houser
# Changed to histogram display by Horserider 10/11/219

declare lower;

# inputs:
input Line1 = 0.9;
input Line2 = 0.2;
input StochLength = 8;
input Period = 25;
input agg = AggregationPeriod.DAY;
def price = close(period = agg);


# variables:
# oFastK(0),
# oFastD(0),
# oSlowK(0),
# oSlowD(0),
# Length(0),
# NormStoch(0),
# SmoothStoch(0),
# Premier(0);


# Value1 = Stochastic( h, l, c, StochLength, 1, 3, 1, oFastK, oFastD, oSlowK, oSlowD);
def oFastK = 100 * ( ( close - Lowest( low, StochLength ) ) / ( Highest( high, StochLength ) - Lowest( low, StochLength ) ) );
def oFastD = Average( oFastK, 1 );
def oSlowK = oFastD;
def oSlowD = Average( oSlowK, 3 );


# Length = iff(Period < 0, 1, squareroot(Period));
def Length = if Period < 0 then 1 else Sqrt( Period );


# NormStoch = .1 * (oslowK - 50);
def NormStoch = 0.1 * ( oSlowK - 50 );


# SmoothStoch = xaverage(xaverage(NormStoch, Length), Length);
def SmoothStoch = ExpAverage( ExpAverage( NormStoch, Length ), Length );


plot Premier = ( Exp( 1 * SmoothStoch ) - 1 ) / ( Exp( 1 * SmoothStoch ) + 1 );


plot pLine1 = Line1;
pLine1.SetDefaultColor( Color.BLACK );
plot pLine2 = Line2;
pLine2.SetDefaultColor( Color.GRAY );
plot nLine1 = -1 * Line1;
nLine1.SetDefaultColor( Color.BLACK );
plot nLine2 = -1 * Line2;
nLine2.SetDefaultColor( Color.GRAY );

#Premier.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Premier.SetLineWeight(3);
Premier.DefineColor("Positive and Up", Color.GREEN);
Premier.DefineColor("Positive and Down", Color.DARK_GREEN);
Premier.DefineColor("Negative and Down", Color.RED);
Premier.DefineColor("Negative and Up", Color.DARK_RED);
Premier.AssignValueColor(if Premier >= 0 then if Premier >Premier[1] then Premier.color("Positive and Up") else Premier.color("Positive and Down") else if Premier < Premier[1] then Premier.color("Negative and Down") else Premier.color("Negative and Up"));
 
First delete the line "def price = close(period = agg); " That was just an example. You need to apply the agg to the calculations of the particular study.
If you want to use the chart time as your first plot just lave as is. Copy and paste the study and apply agg to the copy. If you want two user chosen aggs you still need to plot the study twice and apply the different aggs. .......agg1 and agg2

Here is a small hint:
def oFastK = 100 * ( ( close (period = Agg)- ..................................

Sorry I do not have much interest in this study and Stochastic MTF has already been done. I will try to give you hints as you progress if needed
 
Last edited:
Looking at the TMO before and after the MTF was added and this is the only area that has been changed, is each indicator wired differently,

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input agg = AggregationPeriod.weeK;
 
Nope, it has to be used in the calculations. It is.
def o = open(period = agg);
def c = close(period = agg);

I gave you a hint in post 44
 
I'm referencing the TMO I see the difference it has to do with the open and close of the Aggr and i see it post 44, whats the next step i feel like im getting closer :)
 
I narrowed it down its this area of code and its still missing something

# // ==========================
# // PREMIER STOCHASTIC
# // Indicator
# // ==========================
#
# Technical Analysis of Stocks & Commodities
# August, 2008
# Premier Stochastic Oscillator by Lee Leibfarth
# pp 30 - 36
# ported by R Houser
#
declare lower;




# inputs:
input Line1 = 0.9;
input Line2 = 0.2;
input StochLength = 8;
input Period = 25;
input agg = AggregationPeriod.Thirty_MIN;

def o = open(period = agg);
def c = close(period = agg);




# variables:
# oFastK(0),
# oFastD(0),
# oSlowK(0),
# oSlowD(0),
# Length(0),
# NormStoch(0),
# SmoothStoch(0),
# Premier(0);
 
Nope. Look closely at the post 44 hint.
its right here but its the little things about the code language that throws me off, it confuses me because i don't know code and its so simple once you understand it

Here is a small hint:
def oFastK = 100 * ( ( close (period = Agg)- ..................................
 
Yes follow the hint. Apply agg to variables in the calculations.
If want 2 then use 2 agg inputs, agg1 and agg2 then copy calculations and apply each agg.
def oFastK = 100 * ( ( close (period = Agg1)- ..................................
def oFastK = 100 * ( ( close (period = Agg2)- ..................................
Follow through the rest of that code line and apply the agg to each variable.
 
Yes follow the hint. Apply agg to variables in the calculations.
If want 2 then use 2 agg inputs, agg1 and agg2 then copy calculations and apply each agg.
def oFastK = 100 * ( ( close (period = Agg1)- ..................................
def oFastK = 100 * ( ( close (period = Agg2)- ..................................
Follow through the rest of that code line and apply the agg to each variable.
Thanks, question (hint) Apply agg to variables in the calculations, how many variables are there if not a lot which ones are considered is there a way to identify them or just apply this to each section of code ?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
299 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top