Grafigindeki sistem formulunu özelden gönder bir bakayım....
Hata varsa formulumde, modifiye edeyim...
Printable View
sayın uufuk ema için linkteki dökümanda sizinkinden biraz farklı bir yaklaşım var, aradığınıza çözüm olabilir mi diye paylaşıyorum.
Step 2: The Logic
Start with the initial values that will not change. The time interval is fixed but assigned to a variable. Alpha is also fixed but still needs to be calculated:
tp:= 40; {EMA time periods}
alpha:= 2 / (tp +1);
Next, the formula to identify the start of a new time period should be done. This is best near the top so it is easily changed allowing the basic logic of a formula to be reused with just minor 78changes. The formula for an hourly extrapolation will look for
a change in the value of the Hour() function. Since the 5 minute interval is where the formula will be applied and 5 minutes is evenly divisible into 60 minutes, this extrapolation is possible. The same logic for a daily extrapolation can be used. Just change the DayOfWeek() function to the Hour() function:
new:=ROC(Hour(),1,$)<>0;
This identifies when a new hour starts. However, the average needs to use the Close of the previous hour for the calculation. So, each time new is true, the Ref() function is used to get the previous bar’s close for the new value in the average. If new is not
true, use PREV to “remember†the last value of the average. This same PREV is used for the value of the average from the previous interval to calculate the next of the average:
EMA:= If( new, ( Ref(C, -1) * alpha) + ( PREV * (1-alpha)), PREV);
However, this calculation does not seed the average with the close of the first hour in the chart. PREV has the value of zero at the start of the chart. This means the value of EMA will start at zero and slowly increase over the next several hours before it
gets to a value close to what the prices are. Typically, this would take one to two times the length of the average. To avoid that, the average can be assigned a value to start with. This seed value will then be used by PREV as a jump-start, instead of the value of zero.To seed the average, another If() must be combined with the first. When new is true, this If() is checked first and can only be true on the first hour of the chart. The Cum() function can be used to count the number of times new has been TRUE:
EMA:= If
( new, If( Cum( new ) = 1, Ref(C, -1),
( Ref(C, -1) * alpha) + ( PREV * (1-alpha))), PREV);
Step 3: The Final FormulaNow all that remains is to call the EMA variable so the formula will plot the value. The final formula should look something like this:
tp:= 40; {EMA time periods}
new:=ROC(Hour(),1,$)<>0;
alpha:= 2 / (tp +1);
EMA:=
If
( new, If( Cum( new ) = 1, Ref(C, -1),
( Ref(C, -1) * alpha) + ( PREV * (1-alpha)), PREV));
EMA
bu ilgili dökümanın linki sayfa 80
https://www.metastock.com/customer/r..._Primer_II.pdf
matriks için denemedim çalışır mı fikrim yoktur. saygılar
Dostumuz,sagolsun özelden formulunu gönderdi...
Tahmin ettigim gibi formulun nihayi kararı > < = => <= operatorleriyle saptanıyordu...
Formulumde gerekli düzeltmeyi yaptım ama önce hatanın sebebini açıklayacagım...
Cross(Data1,Data2) mevcut iki datanın kesişmesi yani kıyası yapılırken degişim anını yakalar...
Tek degişim anında sinyal uyarı verir, ama > < = => <= sürekli deger üretir...
al:=Mov(C,13,S)>Mov(C,50,S);
sat:=Mov(C,13,S)<Mov(C,50,S);
al;sat
Dostumuzun sistemi bu temelli,Metastock ve Matriks karşılaştırması ....
https://i.hizliresim.com/rJq0N1.png
https://i.hizliresim.com/JO5Vzj.png
Hatamızın nedeni, kendi sistem hesaplarında kullandıgı "IS DEFİNED" fonksiyonunu indikator yazılımda bize kullandırtmaması...Çözüm bir sonraki mesajda ....
AL_SAT kararı Cross ile verilen örnek...
https://i.hizliresim.com/ROa8gG.png
https://i.hizliresim.com/6y4pMN.png
AL_SAT kararı > < >= <= = ile verilen örnek...
https://i.hizliresim.com/vJ0AyO.png
https://i.hizliresim.com/Qpk8zV.png
islemTipi:=Input("Alsat1 Tum0",0,1,1); ---->İŞLEM TİPİ
n:=50; --------------------------------------->FORMULUMUZDE BULUNAN EN BÜYÜK PERYOT örnegimizde 50
{al:=Cross(mov(c,13,s),mov(c,50,s)); sat:=Cross(mov(c,50,s),mov(c,13,s)); }-->AL_SAT FORMULUMUZ
al:=mov(c,13,s)>mov(c,50,s); sat:=mov(c,13,s)<mov(c,50,s); -->AL_SAT FORMULUMUZ
al:=if(al and cum(1)=>n,1,0) ; sat:=if(sat and cum(1)=>n,1,0) ;
z:=valuewhen(1,al-sat,al-sat);
st:=if(BarsSince(cross(cum(al or sat),0.5))>0,1,0);
ov0:=cum(if(ref(z,-1)=1,ROC(c,1,$),if(ref(z,-1)=-1,-ROC(c,1,$))))*st;
ov1:=cum(ref(z,-1)*ROC(c,1,$))*st;
if(islemTipi=1,ov0,ov1)
Burada kendimiz "IS DEFINED" oluşturtuk..
SON Formulasyon
Kod:islemTipi:=Input("Alsat1 Tum0",0,1,1); n:=50;
{al:=Cross(mov(c,13,s),mov(c,50,s)); sat:=Cross(mov(c,50,s),mov(c,13,s)); }
al:=mov(c,13,s)>mov(c,50,s); sat:=mov(c,13,s)<mov(c,50,s);
al:=if(al and cum(1)=>n,1,0) ; sat:=if(sat and cum(1)=>n,1,0) ;
z:=valuewhen(1,al-sat,al-sat);
st:=if(BarsSince(cross(cum(al or sat),0.5))>0,1,0);
ov0:=cum(if(ref(z,-1)=1,ROC(c,1,$),if(ref(z,-1)=-1,-ROC(c,1,$))))*st;
ov1:=cum(ref(z,-1)*ROC(c,1,$))*st; if(islemTipi=1,ov0,ov1)
mtf ema
1 dk hariç tüm periyotlarda çalışmaktadır,
formül, günlük emanın alt periyotlarda gösterilmesi
https://i.hizliresim.com/MazZ5Q.pngAlıntı:
tp:= 4;
Nw:=ROC( DayOfWeek() ,1,$)<>0;
a1:= 2 / (tp +1);
if(nw,If( Cum( nw ) = 1, Ref(c, -1), Ref(c, -1)*a1 + (PREV*(1-a1))),prev)
Dostum,bu formul 1dak da çalışır...
Önceki gönderinde belirtdigin üzere uzun peryotlarda sorunumuz vardı..
İyileştirme yaptım ama tam netice degil demişdim...
Formulu matrikse uyduramamışsın devamını ben getireyim...
tp:= 4;
Nw:=ROC( DayOfWeek() ,1,$)<>0;
a1:= 2 / (tp +1);
if(nw,If( Cum( nw ) = 1, Ref(c, -1), Ref(c, -1)*a1 + (PREV*(1-a1))),prev)
Cum( nw ) = 1 hiç bir zaman gerçekleşmez çünkü nw gün başı -1 üretir....
Şu şekil olmalıydı...
tp:= 4;
Nw:=ROC( DayOfWeek() ,1,$)<>0;
a1:= 2 / (tp +1);
if(nw,If( Cum(nw ) = -1, Ref(c, -1), Ref(c, -1)*a1 + (PREV*(1-a1))),prev)
-------------------
Kaynak paylaşımın için teşekkür...
Benim iyileştirmem kaynakdaki bu örnekdekden daha iyi...
Son aşamada sizlerle paylaşırım...
-----------------
Elinize sağlık abiler teşekkürler..
ok sn. uufuk, düzeltme için teşekkürler. böylece formülün her parçasının ayrı ayrı kontrol edilmesi gerekliliğini de öğrendik. :whistling:
aslında iki cross fonksiyonunu birleştirmeye çalışıyordum internette araştırayım dedim. farklı bir yaklaşım var mı diye. o site bu site ilgili döküman çıktı. kısaca okurken sizin ema ile yazdıklarınız aklıma geldi, ben de buraya aktardım. işin özü ben simple taraftarıyım.