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

Complex_balance_Ext.mq4

Complex_balance_Ext指标根据均线及价格的特定算法在副图创建类似之字形通道的折线。

图表:Complex_balance_Ext指标

源码:

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

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

extern int       PerFast=0;
extern int       PerSlow=0;
extern int       NBars=200;
extern int       TF=0;
extern int       Price=6;
extern int       Mode=3;
double Buf[],a,b;
int per1,per2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   IndicatorShortName("Complex_balanceExt("+per2+"/"+per1+")");
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexBuffer(0,Buf);

int mn_per = 12;
int mn_fast = 3;

int w_per = 9;
int w_fast = 3;

int d_per = 5;
int d_fast = 3;

int h4_per = 12;
int h4_fast = 2;

int h1_per = 24;
int h1_fast = 8;

int m30_per = 16;
int m30_fast = 2;

int m15_per = 16;
int m15_fast = 4;

int m5_per = 12;
int m5_fast = 3;

int m1_per = 30;
int m1_fast = 10;
if (TF==0) int TFr=Period(); else TFr=TF;
      if ((PerFast==0)||(PerSlow==0))
      {switch(TFr)
        {
         case 1:     per1 = m1_per; per2 = m1_fast; break;
         case 5:     per1 = m5_per; per2 = m5_fast; break;
         case 15:    per1 = m15_per;per2 = m15_fast; break;
         case 30:    per1 = m30_per;per2 = m30_fast; break;
         case 60:    per1 = h1_per; per2 = h1_fast; break;
         case 240:   per1 = h4_per; per2 = h4_fast; break;
         case 1440:  per1 = d_per;  per2 = d_fast; break;
         case 10080: per1 = w_per;  per2 = w_fast; break;
         case 43200: per1 = mn_per; per2 = mn_fast; break;
        }
      } else {per2=PerFast; per1=PerSlow;}  
   Comment("www.125808047.com");
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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 limit;
     int counted_bars=IndicatorCounted();

     if(counted_bars<0) return(-1);

     if(counted_bars>0) counted_bars-=10;
     limit=NBars;

     for(int i=0; i<limit; i++)
       {
        a=b;
        b=iMA(Symbol(),TF,per2,0,Mode,Price,i)-iMA(Symbol(),TF,per1,0,Mode,Price,i);
        if (i!=0)
        {
        if ((a<0 && b>0) || (a>0 && b<0))
        Buf[i]=(iOpen(0,TF,i)+iHigh(0,TF,i)+iLow(0,TF,i)+iClose(0,TF,i))/4+MathAbs(MathAbs(a)-MathAbs(b))/2*Point;
        }
        else Buf[i]=(iOpen(0,TF,i)+iHigh(0,TF,i)+iLow(0,TF,i)+iClose(0,TF,i))/4;
       }
   return(rates_total);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » Complex_balance_Ext.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏