TEMA from STOCKS & COMMODITIES - Feb-1994

The following script can be used to build the TEMA indicator referenced in the Feb 1994 edition of Stocks & Commodities magazine. This indicator needs to be applied to a Candlestick chart with the Heikin-Ashi checkbox enabled.

This script also requires Optuma 64bit as it uses features not supported in older version of Optuma / Market Analyst.

 

// ........TEMA from STOCKS & COMMODITIES --Feb-1994......
// ........HEIKIN-ASHI TEMA Crossover......
// ........55 Bars recommended but 25 Bars can also be used...
EMA1=MA(BARS=25, STYLE=Exponential, CALC=OHLC);
EMA2=MA(BARS=25, STYLE=Exponential, CALC=Close);
TEMA1=(3 * EMA1) - (3 * (MA(EMA1, BARS=25, STYLE=Exponential, CALC=OHLC))) + (MA(MA(EMA1, BARS=25, STYLE=Exponential, CALC=OHLC), BARS=25, STYLE=Exponential, CALC=OHLC));
TEMA2=(3 * EMA2) - (3 * (MA(EMA2, BARS=25, STYLE=Exponential, CALC=Close))) + (MA(MA(EMA2, BARS=25, STYLE=Exponential, CALC=Close), BARS=25, STYLE=Exponential, CALC=Close));
Plot1 = TEMA1;
Plot2 = TEMA2;
Plot1.Colour = Red;

Ex20

Thank you so much for publishing this script, as I am script ignorant :)
As an idea/request, is there any way one could post a MACD type indicator with the TEMA plotted vs. an Exponential MA and have the resulting plot in a histogram with a MA option on the histogram? Could the inputs be made as variables?
Any help/direction would be most appreciated!

André

Hi André,

To create a histogram between the TEMA and an EMA of the TEMA use the following:

 

//TEMA EMA input
$TMA=25;
//Histogram MA input
$HMA=9;

//Calc EMA
EMA1=MA(BARS=$TMA, STYLE=Exponential, CALC=Close);

//Calc TEMA 
TEMA1=(3 * EMA1) - (3 * (MA(EMA1, BARS=$TMA, STYLE=Exponential, CALC=Close))) + (MA(MA(EMA1, BARS=$TMA, STYLE=Exponential, CALC=Close), BARS=$TMA, STYLE=Exponential, CALC=Close));

//Calc Histogram and MA of Histogram
Plot1 = TEMA1 - EMA1;
Plot2 = MA(Plot1,BARS=$HMA, CALC=Close);
Plot1.Plotstyle = Histogram;
Plot2.Color = Blue;

 

Capture

You can change the inputs - currently set to 25 period for the TEMA and 9 for the MA of the histogram at the top of the script. Save the script as an indicator in a New Tool View and it will be added to your toolbox:

Capture

 

THANK YOU, Darren! You guys rock!
It's exactly what I wanted!

Copy the above formula and edit the last lines to create a signal rather than a plot. Use this for the histogram crossing above 0:

 

//TEMA EMA input
$TMA=25;
//Histogram MA input
$HMA=9;

//Calc EMA
EMA1=MA(BARS=$TMA, STYLE=Exponential, CALC=Close);
 
//Calc TEMA 
TEMA1=(3 * EMA1) - (3 * (MA(EMA1, BARS=$TMA, STYLE=Exponential, CALC=Close))) + (MA(MA(EMA1, BARS=$TMA, STYLE=Exponential, CALC=Close), BARS=$TMA, STYLE=Exponential, CALC=Close));
 
//Calc Histogram and cross of 0
Hist1 = TEMA1 - EMA1;
Hist1 CrossesAbove 0

For the cross below 0 change the last line to CrossesBelow. When the formulas are applied to separate Show Bar tools they will match the histogram tool:

Capture

Many, many thanks--this is quite useful! I appreciate all you do.

AJB

Hello Gentlemen:
Using the same formula as TEMA, but adding another dimension for a quadruple exponential moving average, would the formula below be the answer?

EMA2=MA(BARS=34, STYLE=Exponential, CALC=Close); QT=(4 * EMA2) - (4* (MA(EMA2, BARS=34, STYLE=Exponential, CALC=Close))) + (MA(MA(MA(EMA2, BARS=34, STYLE=Exponential, CALC=Close), BARS=34, STYLE=Exponential, CALC=Close), BARS=34, CALC=Close, STYLE=Exponential)); Plot2 = QT;

Lastly, plot colour was omitted. Where is there a list for colour names? I couldn’t find it. I was looking for light blue/aqua.

 

Thanks!

Hi André,

I’m not sure about the formula… is this what you are looking for?

https://www.prorealcode.com/prorealtime-indicators/quadruple-exponential-moving-average-indicator/

As for the colour, you can either use Plot2.Colour and pick from the list, or apply the tool and change it it the properties and save as default.

Capture

 

Thank you, Darren, as always!

I believe it is so. It is just one extension of TEMA, which is one extension of DEMA, etc…

No worries. Here’s the equivalent of that quadruple EMA code, but it has 5 EMAs so not sure if it’s exactly what you want:

//Quadruple EMA
//https://www.prorealcode.com/prorealtime-indicators/quadruple-exponential-moving-average-indicator/
EMA1=MA(BARS=34, STYLE=Exponential, CALC=Close); 
EMA2=MA(EMA1, BARS=34, STYLE=Exponential, CALC=Close);
EMA3=MA(EMA2, BARS=34, STYLE=Exponential, CALC=Close);
EMA4=MA(EMA3, BARS=34, STYLE=Exponential, CALC=Close);
EMA5=MA(EMA4, BARS=34, STYLE=Exponential, CALC=Close);

QEMA = 5*EMA1 - 10*EMA2 + 10*EMA3 - 5*EMA4 + EMA5; 
QEMA

Displayed in a Show Plot:

Capture