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

Cool2.mq4

Cool2指标属于另类分形指标。

图表:Cool2指标

源码:

//+------------------------------------------------------------------+
//|                                                        Cool2.mq4 |
//|                                        Ramdass - Conversion only |
//+------------------------------------------------------------------+
#property copyright " Ramdass - Conversion only"
#property link      "http://www.125808047.com"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int ndot = 5;
extern int CountBars = 300;

double cfl[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   IndicatorBuffers(1);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, cfl);

   if(CountBars >= Bars) 
       CountBars = Bars;
   SetIndexDrawBegin(0, Bars - CountBars + ndot + 1);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Cool2                                                              |
//+------------------------------------------------------------------+
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, cnt, ndot1, counted_bars = IndicatorCounted();
   double TYVar, ZYVar, TIndicatorVar, ZIndicatorVar, M, N, AY, AIndicator;

   if(Bars <= ndot) 
       return(0);

   shift = CountBars - ndot - 1;

   while(shift >= 0)
     {
       TYVar = 0;
	      ZYVar = 0;
	      N = 0;
	      M = 0;
	      TIndicatorVar = 0;
	      ZIndicatorVar = 0;
	      ndot1 = ndot;
	      if(shift + 1 < ndot1) 
	          ndot1 = shift + 1;
	      for(cnt = ndot; cnt >= 1; cnt--) 
	        { 
		         N = N + cnt*cnt; 
		         M = M + cnt;      
	        }
	      for(cnt = ndot1; cnt >= 1; cnt--) 
	        {
		         ZYVar = ZYVar + (High[shift-cnt+1] + Low[shift-cnt+1]) / 2*(ndot+1-cnt);
		         TYVar = TYVar + (High[shift-cnt+1] + Low[shift-cnt+1]) / 2;
		         ZIndicatorVar = ZIndicatorVar + iMA(NULL, 0, 5, 3, MODE_SMMA, PRICE_MEDIAN, 
		                                             shift - cnt + 1)*(ndot + 1 - cnt);
		         TIndicatorVar = TIndicatorVar + iMA(NULL, 0, 5, 3, MODE_SMMA, PRICE_MEDIAN,  
		                                             shift - cnt + 1);
	         }
	      AY = (TYVar + (N - 2*ZYVar)*ndot / M) / M;
	      AIndicator = (TIndicatorVar + (N - 2*ZIndicatorVar)*ndot / M) / M;
	      cfl[shift] = Close[shift] + ((-1000)*MathLog(AY / AIndicator) / 500);
	      shift--;
     }
   return(rates_total);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » Cool2.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏