Hi!
Been exploring True Range Adjusted EMA in tradestation but i would like to try it on PRT as well, i could not find it in the library so i if someone could convert it to PRT code
https://traders.com/Documentation/FEEDbk_docs/2023/01/TradersTips.html#item1
// TASC JAN 2023
// True Range Adjusted EMA
// Vitali Apirine
inputs:
Periods( 40 ),
Pds( 40 ),
Mltp( 10 );
variables:
Mltp1( 0 ),
Mltp2( 0 ),
Rate( 0 ),
TH( 0 ),
TL( 0 ),
TR( 0 ),
TRAdj( 0 ),
TRAdjEMA( 0 );
Mltp1 = 2 / (Periods + 1);
TH = Iff(Close[1] > High, Close[1], High);
TL = Iff(Close[1] < Low, Close[1], Low);
TR = AbsValue(TH - TL);
TRAdj = (TR - Lowest(TR, Pds)) /
(Highest(TR, Pds) - Lowest(TR, Pds));
Mltp2 = TrAdj * Mltp;
Rate = Mltp1*(1 + Mltp2);
if CurrentBar = 1 then
TRAdjEMA = Close
else
TRAdjEMA = TRAdjEMA[1] + Rate *
(Close - TRAdjEMA[1]);
Plot1( TRAdjEMA, "TRAdjEMA" );
JSParticipant
Senior
Hi @snucke
Here is the indicator…
The name of the indicator is confusing because it has nothing to do with an EMA, the EMA does not appear in the code of the indicator…
What the indicator does is adjust the price (Close) to the True Range so actually a “True Range Adjusted Close”
This indicator is then compared with an EMA…
//True Range adjusted EMA
xPeriods=40
xPds=40
xMltp=10
xMltp1=2/(xPeriods+1)
If Close[1]>High then
xTH=Close[1]
Else
xTH=High
EndIf
If Close[1]<Low then
xTL=Close[1]
Else
xTL=Low
EndIf
xTR=Abs(xTH-xTL)
xTRAdj=(xTR-Lowest[xPds](xTR))/(Highest[xPds](xTR)-Lowest[xPds](xTR))
xMltp2=xTRAdj*xMltp
xRate=xMltp1*(1+xMltp2)
If BarIndex=xPds then
xTRAdjEMA=Close
Else
xTRAdjEMA=xTRAdjEMA[1]+xRate*(Close-xTRAdjEMA[1])
EndIf
Return xTRAdjEMA as "xTRAdjEMA" Coloured("Yellow")
JSParticipant
Senior
Hi @snucke
Forget the comment on the indicator…
The way the indicator is calculated follows the way of an EMA and so you can also call it that…