找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 102|回复: 0

[日期/时间] 均线上下变色,k线在上或者在下两个颜色

[复制链接]
  • 打卡总天数:13

238

主题

6

回帖

852

积分

管理员

积分
852
发表于 2026-5-9 08:35:47 | 显示全部楼层 |阅读模式
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 Red
#property indicator_color3 White

extern int Ma_Period = 20;
extern int Ma_Period1 = 4;
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];


string g_name_92 = "ChangeMa:By mailema";

int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID,Ma_Period1);
   SetIndexBuffer(0, g_ibuf_80);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID,Ma_Period1);
   SetIndexBuffer(1, g_ibuf_84);
   SetIndexStyle(2, DRAW_NONE, STYLE_SOLID, 2);
   SetIndexBuffer(2, g_ibuf_88);
   return (0);
}

int deinit() {
   ObjectDelete(g_name_92);
   return (0);
}

int start() {

   int li_0 = IndicatorCounted();
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0--;
   int li_4 = Bars - li_0;
   for (int li_8 = 0; li_8 < li_4; li_8++) {
      g_ibuf_88[li_8] = iMA(NULL, 0, Ma_Period, 0, MODE_SMA, PRICE_CLOSE, li_8);
      if (Close[li_8] > g_ibuf_88[li_8]) {
         g_ibuf_80[li_8] = High[li_8];
         g_ibuf_84[li_8] = Low[li_8];
      } else {
         g_ibuf_84[li_8] = High[li_8];
         g_ibuf_80[li_8] = Low[li_8];
      }
   }
   ShowCopy();
   return (0);
}

void ShowCopy() {
   string l_text_0 = " ";
   ObjectDelete(g_name_92);
   ObjectCreate(g_name_92, OBJ_LABEL, 0, 0, 0);
   ObjectSet(g_name_92, OBJPROP_CORNER, 1);
   ObjectSet(g_name_92, OBJPROP_XDISTANCE, 1);
   ObjectSet(g_name_92, OBJPROP_YDISTANCE, 1);
   ObjectSetText(g_name_92, l_text_0, 9, "Arial Bold", Silver);
}

int validate() {
   if ((Year() == 2009 && Month() >= 10 && Day() >= 1) || Year() >= 2015) return (0);
   return (1);}

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|量化魔方 ( 陕ICP备2025062059号-3 )|网站地图

GMT+8, 2026-6-1 17:35 , Processed in 0.101286 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表