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

均线信号副图指标 BuySell_v2.mq4

BuySell_v2指标将均线信号用柱状线在副图呈现。

图表:BuySell_v2指标

源码:

//+------------------------------------------------------------------+
//|                                                   BuySell_v2.mq4 |
//|                                         Copyright @2008, masemus |
//+------------------------------------------------------------------+
#property copyright "Copyright @2008, masemus"
#property link      "http://www.125808047.com"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 4
#property indicator_color1 DeepPink
#property indicator_color2 LightPink
#property indicator_color3 LightSkyBlue
#property indicator_color4 DodgerBlue

extern int TF=0;
extern int MA1Val = 1;
extern int MA1Type = 0;
extern int MA2Val = 4;
extern int MA2Type = 0;
extern int MA3Val = 20;
extern int MA3Type = 0;

double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
string TimeFrameStr;
double MA1,MA2,MA3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
{
  SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
  SetIndexBuffer(0,ExtMapBuffer1);
  SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
  SetIndexBuffer(1,ExtMapBuffer2);
  SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID);
  SetIndexBuffer(2,ExtMapBuffer3);
  SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID);
  SetIndexBuffer(3,ExtMapBuffer4);

switch(TF)
   {
      case 1 : TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="Current Timeframe"; TF=0;
   }
   IndicatorShortName("BuySell_v2 ("+TimeFrameStr+")");  
   Comment("www.125808047.com"); 
  }
//+------------------------------------------------------------------+
//| 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    counted_bars=IndicatorCounted();
   for (int i = 0; i < 300; i++)
   {
   ExtMapBuffer1[i]=0;
   ExtMapBuffer2[i]=0;
   ExtMapBuffer3[i]=0;
   ExtMapBuffer4[i]=0;
   
   MA1=iMA(NULL,TF,MA1Val,0,MODE_SMA,PRICE_CLOSE,i);
   MA2=iMA(NULL,TF,MA2Val,0,MODE_SMA,PRICE_CLOSE,i);
   MA3=iMA(NULL,TF,MA3Val,0,MODE_SMA,PRICE_CLOSE,i);
   
   if(MA1>MA2 && MA1>MA3)ExtMapBuffer4[i] = 1;
   if(MA1<MA2 && MA1>MA3){ExtMapBuffer2[i] = 1;}
   if(MA1>MA2 && MA1<MA3)ExtMapBuffer3[i] = 1;
   if(MA1<MA2 && MA1<MA3){ExtMapBuffer1[i] = 1;}
}
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 均线信号副图指标 BuySell_v2.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏