设为首页 收藏本站 切换语言
| 发表于 2025-7-13 21:14:28 | 显示全部楼层 |复制链接
指标名称:Sto热力图[color=rgba(0, 0, 0, 0.9)]
版本:MT4 ver. 2.01(指标)

Sto热力图指标与CCI热力图相同,只不过对应的指标不同。CCI热力图是基于 CCI(Commodity Channel Index)指标,Sto热力图是基于Stochastic指标。
image.png

参数:
image.jpg
部分代码展示:

  1. //+------------------------------------------------------------------+//|                                                   STO热力图.mq4 |//|                                Copyright © 2009-2024, www.QChaos.com |//|                                          https://www.qchaos.com/ |//+------------------------------------------------------------------+#property copyright "Copyright © 量化混沌, www.qchaos.com"#property link      "https://www.qchaos.com"#property version   "2.01"#property strict/------------------------------------------------------------------#property indicator_chart_window
  2. extern string Symbols           = "GBPJPY;AUDJPY;NZDJPY;EURJPY;USDJPY;CHFJPY;";  // 要使用的货币对(用“;”分隔)extern string TimeFrames        = "M5;M15;M30;H1;H4";        // 要使用的时间框架(用“;”分隔)
  3. //extern string TimeFrames        = "M1;M5;M15;M30;H1;H4;D1;W1;MN";        // 可选的时间框架(用“;”分隔)extern int    StoPeriod         = 14;                                    // 随机指标的周期(Stochastic Period)extern int    StoSmoothing      =  3;                                    // 随机指标的平滑(Smoothing)extern ENUM_STO_PRICE Price     = STO_LOWHIGH;                           // 随机指标使用的价格类型(Low/High)extern double lStrongUp         = 80;                                    // 强势上涨水平(Strong Up Level)extern double lStrongDown       = 20;                                    // 强势下跌水平(Strong Down Level)extern int    BarToTest         = 0;                                     // 测试的K线(Bar To Test)extern color  StrongUp          = clrLimeGreen;                          // 强势上涨的颜色extern color  Neutral           = clrDarkGray;                           // 中立的颜色extern color  StrongDown        = clrOrangeRed;                          // 强势下跌的颜色extern int    ColorSteps        = 41;                                    // 渐变色的步骤数extern color  TextColor         = clrBlack;                              // 按钮文本的颜色extern color  BorderColor       = clrBlack;                              // 按钮边框的颜色extern color  FillColor         = clrSilver;                             // 按钮背景的颜色extern int    Window            = 0;                                     // 显示窗口的编号extern ENUM_BASE_CORNER  Corner = CORNER_LEFT_LOWER;                     // 按钮显示的窗口角落位置extern int    XShift            = 0;                                     // 按钮的水平偏移extern int    YShift            = 0;                                     // 按钮的垂直偏移extern string             button_note1          = "------------------------------";  // 按钮上的备注1extern ENUM_BASE_CORNER   btn_corner            = CORNER_LEFT_UPPER; // 按钮在图表上的固定位置(左上角)extern string             btn_text              = "Stoch";  // 按钮文本内容extern string             btn_Font              = "Arial";  // 按钮字体extern int                btn_FontSize          = 10;  // 按钮字体大小extern color              btn_text_ON_color     = clrWhite;  // 按钮启用时的文本颜色extern color              btn_text_OFF_color    = clrRed;  // 按钮禁用时的文本颜色extern color              btn_background_color  = clrDimGray;  // 按钮背景颜色extern color              btn_border_color      = clrBlack;  // 按钮边框颜色extern int                button_x              = 20;  // 按钮的X坐标位置extern int                button_y              = 13;  // 按钮的Y坐标位置extern int                btn_Width             = 60;  // 按钮的宽度extern int                btn_Height            = 20;  // 按钮的高度extern string             button_note2          = "------------------------------";  // 按钮上的备注2
  4. bool                      show_data             = true;  // 是否显示数据string IndicatorName, IndicatorObjPrefix;  // 指标名称和对象前缀//template code end1int    cpairsLen, ctimesLen, aTimes[];  // 货币对数量、时间框架数量和时间数组string cpairs[];  // 存储货币对的字符串数组color  colors[];  // 存储颜色的数组string UniqueID          = "Stochastic Heatmap";  // 指标的唯一ID//+------------------------------------------------------------------------------------------------------------------+// 生成唯一的指标名称string GenerateIndicatorName(const string target) //不要更改此部分代码  {   string name = target;   int try         = 2;// 检查窗口是否已经存在相同名称的指标,如果存在,则加上数字后缀   while(WindowFind(name) != -1)     {      name = target + " #" + IntegerToString(try                                                ++);  // 生成新的名称     }   return name;  // 返回唯一名称  }
  5. //+------------------------------------------------------------------------------------------------------------------+string buttonId;
  6. //+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+int OnInit()  {   IndicatorName = GenerateIndicatorName(btn_text);   IndicatorObjPrefix = "__" + IndicatorName + "__";   IndicatorShortName(IndicatorName);   IndicatorDigits(Digits);
  7.    double val;   if(GlobalVariableGet(IndicatorName + "_visibility", val))      show_data = val != 0;
  8. // put init() here   Symbols = StringTrimLeft(StringTrimRight(Symbols));   if(StringSubstr(Symbols,StringLen(Symbols)-1,1) != ";")      Symbols = StringConcatenate(Symbols,";");
  9.    TimeFrames = StringTrimLeft(StringTrimRight(TimeFrames));   if(StringSubstr(TimeFrames,StringLen(TimeFrames)-1,1) != ";")      TimeFrames = StringConcatenate(TimeFrames,";");
  10.    int s = 0, i = StringFind(Symbols,";",s);   while(i > 0)     {      string current = StringSubstr(Symbols,s,i-s);      ArrayResize(cpairs,ArraySize(cpairs)+1);      cpairs[ArraySize(cpairs)-1] = current;      s = i + 1;      i = StringFind(Symbols,";",s);     }   if(Corner==CORNER_LEFT_LOWER  || Corner==CORNER_RIGHT_LOWER)      invertArray(cpairs);   cpairsLen = ArraySize(cpairs);   s = 0;   i = StringFind(TimeFrames,";",s);   while(i > 0)     {      string current = StringSubstr(TimeFrames,s,i-s);      int time = stringToTimeFrame(current);      if(time > 0)        {         ArrayResize(aTimes,ArraySize(aTimes)+1);         aTimes[ArraySize(aTimes)-1] = time;        }      s = i + 1;      i = StringFind(TimeFrames,";",s);     }   if(Corner==CORNER_RIGHT_UPPER || Corner==CORNER_RIGHT_LOWER)      invertiArray(aTimes);   ctimesLen = ArraySize(aTimes);
  11.    if(ColorSteps%2==0)      ColorSteps++;   ArrayResize(colors,ColorSteps);   int half = ColorSteps/2;   for(i=0; i<half; i++)     {      colors[i             ] = gradientColor(i+1,half,StrongUp,Neutral);      colors[ColorSteps-i-1] = gradientColor(i+1,half,StrongDown,Neutral);     }   colors = Neutral;
  12.    ChartSetInteger(ChartID(), CHART_EVENT_MOUSE_MOVE, 1);   buttonId = IndicatorObjPrefix + "StochDashboard2020";   createButton(buttonId, btn_text, btn_Width, btn_Height, btn_Font, btn_FontSize, btn_background_color, btn_border_color, btn_text_ON_color);   ObjectSetInteger(ChartID(), buttonId, OBJPROP_YDISTANCE, button_y);   ObjectSetInteger(ChartID(), buttonId, OBJPROP_XDISTANCE, button_x);
  13.    return(INIT_SUCCEEDED);  }//+------------------------------------------------------------------------------------------------------------------+//don't change anything herevoid createButton(string buttonID,string buttonText,int width,int height,string font,int fontSize,color bgColor,color borderColor,color txtColor)  {   ObjectDelete(ChartID(),buttonID);   ObjectCreate(ChartID(),buttonID,OBJ_BUTTON,0,0,0);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_COLOR,txtColor);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_BGCOLOR,bgColor);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_BORDER_COLOR,borderColor);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_XSIZE,width);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_YSIZE,height);   ObjectSetString(ChartID(),buttonID,OBJPROP_FONT,font);   ObjectSetString(ChartID(),buttonID,OBJPROP_TEXT,buttonText);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_FONTSIZE,fontSize);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_SELECTABLE,0);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_CORNER,btn_corner);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_HIDDEN,1);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_XDISTANCE,9999);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_YDISTANCE,9999);  }//+------------------------------------------------------------------------------------------------------------------+int deinit()  {   ObjectsDeleteAll(ChartID(), IndicatorObjPrefix);
  14. //put deinit() here   int idLength = StringLen(UniqueID);   for(int i = ObjectsTotal(); i>=0; i--)     { string name = ObjectName(i); if(StringSubstr(name,0,idLength) == UniqueID) ObjectDelete(name); }
  15.    return(0);  }//+------------------------------------------------------------------------------------------------------------------+//don't change anything herebool recalc = true;
  16. //+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+void handleButtonClicks()  {   if(ObjectGetInteger(ChartID(), buttonId, OBJPROP_STATE))     {      ObjectSetInteger(ChartID(), buttonId, OBJPROP_STATE, false);      show_data = !show_data;      GlobalVariableSet(IndicatorName + "_visibility", show_data ? 1.0 : 0.0);      recalc = true;      start();     }  }//+------------------------------------------------------------------------------------------------------------------+void OnChartEvent(const int id, //don't change anything here                  const long &lparam,                  const double &dparam,                  const string &sparam)  {   handleButtonClicks();  }//+------------------------------------------------------------------------------------------------------------------+string GetButtonState(string whichbutton)  {   bool selected = ObjectGetInteger(ChartID(),whichbutton,OBJPROP_STATE);   if(selected)     { return ("on"); }   else     {      return ("off");     }  }//+------------------------------------------------------------------------------------------------------------------+int start()  {   handleButtonClicks();   recalc = false;   int xshift=0, nxshift=0;   if(Corner==CORNER_RIGHT_LOWER || Corner==CORNER_RIGHT_UPPER)     {      xshift=49;      nxshift=66;     }   for(int i = 0; i < cpairsLen; i++)      ButtonCreate2(ChartID(),UniqueID+"t"+(string)i,Window,XShift+nxshift+2,YShift+30+i*15,66,14,Corner,cpairs,"Arial",9,TextColor,BorderColor,FillColor);   for(int i = 0; i < ctimesLen; i++)      ButtonCreate2(ChartID(),UniqueID+"h"+(string)i,Window,XShift+xshift+i*50+69,YShift+15,49,14,Corner,timeFrameToString(aTimes),"Arial",9,TextColor,BorderColor,FillColor);   for(int i = 0; i < cpairsLen; i++)      if(iClose(cpairs,0,0)!=0)         for(int t = 0; t < ctimesLen; t++)           {            double value    = iStochastic(cpairs,aTimes[t],StoPeriod,1,StoSmoothing,MODE_SMA,Price,MODE_MAIN,BarToTest);            int    step     = (int)((ColorSteps-1)*(MathMax(MathMin(value,lStrongUp),lStrongDown)-lStrongDown)/(lStrongUp-lStrongDown));            color  theColor = colors[ColorSteps-step-1];            ButtonCreate2(ChartID(),UniqueID+(string)t+(string)i,Window,XShift+xshift+t*50+69,YShift+30+i*15,49,14,Corner," ","arial",10,theColor,BorderColor,theColor);           }   if(Corner==CORNER_RIGHT_UPPER || Corner==CORNER_RIGHT_LOWER)      ButtonCreate2(ChartID(),UniqueID+"title",Window,XShift+xshift+ctimesLen*50+19,YShift+30+cpairsLen*15,ctimesLen*50-1,14,Corner," Stochastic ("+(string)StoPeriod+","+(string)StoSmoothing+")","arial",10,TextColor,BorderColor,FillColor);   else      ButtonCreate2(ChartID(),UniqueID+"title",Window,XShift+xshift+69,YShift+30+cpairsLen*15,ctimesLen*50-1,14,Corner," Stochastic ("+(string)StoPeriod+","+(string)StoSmoothing+")","arial",10,TextColor,BorderColor,FillColor);
  17.    if(!show_data)     {      ObjectSetInteger(ChartID(),buttonId,OBJPROP_COLOR,btn_text_OFF_color);      int idLength = StringLen(UniqueID);      for(int i = ObjectsTotal(); i>=0; i--)        { string name = ObjectName(i); if(StringSubstr(name,0,idLength) == UniqueID) ObjectDelete(name); }     }   else      ObjectSetInteger(ChartID(),buttonId,OBJPROP_COLOR,btn_text_ON_color);
  18.    return(0);  }//+------------------------------------------------------------------------------------------------------------------+bool ButtonCreate2(const long              chart_ID=0,               // chart's ID                   const string            name="Button",            // button name                   const int               sub_window=0,             // subwindow index                   const int               x=0,                      // X coordinate                   const int               y=0,                      // Y coordinate                   const int               width=50,                 // button width                   const int               height=18,                // button height                   const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // chart corner for anchoring                   const string            text="Button",            // text                   const string            font="Arial",             // font                   const int               font_size=10,             // font size                   const color             clr=clrBlack,             // text color                   const color             clrBorder=clrBlack,       // border color                   const color             back_clr=clrGray,         // background color                   const bool              state=true,              // pressed/released                   const bool              back=false,               // in the background                   const bool              selection=false,          // highlight to move                   const bool              hidden=true,              // hidden in the object list                   const long              z_order=0)                // priority for mouse click  {   ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0);   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,clrBorder);   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_TYPE,BORDER_FLAT);   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);   ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);   return(true);  }
复制代码

Sto热力图.ex4

34.06 KB, 下载次数: 0, 下载积分: 活跃度 -5 售价: 1 H币  [记录]  [购买]

评分
  • 1
  • 2
  • 3
  • 4
  • 5
平均分:NAN    参与人数:0    我的评分:未评 下载时遇到问题?
如果有帮助,就支持一下我呗
举报

评论 使用道具

精彩评论1

peterzhu2004
DDD
| 发表于 2025-7-14 05:55:08 | 显示全部楼层
看起来很不错,可以做震荡
举报

点赞 评论 使用道具

发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册

简体中文
繁體中文
English(英语)
日本語(日语)
Deutsch(德语)
Русский язык(俄语)
بالعربية(阿拉伯语)
Türkçe(土耳其语)
Português(葡萄牙语)
ภาษาไทย(泰国语)
한어(朝鲜语/韩语)
Français(法语)