# ########################################################
# TOS TEMA DEMA cloud
plot TEMA1 = TEMA("price" = close, "length" = 20);
plot DEMA2 = DEMA("price" = close, "length" = 9);
AddCloud(TEMA1, DEMA2, Color.violet, Color.orange );
# ########################################################
declare upper;
# TEMA
input price = close;
input length = 10;
def ema1 = ExpAverage(price, length);
def ema2 = ExpAverage(ema1, length);
def ema3 = ExpAverage(ema2, length);
def TEMA = 3 * ema1 - 3 * ema2 + ema3;;
plot TEMA1 = TEMA("price" = close, "length" = 10);
plot DEMA2 = DEMA("price" = close, "length" = 10);
AddCloud(TEMA1, DEMA2, Color.GREEN, Color.RED );
#input price = close;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input AverageType = {SMA, default EMA};
input MACDLevel = 0.0;
def fastCoeff = 2 / (1 + fastLength);
def slowCoeff = 2 / (1 + slowLength);
def prevFastEMA = ExpAverage(price, fastLength)[1];
def prevSlowEMA = ExpAverage(price, slowLength)[1];
def prevFastSMA = Average(price, fastLength)[1];
def prevSlowSMA = Average(price, slowLength)[1];
def prevDiff;
def crossDiff;
def denominator;
plot PMACDeq;
plot PMACDlevel;
plot MA_PMACDeq;
plot PMACDsignal;
switch (AverageType) {
case SMA:
crossDiff = slowLength * price[fastLength] - fastLength * price[slowLength];
denominator = slowLength - fastLength;
prevDiff = prevFastSMA - prevSlowSMA;
PMACDlevel = (crossDiff + fastLength * slowLength * (MACDLevel - prevDiff)) / denominator;
if IsNaN(price[1]) {
PMACDeq = Double.NaN;
MA_PMACDeq = Double.NaN;
} else {
PMACDeq = crossDiff / denominator;
MA_PMACDeq = Average(PMACDeq, MACDLength);
}
PMACDsignal = (crossDiff + fastLength * slowLength * (Average(prevDiff, MACDLength - 1) - prevDiff)) / denominator;
case EMA:
crossDiff = prevFastEMA * fastCoeff - prevSlowEMA * slowCoeff;
denominator = fastCoeff - slowCoeff;
prevDiff = prevFastEMA - prevSlowEMA;
PMACDeq = crossDiff / denominator;
PMACDlevel = (MACDLevel - prevDiff + crossDiff) / denominator;
MA_PMACDeq = ExpAverage(PMACDeq, MACDLength);
PMACDsignal = (ExpAverage(prevDiff, MACDLength) - prevDiff + crossDiff) / denominator;
}
PMACDeq.SetDefaultColor(GetColor(1));
MA_PMACDeq.SetDefaultColor(GetColor(8));
PMACDlevel.SetDefaultColor(GetColor(3));
PMACDsignal.SetDefaultColor(GetColor(5));
AddCloud(TEMA, MA_PMACDeq, Color.green, Color.red);
declare upper;
# TEMA
input price = close;
input length = 10;
plot TEMA1 = TEMA("price" = close, "length" = 10);
#input price = close;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input AverageType = {SMA, default EMA};
input MACDLevel = 0.0;
def fastCoeff = 2 / (1 + fastLength);
def slowCoeff = 2 / (1 + slowLength);
def prevFastEMA = ExpAverage(price, fastLength)[1];
def prevSlowEMA = ExpAverage(price, slowLength)[1];
def prevFastSMA = Average(price, fastLength)[1];
def prevSlowSMA = Average(price, slowLength)[1];
def prevDiff;
def crossDiff;
def denominator;
plot PMACDeq;
switch (AverageType) {
case SMA:
crossDiff = slowLength * price[fastLength] - fastLength * price[slowLength];
denominator = slowLength - fastLength;
prevDiff = prevFastSMA - prevSlowSMA;
if IsNaN(price[1]) {
PMACDeq = Double.NaN;
} else {
PMACDeq = crossDiff / denominator;
}
case EMA:
crossDiff = prevFastEMA * fastCoeff - prevSlowEMA * slowCoeff;
denominator = fastCoeff - slowCoeff;
prevDiff = prevFastEMA - prevSlowEMA;
PMACDeq = crossDiff / denominator;
}
PMACDeq.AssignValueColor(if PMACDeq > TEMA1 then color.green else color.red) ;
TEMA1.AssignValueColor(if TEMA1 > PMACDeq then color.dark_green else color.dark_red) ;
AddCloud(TEMA1, PMACDeq, Color.green, Color.red);
looks very clean. Can you share the Chart link please? Thanks.I changed the colors a bit so when I look back at monitor it looks like this:
looks very clean. Can you share the Chart link please? Thanks.
plot bullish = if UpSignal then low else double.Nan ;
plot bearish = if DwnSignal then high else double.Nan ;
plot bullish1 = if UpSignal then OBVM else double.Nan ;
plot bearis1 = if DwnSignal then OBVM else double.Nan ;
OMGosh! Totally my fault~ I feel so bad that I added to your frustration... There are no low or high candles on a lower study SO OF COURSE, THE PLOTS I GAVE YOU DON'T WORK!
There is a OBVM so lets tell it to print on OBVM
Code:plot bullish1 = if UpSignal then OBVM else double.Nan ; plot bearis1 = if DwnSignal then OBVM else double.Nan [/QUOTE]