SATL – это статистическая оценка линии долгосрочного тренда, которая, в отличие от традиционных скользящих средних, не имеет фазового запаздывания относительно текущих цен
Значение SATL(i) является матожиданием FATL(i) для любого i на заданном временном интервале.
В настоящее время код семейства цифровых фильтров, в которые входит SATL давно раскрыт и мы можем рассмотреть его:
- Код: выделить все
//+------------------------------------------------------------------+
//| SATL.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Green
//---- buffers
double SATLBuffer[];
//+------------------------------------------------------------------+
//| FATL weights |
//+------------------------------------------------------------------+
#define SATLPeriods 65
double g_SATLKoef[SATLPeriods]=
{ 0.0982862174 ,+0.0975682269 , +0.0961401078 ,+0.0940230544 ,+0.0912437090 ,+0.0878391006 ,
+0.0838544303 ,+0.0793406350 , +0.0743569346 ,+0.0689666682 ,+0.0632381578 ,+0.0572428925 ,
+0.0510534242 ,+0.0447468229 , +0.0383959950 ,+0.0320735368 ,+0.0258537721 ,+0.0198005183 ,
+0.0139807863 ,+0.0084512448 , +0.0032639979 ,-0.0015350359 ,-0.0059060082 ,-0.0098190256 ,
-0.0132507215 ,-0.0161875265 , -0.0186164872 ,-0.0205446727 ,-0.0219739146 ,-0.0229204861 ,
-0.0234080863 ,-0.0234566315 , -0.0231017777 ,-0.0223796900 ,-0.0213300463 ,-0.0199924534 ,
-0.0184126992 ,-0.0166377699 , -0.0147139428 ,-0.0126796776 ,-0.0105938331 ,-0.0084736770 ,
-0.0063841850 ,-0.0043466731 , -0.0023956944 ,-0.0005535180 ,+0.0011421469 ,+0.0026845693 ,
+0.0040471369 ,+0.0052380201 , +0.0062194591 ,+0.0070340085 ,+0.0076266453 ,+0.0080376628 ,
+0.0083037666 ,+0.0083694798 , +0.0082901022 ,+0.0080741359 ,+0.0077543820 ,+0.0073260526 ,
+0.0068163569 ,+0.0062325477 , +0.0056078229 ,+0.0049516078,+0.0161380976 };
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0, SATLBuffer);
SetIndexDrawBegin(0,65);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//---- TODO: add your code here
int j,pos;
double sum3;
//----
if(counted_bars<0) return(-1);
//if (counted_bars>0) counted_bars--;
//---- main calculation loop
for (pos=Bars-counted_bars-1;pos>=0;pos--)
{
sum3=0; // zero summary
for(j=0;j<SATLPeriods;j++) sum3+=g_SATLKoef[j]*Close[pos+j];//Counted SATL[POS]
SATLBuffer[pos]=sum3;
}
return(0);
}
//+------------------------------------------------------------------+
На скрине графика EURUSD (см. скрин ниже) данная линия индикатора SATL представлена зеленым цветом: