The Fractal Adaptive Moving Average FRAMA was developed by John Ehlers.
The indicator is constructed on the EMA exponential moving average algorithm, with a smoothing factor calculated on the basis of the current fractal dimension of the price.
The advantage of the indicator is the ability to track strong trend movements and market consolidation moments.
Interpretation Trading Signals And Rules:
The interpretation of the indicator is identical to the interpretation of moving averages
_ The FRAMA line is relatively “flat” in periods of horizontal range trading. It could therefore be used to avoid many false signals when it is desired to use a technique of the crossing of moving averages.
_ The FRAMA line has a greater reactivity to changes in trends than moving averages, making it possible to take a much earlier position on a breakout of the horizontal channel.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
// FRAMA //p = 20 pri=Customclose len=p N3=(Highest[len](High)-Lowest[len](Low))/len mH=High L=Low For count=0 To len/2-1 If High[count] > mH Then mH=High[count] Endif If Low[count] < L Then L=Low[count] Endif Next N1=(mH-L)/(len/2) HH=High[len/2] LL=Low[len/2] For count=len/2 To len-1 If High[count] > HH Then HH=High[count] Endif If Low[count] < LL Then LL=Low[count] Endif Next N2=(HH-LL)/(len/2) If N1 > 0 And N2 > 0 And N3 > 0 Then Dimen=(Log(N1+N2)-Log(N3))/Log(2) Endif alpha=Exp(-4.6*(Dimen-1)) If alpha < 0.01 Then alpha=0.01 Endif If alpha > 1 Then alpha=1 Endif Filt=alpha*pri+(1-alpha)*Filt[1] If Barindex < len+1 Then Filt=pri Endif Return Filt as "FRAMA" |
original code from gigi @ http://www.aktienboard.com/forum/f29/prorealtime-cmc-script-programmierung-t94783/215#post2035965
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
hi
i will use it to see … and get back to tell ya
Ciao Nicolas. Approfitto di questo spazio per chiederti se puoi aiutarmi. Avrei bisogno di un codice che sommi in tempo reale sul grafico tick by tick tutti i volumi in intraday che vengono scambiati su ogni livello di prezzo e che venga plottato sul grafico il livello dove in quel momento si stanno scambiando più contratti. Allego un esempio dove ho messo le frecce azzurre per indicare i volumi in real time plottati sul grafic.
Grazie.
Luigi
Si prega di utilizzare i forum per chiedere richieste di codice per favore.
Hi Nicolas!,
Thanks for providing code for the FRAMA! If I have understood correctly, one should enter both minimum MAperiod and maximum MAperiod for the adaptive process. I am uncertain if your code provides for this. If so could you tell which variables hold these values, please?
Kind regards,
Wilko
Hi, Wilko. Acc to the original FRAMA paper by Ehlers, Ehler’s own code only takes inputs for price and N (respectively, pri and len in Nicholas’ code above). If I follow the code, then I think it adaptively generates its own min and max periods, and the N value is only intended for your desired level of smoothing, not a fixed period for calculating the MA.
For reference, here is Ehlers’ original paper:
http://www.mesasoftware.com/papers/FRAMA.pdf
And for anyone interested in tweaking this, ETFHQ wrote an article on adjusting the constant w, which in the code above is hardcoded as a value of -4.6. By allowing two new variables FC and SC, you can set the fast and slow averages used to calculate the FRAMA.
http://etfhq.com/blog/2010/09/30/fractal-adaptive-moving-average-frama/#Mod
I am only smart enough to edit in the ability to set your own slow average (variable sc), so the fc is still set to the original default of 1.
Here is the code with only SC included, per ETFHQ.
pri=customclose
//len>=4, even
once len=p
once w=2.303*log(2/(sc+1))
//once w=-4.61015 equivalent to sc=200
N3=(Highest[len](High)-Lowest[len](Low))/len
mH=High
L=Low
For count=0 To len/2-1
If High[count] > mH Then
mH=High[count]
Endif
If Low[count] HH Then
HH=High[count]
Endif
If Low[count] 0 And N2 > 0 And N3 > 0 Then
Dimen=(Log(N1+N2)-Log(N3))/Log(2)
Endif
alpha=Exp(w*(Dimen-1))
If alpha 1 Then
alpha=1
Endif
Filt=alpha*pri+(1-alpha)*Filt[1]
If Barindex < len+1 Then
Filt=pri
Endif
Return Filt as "FRAMA"