True Range Adjusted EMA

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #207411 quote
    snucke
    Participant
    Veteran

    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" );
    #207420 quote
    JS
    Participant
    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")
    #207435 quote
    JS
    Participant
    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…

    #207441 quote
    JS
    Participant
    Senior

    Hi @snucke

    You are welcome…

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

True Range Adjusted EMA


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
snucke @snucke Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by JS
3 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 01/13/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...