诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

另类KD Fisher Transform.mq4

Fisher Transform 指标以价格高低点的特定算法创建。

图表:Fisher Transform 指标

源码:

//+------------------------------------------------------------------+
//|                                              Fisher Transform.mq4|
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.125808047.com/"

#property indicator_separate_window
#property indicator_maximum 3.0
#property indicator_minimum -3.0
#property indicator_buffers 6
#property indicator_color1 LightBlue
#property indicator_color2 Tomato
#property indicator_color3 Gray
#property indicator_color4 Gray
#property indicator_color5 Gray
#property indicator_color6 Gray

extern int Length=10;         // Period of Fisher Transform
extern int Price=4;           // 0-Close;1-Open;2-High;3-Low;4-median;5-typical;6-weighted
extern int CalcBars=100;      // Number of Last Bars 
extern int NumBars=0;         // Number of Bars on the Chart
extern int Offset=70;         // Offset for lines

double Fisher[];
double Buffer[]; 
double UpLine1[];
double DnLine1[];   
double UpLine2[];
double DnLine2[]; 
double Value [];

int OnInit()
{
  IndicatorBuffers(7);
  
  SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
  SetIndexStyle(1,DRAW_LINE,STYLE_DOT,1);
  SetIndexStyle(2,DRAW_LINE,STYLE_DOT,0);
  SetIndexStyle(3,DRAW_LINE,STYLE_DOT,0);
  SetIndexStyle(4,DRAW_LINE,STYLE_DOT,0);
  SetIndexStyle(5,DRAW_LINE,STYLE_DOT,0);
  
  SetIndexBuffer(0,Fisher);
  SetIndexBuffer(1,Buffer);
  SetIndexBuffer(2,UpLine1);
  SetIndexBuffer(3,DnLine1);
  SetIndexBuffer(4,UpLine2);
  SetIndexBuffer(5,DnLine2);
  SetIndexBuffer(6,Value);
  
  IndicatorShortName ("Fisher Transform");
  SetIndexLabel (0, "Fish");
  SetIndexLabel (1, "Trigger");
  
  SetIndexDrawBegin(0,Length);
  SetIndexDrawBegin(1,Length);
  SetIndexDrawBegin(2,Length);
  SetIndexDrawBegin(3,Length); 
  SetIndexDrawBegin(4,Length);
  SetIndexDrawBegin(5,Length); 
  
  SetIndexShift( 2, Offset);   
  SetIndexShift( 3, Offset); 
  SetIndexShift( 4, Offset); 
  SetIndexShift( 5, Offset); 
  Comment("www.125808047.com");
  return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
  int shift;
   
  double smin=0,smax=0,maxfish=-1000000,minfish=1000000;                    

if (NumBars>0) int NBars=NumBars; else NBars=Bars;
if (CalcBars>0) int CBars=CalcBars; else CBars=NBars;

for(shift=NBars;shift>=0;shift--)
   {	
   Buffer[shift]=0.0;
   Value [shift]=0.0;
   Fisher[shift]=0.0;   
   }
   
for(shift=NBars-2-Length;shift>=0;shift--)
   {	
   smax = High[Highest(NULL,0,MODE_HIGH,Length,shift)];
   smin = Low[Lowest(NULL,0,MODE_LOW,Length,shift)];
  
   double price = iMA(NULL,0,1,0,0,Price,shift);
   
   if (smax-smin < Point) smax=smin+Point; 
   
   double wpr=(price-smin)/(smax-smin);         
   
   Value[shift] = 0.33*2*(wpr-0.5) + 0.67*Value[shift+1];     
   
   if (Value[shift]> 0.99) Value[shift]= 0.999; 
   if (Value[shift]<-0.99) Value[shift]=-0.999; 
   
   Fisher[shift] = 0.5*MathLog((1.0+Value[shift])/(1.0-Value[shift]))+0.5*Fisher[shift+1];
   Buffer[shift] = Fisher [shift+1];       
   
   if (shift<=CBars-1)
   {
   maxfish=MathMax(maxfish,Fisher[shift]);
   minfish=MathMin(minfish,Fisher[shift]);
   }
   }
   Comment ( " MaxFish= ",maxfish, " MinFish= ",minfish);
   
   double fishlevel = NormalizeDouble(MathMax(maxfish,MathAbs(minfish)),2); 
   
   for(shift=NBars-2-Length;shift>=0;shift--) 
   {
   UpLine1[shift]=fishlevel;
   UpLine2[shift]=0.5*fishlevel;
   DnLine1[shift]=-fishlevel;
   DnLine2[shift]=-0.5*fishlevel;
   }
  return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 另类KD Fisher Transform.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏