TradingView
InvestitoreComune
19 maj 2016 07:43

Fractal Adaptive Moving Average 

Crude Oil FuturesNYMEX

Opis

Settings:
  • FRAMA: blue line, SC = 252, FC = 40, length = 252
  • EMA: orange line, length = 50


FRAMA seems to be the evolution of the current and much-used EMA. The basic strategy is simple: long if the price crosses up the line, short or exit if vice versa.
The main difference between EMA and FRAMA is that the first one seems to lag much more than the first one, as we can see from the chart below (crude oil daily chart)

FYI
Komentarze
Cryptocontinuum
This is quite clear on the cross in conjunction with the tenkan-sen and kijun-sen
JRA77
I was trying your script but it is somewhat different from my Sierra chart and Amibroker Frama. From what I know the final stage before the Frama calculation is the AMA, so I tried the Default settings of 16 and probably FC 2 and SC 30 but it is way different.
Here is the code from Ami which acts exactly the same with the code from Sierra. Could u give it a try

// FRAMA - Fractal Adaptive Moving Average
Price = (H+L)/2;
N = Param( "N", 16, 2, 40, 2 ); // must be even
N3 = ( HHV( High, N ) - LLV( Low, N ) ) / N;
HH = HHV( High, N / 2 ) ;
LL = LLV( Low, N / 2 );
N1 = ( HH - LL ) / ( N / 2 );
HH = HHV( Ref( High, - N/2 ), N/2 );
LL = LLV( Ref( Low, - N/2 ), N/ 2 );
N2 = ( HH - LL ) / ( N / 2 );
Dimen = IIf( N1 > 0 AND N2 > 0 AND N3 > 0, ( log( N1+N2) - log( N3 ) )/log( 2 ), Null );
alpha = exp( -4.6 * (Dimen -1 ) );
alpha = Min( Max( alpha, 0.01 ), 1 ); // bound to 0.01...1 range
Frama = AMA( Price, alpha );
Plot( Frama, "FRAMA("+N+")", ColorRGB(255,0,0), styleThick,maskAll );
_SECTION_END();
InvestitoreComune
Thank you for your comment. My FRAMA contained some errors that I've corrected in latest version, but I dont know how to modify the published script.
Here the correct code, just copypaste on a new indicator if you want to use it (default settings are FC =1, SC =198, length =16, same as Ehlers's FRAMA):

//@version=2
study("Fractal Adaptive Moving Average",shorttitle="FRAMA",overlay=true)
price = input(hl2)
len = input(defval=16,minval=1)
FC = input(defval=1,minval=1)
SC = input(defval=198,minval=1)
len1 = len/2
w = log(2/(SC+1))
H1 = highest(high,len1)
L1 = lowest(low,len1)
N1 = (H1-L1)/len1
H2 = highest(high,len)[len1]
L2 = lowest(low,len)[len1]
N2 = (H2-L2)/len1
H3 = highest(high,len)
L3 = lowest(low,len)
N3 = (H3-L3)/len
dimen1 = (log(N1+N2)-log(N3))/log(2)
dimen = iff(N1>0 and N2>0 and N3>0,dimen1,nz(dimen1[1]))
alpha1 = exp(w*(dimen-1))
oldalpha = alpha1>1?1:(alpha1<0.01?0.01:alpha1)
oldN = (2-oldalpha)/oldalpha
N = (((SC-FC)*(oldN-1))/(SC-1))+FC
alpha_ = 2/(N+1)
alpha = alpha_<2/(SC+1)?2/(SC+1):(alpha_>1?1:alpha_)
out = (1-alpha)*nz(out[1]) + alpha*price
plot(out,title="FRAMA",color=blue,linewidth=2,transp=0)
JRA77
Thank you very much for yur reply. Don't know you but really appreciate it.
I got these errors when loading on the chart


line 26: Undeclared identifier `out`;
line 26: Cannot call `nz` with arguments (type_error); available overloads: nz(integer, integer) => integer; nz(float, float) => float; nz(float, series) => series; nz(series, float) => series; nz(series, series) => series; nz(float) => float; nz(series) => series;
line 26: Cannot call `operator *` with arguments (series, type_error); available overloads: *(integer, integer) => integer; *(float, float) => float; *(float, series) => series; *(series, float) => series; *(series, series) => series;
line 26: Cannot call `operator +` with arguments (type_error, series); available overloads: +(string, string) => string; +(integer, integer) => integer; +(float, float) => float; +(float, series) => series; +(series, float) => series; +(series, series) => series; +(integer) => integer; +(float) => float; +(series) => series;
line 27: Undeclared identifier `out`;
line 27: Cannot call `plot` with arguments (type_error, literal__string, color, literal__integer, literal__integer); available overloads: plot(series, string, series__color, integer, integer, bool, integer, float, integer, bool, series, literal__bool, string) => plot
InvestitoreComune
pardon, there was an error in the out formula (nz(out) > nz(out[1]) ).

Here the correct version:

//@version=2
study("Fractal Adaptive Moving Average",shorttitle="FRAMA",overlay=true)
price = input(hl2)
len = input(defval=16,minval=1)
FC = input(defval=1,minval=1)
SC = input(defval=198,minval=1)
len1 = len/2
w = log(2/(SC+1))
H1 = highest(high,len1)
L1 = lowest(low,len1)
N1 = (H1-L1)/len1
H2 = highest(high,len)[len1]
L2 = lowest(low,len)[len1]
N2 = (H2-L2)/len1
H3 = highest(high,len)
L3 = lowest(low,len)
N3 = (H3-L3)/len
dimen1 = (log(N1+N2)-log(N3))/log(2)
dimen = iff(N1>0 and N2>0 and N3>0,dimen1,nz(dimen1[1]))
alpha1 = exp(w*(dimen-1))
oldalpha = alpha1>1?1:(alpha1<0.01?0.01:alpha1)
oldN = (2-oldalpha)/oldalpha
N = (((SC-FC)*(oldN-1))/(SC-1))+FC
alpha_ = 2/(N+1)
alpha = alpha_<2/(SC+1)?2/(SC+1):(alpha_>1?1:alpha_)
out = (1-alpha)*nz(out[1]) + alpha*price
plot(out,title="FRAMA",color=blue,transp=0)
InvestitoreComune
ok I found the problem :) when I write a number between bracket here, don't why but it disappears from the message.
Just add [ 1 ] in the formula.

out = (1-alpha)*nz(out[ 1 ]) + alpha*price (just remove the spaces)
LyonheirHoldings
hello can you sendme the up too script please. very useful indicator regards
AMBRISH
Thank You for sharing strategy .
Więcej