Thursday, May 21, 2009

Double your Stochastics for double the fun.






You can change the smoothing types: 1 = simple, 2 = exponential. Then watch when the indicators cross above 80, or below 20 for buy/sell signals.




declare lower;
declare all_for_one;

input smoothingType = 1;

def priceH = high;
def priceL = low;
def priceC = close;

input K1_Period = 5;
input K1_Slowing = 3;
input K2_Period = 8;
input K2_Slowing = 5;

def FastK_1 = (priceC - Lowest (priceL, K1_Period)) / (Highest(priceH, K1_Period) - Lowest (priceL, K1_Period)) * 100;
def FastK_2 = (priceC - Lowest(priceL, K2_Period)) / (Highest(priceH, K2_Period) - Lowest(priceL, K2_Period)) * 100;

plot Line20 = 20;
Line20.SetDefaultColor(Color.Red);
plot Line50 = 50;
Line50.SetDefaultColor(Color.White);
plot Line80 = 80;
Line80.SetDefaultColor(Color.Red);

plot FullK_2;
plot FullK_1;

if smoothingType == 1 then {
FullK_1 = Average(FastK_1, K1_Slowing);
FullK_2 = Average(FastK_2, K2_Slowing); }
else {
FullK_1 = ExpAverage(FastK_1, K1_Slowing);
FullK_2 = ExpAverage(FastK_2, K2_Slowing); }

FullK_1.SetDefaultColor(Color.Yellow);
FullK_1.SetLineWeight(1);
FullK_2.SetDefaultColor(Color.Green);
FullK_2.SetLineWeight(1);
blog comments powered by Disqus