Registered User Joined: 5/29/2014 Posts: 26
|
I have searched and found several posts on the formula for the SMI. I am looking for how to create the following conditions:
Slow - 18 Smooth 9 /Color Green
Fast - 6-15 Smooth 5 /Color Red
Any help would be really appreciated
Rod
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Most previous requests have involved four settings for each SMI indicator. I'm guessing the Smooth numbers given above are for the signal EMA period, but I'm not quite sure what the days, smoothing and double smoothing periods would be for each of these SMI indicators.
Days = ?
Smoothing Period = ?
Double Smoothing Period = ?
Signal EMA Period = ?
Stochastic Momentum Index
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 5/29/2014 Posts: 26
|
Bruce,
Thank you for your reply!
The settings provided were given to me from MetaStock settings. I have sent an Email to get clarification, but it will take time.
Is it possilbe to create a Dual Stochastic Indicator, or parts of it anyway? I have included the .ts code for what I am interested in. I am primatily interested in the SMI lines and not necessarily the line plots (I can put these in manually) or signals (unless they are possible).
Any help would be greatly appreciated. I am aware the days, smoothing and signal is defferent in this .ts code. I hope to understand it enough by studying to change later. For simplicity and so I can follow along and learn, I am interested in the .ts version. rather than origional post.
Thank You! Rod
# Dual Stochastic Momentum Indicator
declare lower;
input over_bought = 40.0;
input over_sold = -40.0;
input Mid_Line = 0;
input dlength1 = 6;
input klength1 = 15;
input dlength2 = 18;
input klength2 = 40;
script Stoch {
input percentDLength = 3;
input percentKLength = 5;
def min_low = lowest(low, percentKLength);
def max_high = highest(high, percentKLength);
def rel_diff = close - (max_high + min_low)/2;
def diff = max_high - min_low;
def avgrel = expaverage(expaverage(rel_diff, percentDLength), percentDLength);
def avgdiff = expaverage(expaverage(diff, percentDLength), percentDLength);
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
plot AvgSMI = expaverage(smi, percentDLength);
}
plot SMI1 = Stoch(dlength1, klength1);
SMI1.AssignNormGradientColor(28, SMI1.color("OverSold"), SMI1.color("OverBought"));
SMI1.DefineColor("OverBought", color.WHITE);
SMI1.DefineColor("OverSold", CreateColor(40, 25, 95));
SMI1.SetLineWeight(2);
plot SMI2 = Stoch(dlength2, klength2);
SMI2.AssignNormGradientColor(28, SMI2.color("OverSold"), SMI2.color("OverBought"));
SMI2.DefineColor("OverBought", color.WHITE);
SMI2.DefineColor("OverSold", Color.DARK_RED);
SMI2.SetStyle(Curve.SHORT_DASH);
SMI2.SetLineWeight(2);
plot overbought = over_bought;
overbought.SetDefaultColor(CreateColor(75, 75, 125));
plot oversold = over_sold;
oversold.SetDefaultColor(CreateColor(75, 75, 125));
plot MidLine = Mid_Line;
Midline.SetStyle(Curve.LONG_DASH);
MidLine.SetDefaultColor(CreateColor(75, 75, 125));
MidLine.SetLineWeight(2);
plot up25 = 25;
up25.SetStyle(Curve.SHORT_DASH);
up25.SetDefaultColor(CreateColor(90, 90, 75));
plot lw25 = -25;
lw25.SetStyle(Curve.SHORT_DASH);
lw25.SetDefaultColor(CreateColor(90, 90, 75));
plot downsignal1 = if SMI1 crosses below Stoch(dlength1, klength1).AvgSMI then SMI1 + 10 else Double.NaN;
downsignal1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
downsignal1.SetDefaultColor(CreateColor(40, 10, 150));
plot upsignal1 = if SMI1 crosses above Stoch(dlength1, klength1).AvgSMI then SMI1 - 10 else Double.NaN;
upsignal1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
upsignal1.SetDefaultColor(CreateColor(155, 155, 235));
plot downsignal2 = if SMI2 crosses below Stoch(dlength2, klength2).AvgSMI then SMI2 + 10 else Double.NaN;
downsignal2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
downsignal2.SetDefaultColor(Color.RED);
plot upsignal2 = if SMI2 crosses above Stoch(dlength2, klength2).AvgSMI then SMI2 - 10 else Double.NaN;
upsignal2.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
upsignal2.SetDefaultColor(Color.WHITE);
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I don't speak MetaStock, but as far as I can tell, it is a SMI5,3,3,3. So the following as a Custom PCF Indicator.
200 * (C - (MAXH5 + MINL5) / 2 + .5 * (3 * (C1 - (MAXH5.1 + MINL5.1) / 2) + .5 * (6 * (C2 - (MAXH5.2 + MINL5.2) / 2) + .5 * (10 * (C3 - (MAXH5.3 + MINL5.3) / 2) + .5 * (15 * (C4 - (MAXH5.4 + MINL5.4) / 2) + .5 * (21 * (C5 - (MAXH5.5 + MINL5.5) / 2) + .5 * (28 * (C6 - (MAXH5.6 + MINL5.6) / 2) + .5 * (36 * (C7 - (MAXH5.7 + MINL5.7) / 2) + .5 * (45 * (C8 - (MAXH5.8 + MINL5.8) / 2) + .5 * (55 * (C9 - (MAXH5.9 + MINL5.9) / 2) + .5 * (66 * (C10 - (MAXH5.10 + MINL5.10) / 2) + .5 * (78 * (C11 - (MAXH5.11 + MINL5.11) / 2) + .5 * (91 * (C12 - (MAXH5.12 + MINL5.12) / 2) + .5 * (105 * (C13 - (MAXH5.13 + MINL5.13) / 2) + .5 * (120 * (C14 - (MAXH5.14 + MINL5.14) / 2) + .5 * (136 * (C15 - (MAXH5.15 + MINL5.15) / 2))))))))))))))))) / (MAXH5 - MINL5 + .5 * (3 * (MAXH5.1 - MINL5.1) + .5 * (6 * (MAXH5.2 - MINL5.2) + .5 * (10 * (MAXH5.3 - MINL5.3) + .5 * (15 * (MAXH5.4 - MINL5.4) + .5 * (21 * (MAXH5.5 - MINL5.5) + .5 * (28 * (MAXH5.6 - MINL5.6) + .5 * (36 * (MAXH5.7 - MINL5.7) + .5 * (45 * (MAXH5.8 - MINL5.8) + .5 * (55 * (MAXH5.9 - MINL5.9) + .5 * (66 * (MAXH5.10 - MINL5.10) + .5 * (78 * (MAXH5.11 - MINL5.11) + .5 * (91 * (MAXH5.12 - MINL5.12) + .5 * (105 * (MAXH5.13 - MINL5.13) + .5 * (120 * (MAXH5.14 - MINL5.14) + .5 * (136 * (MAXH5.15 - MINL5.15)))))))))))))))))
With a 3-period exponential moving average added as a signal line.
Then there appear to be two regular Stochastics plotted on the chart. There is a Stochastic 15,6 and a Stochastic 40,18.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 5/29/2014 Posts: 26
|
Bruce
Thank you for your reply. I do know the 15,6 Stochastics is Fast. I assume it is:
15,16 = Period-14 %K-3 %D-3
The 5,16 STO is Slow. I assume it is:
5,16 = Period-5 %K-6 %D-1
Does this look right? Again thank you for your time and help!
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The Stochastics indicator in TC2000 version 12.4 is a full stochastics indicator. This means you can set the Period and the moving average period for a %K and the moving average period for a %D.
You can add the Stochastics indicator in TC2000 version 12.4 by selecting Add Plot to Chart (the green + in the upper left of the chart). Start typing stochastic in the search line and then select it when it gets close enough to the top of the list to see it.
In a fast stochastic, the moving average period of the %K is always 1 and in a slow stochastic, the moving average period of the %K is always 3.
Understanding Stochastics
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 5/29/2014 Posts: 26
|
Bruce, I have been studying PCF and ThinkScript for the last 2 days (16 hours) trying to understand and be able to convert to PCF. (TC2000) Please look at my two SMI examples below and tell me if I am on the right track.
Stochastic Momentum Index 5, 6, 3
200 * (5 * (XAVGC6 - (XAVG(MAXH5,6) + XAVG(MINL5,6)) / 2) - 2 * (XAVGC3 - (XAVG(MAXH5,3) + XAVG(MINL5,3)) / 2)) / (5 * (XAVG(MAXH5,6) - XAVG(MINL5,6)) - 2 * (XAVG(MAXH3, 5) - XAVG(MINL3, 5)))
Stochastic Momentum Index 4, 18, 3
200 * (17 * (XAVGC18- (XAVG(MAXH4,18) + XAVG(MINL4,18)) / 2) - 2 * (XAVGC3 - (XAVG(MAXH4,3) + XAVG(MINL4,3)) / 2)) / (17 * (XAVG(MAXH4,18) - XAVG(MINL4,18)) - 2 * (XAVG(MAXH3, 4) - XAVG(MINL3, 4)))
If correct, I do have a question and I used assumptions while scripting:
In the first part; 200*(17* (in the example above) Why not *100 and why *17? It appears the 17 is the smoothing period minus 1?
Thank you for all you do here! I really appreciate it.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The 5 and 2 in the first formula are in fact the periods of EMA6 and EMA3 minus one.
The 17 and 2 in the second formula are in fact the periods of the EMA18 and EMA3 minus one.
The reason for this is just the result of the math behind taking an EMA of another EMA when the periods of those EMAs do not match. This is explored in much greater detail in the Cascades of Moving Averages topic.
The technique cannot be used when the EMA periods match. This usually results in a much longer formula for when the EMA periods match than when the EMA periods do not match.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 5/29/2014 Posts: 26
|
"The technique cannot be used when the EMA periods match. This usually results in a much longer formula for when the EMA periods match than when the EMA periods do not match."
Interesting you said this, because that is my next script to tackle.
Thank you for your time, I really do appreciate it. I also have gained a great respect for your PCF abilities. For some reason, I find PCF hard to understand. Getting too old to learn another language :)
|