admin 发表于 2018-1-18 15:01:56

bezier



//+------------------------------------------------------------------+
//|                                                       Bezier.mq4 |
//|                      Copyright ?2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2007, MetaQuotes Software Corp."
#property link      "Lizhniyk E"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Aqua

//---- input parameters
extern int period=8;
extern double t=0.5;
extern int shift=0;
extern intPrice=0;
double Ext[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Ext);
   SetIndexLabel(0,"Bezier("+period+","+t+")");
   SetIndexShift(0,shift);
   SetIndexDrawBegin(0,period);
   
   
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                     |
//+------------------------------------------------------------------+
int deinit()
{
//----
   
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int    counted_bars=IndicatorCounted();
//----

for(int j=0;j<Bars-counted_bars;j++)
{
double r=0;
   for(int i=period;i>=0;i--)
    {
    r+=pr(Price,j+i) *
   (fact(period)/(fact(i)*fact(period-i))) *
      MathPow(t,i) *
       MathPow(1-t,period-i);
    }
Ext=r;
}
//----
   return(0);
}
//+------------------------------------------------------------------+
double fact(int value)
{
double res=1;
for(double j=2;j<value+1;j++)
{
res*=j;
}
return (res);
}

double pr(int Price,int n)
{
switch (Price)
{
case 0: {return(Close);break;}
case 1: {return(Open);break;}
case 2: {return(High);break;}
case 3: {return(Low);break;}
case 4: {return((High+Low)/2);break;}
case 5: {return((High+Low+Close)/3);break;}
case 6: {return((High+Low+Close+Close)/4);break;}
case 7: {return(iMA(Symbol(),0,4,0,0,0,n));break;}
}
}




你的太在乎 发表于 2020-6-7 21:58:14

LZ说的很不错

依百分hq 发表于 2020-7-3 22:49:24

LZ真是人才

huangj01 发表于 2020-7-11 10:00:58

学习了,不错

涂杭 发表于 2020-7-30 12:45:29

学习了,不错

d万佛阁 发表于 2020-8-30 10:06:06

学习了,不错

sjaking 发表于 2021-7-28 16:44:24

{:1_181:}
页: [1]
查看完整版本: bezier