# ########################################################
# 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]
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
R | Need help creating this weekly ATR into Monthly ATR | Questions | 2 | |
Need help creating a scan for above ORH and ORL | Questions | 3 | ||
Need help creating a Smart Exponential MA Indicator | Questions | 5 | ||
P | Need help creating premarket scanner based on daily ATR | Questions | 1 | |
T | I need help creating a watchlist | Questions | 1 |
Start a new thread and receive assistance from our community.
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.
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.