Shizaru

Fractal Adaptive Moving Average

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
  • http://etfhq.com/blog/2010/10/09/frama-is-it-effective/
  • https://quantstrattrader.wordpress.com/2014/06/22/the-continuing-search-for-robust-momentum-indicators-the-fractal-adaptive-moving-average/
إزالة من البرامج النصية المفضلة أضف إلى البرامج النصية المفضلة
//@version=2
study("Fractal Adaptive Moving Average",shorttitle="FRAMA",overlay=true)

price = close
len = input(defval=252,minval=1)
FC = input(defval=40,minval=1)
SC = input(defval=252,minval=1)

w = log(2/(SC+1))
len1 = len/2
H1 = highest(high,len1)
L1 = lowest(low,len1)
N1 = (H1 - L1)/len1

H2 = for i = len1+1 to len
    high>high[i]?high:high[i]
    
L2 = for i = len1+1 to len
    low>low[i]?low:low[i]

N2 = (H2 - L2)/len1

H3 = highest(high,len)
L3 = lowest(low,len)
N3 = (H1 - L1)/len

dimen = (log(H1+H2) - log(H3))/log(2)
oldalpha = exp(w*(dimen-1))
oldN = (2-oldalpha)/oldalpha
newN = ((SC-FC)*(oldN-1)/(SC-1))+FC
alpha = 2/(newN+1)
out = nz(out[1])*(1-alpha) + price*alpha

plot(out,title="FRAMA")
This is quite clear on the cross in conjunction with the tenkan-sen and kijun-sen
رد
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();
رد
Shizaru IoannisRoukakianakis
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)
L2 = lowest(low,len)
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))
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) + alpha*price
plot(out,title="FRAMA",color=blue,linewidth=2,transp=0)
رد
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
رد
Shizaru IoannisRoukakianakis
pardon, there was an error in the out formula (nz(out) > nz(out) ).

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)
L2 = lowest(low,len)
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))
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) + alpha*price
plot(out,title="FRAMA",color=blue,transp=0)
رد
Shizaru Shizaru
ok I found the problem :) when I write a number between bracket here, don't why but it disappears from the message.
Just add in the formula.

out = (1-alpha)*nz(out) + alpha*price (just remove the spaces)
رد
hello can you sendme the up too script please. very useful indicator regards
رد
Thank You for sharing strategy .
رد
الصفحة الرئيسية منصة الأسهم منصًة العملات منصّة العملات الرقمية جدول الأعمال الاقتصادي برامج تعليمية كيف نعمل مميزات الرسم البياني أسعار العضوية قوانين الموقع المشرفون حلول المواقع الإلكترونية والوسطاء الأدوات حلول الرسوم البيانية مكتبة الرسوم البيانية صغيرة الحجم مركز المساعدة إحالة صديق طلب الخصائص المدوّنة والأخبار الأسئلة الأكثر شيوعًا معرفة تويتر
الملف الشخصي إعدادات الصفحة الشخصية الحساب وإعداد الفواتير إحالة صديق تذاكر الدعم الخاصة بي مركز المساعدة التحاليل المنشورة المتابعين تتابع رسالة خاصة المحادثة تسجيل الخروج