Moving Average Difference Indicator – J. Ehlers

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #180141 quote
    BF___
    Participant
    Junior
    Convert to  ProCODE
    {
    	MAD (Moving Average Difference) Indicator
    	(C) 2021 John F. Ehlers
    }
    
    Inputs:
    	ShortLength(8),
    	LongLength(23);
    	
    Vars:
    	MAD(0);
    
    MAD = 100*(Average(Close, ShortLength) - Average(Close, LongLength)) / Average(Close, LongLength);
    
    Plot1(MAD, "", red, 4, 4);
    Plot2(0,"", white, 1, 1);
    #180150 quote
    Nicolas
    Keymaster
    Master

    Ok lo farò, ma per favore la prossima volta aggiungi una descrizione completa e uno screenshot del codice originale, mi aiuta molto e velocizza il processo di conversione! Questo codice è probabilmente una normalizzazione di un MACD.

    #180152 quote
    Nicolas
    Keymaster
    Master

    Ecco il codice tradotto e compatibile con ProRealTime per "Moving Average Difference Indicator – J. Ehlers"

    ShortLength=8
    LongLength=23
    
    MAD = 100*(Average[ShortLength] - Average[LongLength]) / Average[LongLength]
    
    RETURN MAD coloured(255,0,0) style(line,4), 0  
    Moving-Average-Difference-Indicator-–-J.-Ehlers.png Moving-Average-Difference-Indicator-–-J.-Ehlers.png
    #180158 quote
    BF___
    Participant
    Junior

    ok, grazie mille davvero! ti invio anche l’evoluzione di questo codice che si chiama MADH

    #180187 quote
    BF___
    Participant
    Junior
    {
    	MADH (Moving Average Difference - Hann) Indicator	
    	(C) 2021 John F. Ehlers
    }
    
    Inputs:
    	ShortLength(8),
    	DominantCycle(27);
    	
    Vars:
    	LongLength(20),
    	Filt1(0),
    	Filt2(0), 
    	coef(0),
    	count(0),
    	MADH(0);
    	
    LongLength = IntPortion(ShortLength + DominantCycle / 2);
    
    Filt1 = 0;
    coef = 0;
    For count = 1 to ShortLength Begin
    	Filt1 = Filt1 + (1 - Cosine(360*count / (ShortLength + 1)))*Close[count - 1];
    	coef = coef + (1 - Cosine(360*count / (ShortLength + 1)));
    End;
    If coef <> 0 Then Filt1 = Filt1 / coef;
    
    Filt2 = 0;
    coef = 0;
    For count = 1 to LongLength Begin
    	Filt2 = Filt2 + (1 - Cosine(360*count / (LongLength + 1)))*Close[count - 1];
    	coef = coef + (1 - Cosine(360*count / (LongLength + 1)));
    End;
    If coef <> 0 Then Filt2 = Filt2 / coef;
    
    //Computed as percentage of price
    If Filt2 <> 0 Then MADH = 100*(Filt1 - Filt2) / Filt2;
    
    Plot1(MADH, "", yellow, 4, 4);
    Plot2(0, "", white, 1, 1);
       
    #180194 quote
    robertogozzi
    Moderator
    Master

    Eccolo:

    // MADH indicator
    //
    // (MAD Enhanced by John Ehlers)
    //
    // https://www.tradingview.com/script/vraaRpAA-TASC-2021-11-MADH-Moving-Average-Difference-Hann/
    //
    Source       = close
    ShortLen     = 8
    DomCycle     = 27
    LongLen      = round((DomCycle * 0.5) + ShortLen)
    PI           = 3.14159//26535897932
    PIx2LongLen  = PI * 2.0 / (LongLen  + 1)
    PIx2ShortLen = PI * 2.0 / (ShortLen + 1)
    filt1        = 0
    coefs        = 0
    FOR count = 1 TO ShortLen
       coefHann = 1 - cos(count * PIx2ShortLen)
       filt1    = filt1 + (coefHann * source[count - 1])
       coefs    = coefs + coefHann
    NEXT
    filt1       = filt1 / coefs
    filt2       = 0
    coefs       = 0
    FOR count = 1 TO LongLen
       coefHann = 1 - cos(count * PIx2LongLen)
       filt2    = filt2 + (coefHann * source[count - 1])
       coefs    = coefs + coefHann
    NEXT
    filt2       = filt2 / coefs
    MadH        = (filt1 - filt2) / filt2 * 100
    RETURN MadH AS "MADH"
    x-11.jpg x-11.jpg MADH-indicator.itf
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Moving Average Difference Indicator – J. Ehlers


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
BF___ @bf___ Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by robertogozzi
4 years, 4 months ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 10/22/2021
Status: Active
Attachments: 3 files
Logo Logo
Loading...