Can anybody explain how to solve this problem?
walb99:
Can anybody explain how to solve this problem?
Can anybody explain how to solve this problem?
You may delete this query. The indicator has a refreshing problem, which could be
eliminated.
test this version
//+------------------------------------------------------------------+ //| MAMA_FAMA.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ru/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/ru/" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 Blue extern double FastLimit=0.5; extern double SlowLimit=0.05; //---- buffers double MAMA[]; double FAMA[]; double SmoothPeriod[]; double Phase[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(4); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,MAMA); SetIndexLabel(0,"MAMA"); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,FAMA); SetIndexLabel(1,"FAMA"); SetIndexBuffer(2,SmoothPeriod); SetIndexBuffer(3,Phase); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| вычислить медиану для бара с индексом index | //+------------------------------------------------------------------+ double Price(int index) { double res; //---- res=(High[index]+Low[index])/2.0; //---- return(res); } //+------------------------------------------------------------------+ //| вычислить Smooth для бара с индексом i | //+------------------------------------------------------------------+ double Smooth(int i) { double res; //---- res=(4*Price(i)+3*Price(i+1)+2*Price(i+2)+Price(i+3))/10.0; //---- return(res); } //+------------------------------------------------------------------+ //| высилить Detrender ждя данного бара с заданным | //+------------------------------------------------------------------+ double Detrender(int i, double ThatPer) { double res; //---- res=(0.0962*Smooth(i)+0.5769*Smooth(i+2)-0.5769*Smooth(i+4)-0.0962*Smooth(i+6))*(0.075*ThatPer+0.54); //---- return(res); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i,limit,counted_bars=IndicatorCounted(); double periodD,prev_period,DeltaPhase,I1,Q1,thatPeriod; double alpha; //---- if (counted_bars==0) limit=Bars-27; if (counted_bars>0) limit=Bars-counted_bars; for (i=limit;i>=0;i--) { periodD=iCustom(NULL,0,"MAMA_Slave2",7,i); prev_period=iCustom(NULL,0,"MAMA_Slave2",7,i+1); thatPeriod=prev_period; Q1=iCustom(NULL,0,"MAMA_Slave2",6,i); I1=Detrender(i,thatPeriod); SmoothPeriod[i]=0.33*periodD+0.67*prev_period; if (I1!=0) Phase[i]=360*MathArctan(Q1/I1)/2*3.1415; DeltaPhase=Phase[i+1]-Phase[i]; if (DeltaPhase<1) DeltaPhase=1; alpha=FastLimit/DeltaPhase; if (alpha<SlowLimit) alpha=SlowLimit; MAMA[i]=alpha*Price(i)+(1-alpha)*MAMA[i+1]; FAMA[i]=0.5*alpha*MAMA[i]+(1-0.5*alpha)*FAMA[i+1]; } //---- return(0); } //+------------------------------------------------------------------+Slave indicator is attached below.
Files:
mama_slave2.mq4
6 kb
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register