HighBredCloud
Well-known member
Can you please take a look at the Schaff Wave below? There's a lot more indicators combined in the script below that are not needed...What needs to be kept and working is the actual Schaff Wave I believe its STC Wave in the script and the logic needs to be to color the candles based on the color change of the actual Wave...Everything else is not needed at all...
Code:
#STSW = Schaff Trend Line and Schaff Wave Line
#Schaff Trend Line = Used for quick up/down trend declaration
#Schaff Wave Line = Trade Wave in the direction of trend as
#declared by Trend Line.
#Schaff Wave Line can be used alone to enter trend
#declared by the MACD.
#Schaff Wave can be used with the EMA for signals
declare lower;
input fastLengthTrend = 48;
input slowLengthTrend = 104;
input KPeriodTrend = 36;
input DPeriodTrend = 8;
input averageTypeTrend = AverageType.EXPONENTIAL;
input fastLengthWave = 12;
input slowLengthWave = 26;
input KPeriodWave = 9;
input DPeriodWave = 2;
input over_bought = 75;
input over_sold = 25;
input averageTypeWave = AverageType.EXPONENTIAL;
def macdTrend = MovingAverage(averageTypeTrend, close, fastLengthTrend) - MovingAverage(averageTypeTrend, close, slowLengthTrend);
def macdWave = MovingAverage(averageTypeWave, close, fastLengthWave) - MovingAverage(averageTypeWave, close, slowLengthWave);
def fastK1Trend = FastKCustom(macdTrend, KPeriodTrend);
def fastK1Wave = FastKCustom(macdWave, KPeriodWave);
def fastD1Trend = MovingAverage(averageTypeTrend, fastK1Trend, DPeriodTrend);
def fastD1Wave = MovingAverage(averageTypeWave, fastK1Wave, DPeriodWave);
def fastK2Trend = FastKCustom(fastD1Trend, KPeriodTrend);
def fastK2Wave = FastKCustom(fastD1Wave, KPeriodWave);
plot STCTrend = MovingAverage(averageTypeTrend, fastK2Trend, DPeriodTrend);
plot STCWave = MovingAverage(averageTypeWave, fastK2Wave, DPeriodWave);
plot OverBought = over_bought;
plot OverSold = over_sold;
STCTrend.SetDefaultColor(GetColor(8));
STCWave.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(7));
OverSold.SetDefaultColor(GetColor(7));
plot Fifty_Line = 50;
fifty_line.SetDefaultColor(GetColor(8));
fifty_line.HideTitle();
fifty_line.SetStyle(Curve.SHORT_DASH);
STCTrend.DefineColor("Up", GetColor(1));
STCTrend.DefineColor("Down", GetColor(0));
STCTrend.AssignValueColor(if STCTrend > STCTrend[1] then STCTrend.Color("Up") else STCTrend.Color("Down"));
STCWave.DefineColor("Up", GetColor(1));
STCWave.DefineColor("Down", GetColor(0));
STCWave.AssignValueColor(if STCWave > STCWave[1] then STCWave.Color("Up") else STCWave.Color("Down"));
input lengthWave = 10;
plot AvgExpWave = ExpAverage(STCWave, lengthWave);
AvgExpWave.SetDefaultColor(GetColor(1));
#
# Polarity
# v0.01
# 6.2.19
# Nube
#hint: This study calculates a CCI from an average of high and low pivot prices then uses that CCI and a user defined number of deviations to determine polarity. A cross above +deviations or cross below -devations signals a polarity change
# subscript for calculating the mean of pivot prices
script pivotMean{
input pivotN = 4;
input stochasticN = 21;
def h = high;
def l = low;
def norm = (close - Lowest(l, pivotN)) /
(Highest(h, pivotN) - Lowest(l, pivotN));
## Pivot High
def hh = if norm crosses above .5
then h
else if h > hh[1]
then h
else hh[1];
def hpBar = if h == hh
then BarNumber()
else Double.NaN;
def hpPrice = if !IsNaN(hpBar)
then h
else hpPrice[1];
## Pivot Low
def ll = if norm crosses below .5
then l
else if l < ll[1]
then l
else ll[1];
def lpBar = if l == ll
then BarNumber()
else Double.NaN;
def lpPrice = if !IsNaN(lpBar)
then l
else lpPrice[1];
plot
pivotMean = Average((hpPrice + lpPrice) / 2, stochasticN);
}
# Inputs
input pivotLength = 4; #hint pivotLength: Number of bars for stochastic pivot calcuation
input meanLength = 21; #hint meanLength: Number of bars to calculate mean
input deviations = 1.0;#hint deviations: Number of deviations from mean to signal a polarity change
# Variables
def mean = pivotMean(pivotLength, meanLength);
def linDev = lindev(close, meanLength);
def cci = (close - mean) / linDev;
def polarity_;
if cci crosses above deviations{
polarity_ = 1;
}else
if cci crosses below -deviations{
polarity_ = -1;
}else{
polarity_ = polarity_[1];
}
# Plots
plot
Polarity = polarity_;
Polarity.AssignValueColor(if polarity_ > 0 then Color.Green else Color.Red);
#declare lower;
# f/ Polarity
Last edited by a moderator: