chzh 发表于 2016-6-5 10:17:16

哪位大神帮改一下


这是KD指标,能否在30分钟,和1小时级别的KD指标中在叠加一条4小时级别的K值线


#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_color4 Blue

double g_ibuf_76[];
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
extern int KPeriod = 8;
extern int DPeriod = 5;
extern int Slowing = 3;
extern bool Alert_Switch = TRUE;
double g_time_108;

int init() {
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(2, 233);
   SetIndexArrow(3, 234);
   SetIndexBuffer(0, g_ibuf_76);
   SetIndexBuffer(1, g_ibuf_80);
   SetIndexBuffer(2, g_ibuf_84);
   SetIndexBuffer(3, g_ibuf_88);
   string ls_0 = "Sto(" + KPeriod + "," + DPeriod + "," + Slowing + ")";
   IndicatorShortName(ls_0);
   SetIndexLabel(0, ls_0);
   SetIndexLabel(1, "Signal");
   SetIndexLabel(2, "金叉");
   SetIndexLabel(3, "死叉");
   IndicatorDigits(Digits);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int li_4 = IndicatorCounted();
   if (li_4 < 0) return (-1);
   if (li_4 > 0) li_4--;
   int li_0 = Bars - li_4;
   for (int l_shift_8 = 0; l_shift_8 < li_0; l_shift_8++) {
      g_ibuf_76 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, l_shift_8);
      g_ibuf_80 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_SIGNAL, l_shift_8);
   }
   for (l_shift_8 = 0; l_shift_8 < li_0; l_shift_8++) {
      g_ibuf_84 = EMPTY_VALUE;
      g_ibuf_88 = EMPTY_VALUE;
      if (g_ibuf_76 > g_ibuf_80 && g_ibuf_76 < g_ibuf_80) g_ibuf_84 = g_ibuf_80;
      if (g_ibuf_76 < g_ibuf_80 && g_ibuf_76 > g_ibuf_80) g_ibuf_88 = g_ibuf_80;
      if (g_ibuf_76 > g_ibuf_80 && g_ibuf_76 == g_ibuf_80 && g_ibuf_76 < g_ibuf_80) g_ibuf_84 = g_ibuf_80;
      if (g_ibuf_76 < g_ibuf_80 && g_ibuf_76 == g_ibuf_80 && g_ibuf_76 > g_ibuf_80) g_ibuf_88 = g_ibuf_80;
   }
   if (Alert_Switch == TRUE && g_ibuf_76 > g_ibuf_80 && g_ibuf_76 < g_ibuf_80 && g_time_108 != Time) {
      Alert(Symbol(), "", Period(), ":", "Stochastic 金叉");
      g_time_108 = Time;
   }
   if (Alert_Switch == TRUE && g_ibuf_76 < g_ibuf_80 && g_ibuf_76 > g_ibuf_80 && g_time_108 != Time) {
      g_time_108 = Time;
      Alert(Symbol(), "", Period(), ":", "Stochastic 死叉");
   }
   if (Alert_Switch == TRUE && g_ibuf_76 > g_ibuf_80 && g_ibuf_76 == g_ibuf_80 && g_ibuf_76 < g_ibuf_80 && g_time_108 != Time) {
      g_time_108 = Time;
      Alert(Symbol(), "", Period(), ":", "Stochastic 金叉");
   }
   if (Alert_Switch == TRUE && g_ibuf_76 < g_ibuf_80 && g_ibuf_76 == g_ibuf_80 && g_ibuf_76 > g_ibuf_80 && g_time_108 != Time) {
      g_time_108 = Time;
      Alert(Symbol(), "", Period(), ":", "Stochastic 死叉");
   }
   return (0);
}

ysyyclnh 发表于 2016-6-5 19:36:14

论坛有现成的多周期KDJ指标,楼主找找看。
页: [1]
查看完整版本: 哪位大神帮改一下