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

OSMA类指标 ChandeQStick_v1.mq4

ChandeQStick_v1指标创建另类OSMA。

图表:ChandeQStick_v1指标

源码:

//+------------------------------------------------------------------+
//|                                              ChandeQStick_v1.mq4 |
//|                            Copyright @2006, TrendLaboratory Ltd. |
//+------------------------------------------------------------------+
#property copyright "Copyright @2006, TrendLaboratory Ltd."
#property link      "http://www.125808047.com/"

#property indicator_separate_window
#property indicator_buffers   2
#property indicator_color1    LightBlue
#property indicator_color2    Orange
#property indicator_width1    3
#property indicator_width2    3
#property indicator_level1    0

extern int       Length =8; 
extern int       MA_Mode=0; 

double CQS_Up[];
double CQS_Dn[];
double Diff[];
double CQS[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,CQS_Up);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,CQS_Dn);
   SetIndexBuffer(2,Diff);
   SetIndexBuffer(3,CQS);

   string short_name="ChandeQStick("+Length+","+MA_Mode+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"CQS Up");
   SetIndexLabel(0,"CQS Down");

   SetIndexDrawBegin(0,Length);
   SetIndexDrawBegin(1,Length);
   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      shift, limit, counted_bars=IndicatorCounted();

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for( shift=limit; shift>=0; shift--)
      Diff[shift]=Close[shift]-Open[shift];

   for( shift=limit; shift>=0; shift--)
     {
      CQS[shift]=iMAOnArray(Diff,0,Length,0,MA_Mode,shift);
      if (CQS[shift]>=CQS[shift+1]) {CQS_Up[shift]=CQS[shift];CQS_Dn[shift]=0;}
      else
         if (CQS[shift]<CQS[shift+1]) {CQS_Dn[shift]=CQS[shift];CQS_Up[shift]=0;}
     }
   return(rates_total);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » OSMA类指标 ChandeQStick_v1.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏