2评论

0收藏

请好心老师修改一下分时线,附有源代码,谢谢!

avatar 641386452 | 179 人阅读 | 2 人评论 | 2025-03-16

现在的分时线只显示当天的,第二天开始重新开始计。想修改成每月第一天到月度的最后一天。请老师修改一下标记出来,不生感谢,下面是源代码。

//+------------------------------------------------------------------+
//|                                                   FenShiTu_I.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//|                指标采用5分钟的折线图,得到的效果和分时图非常接近 |
//|                该指标使用方法:1、把5分钟分钟K线图设置改成折线图 |
//|                                2、折线图的颜色改成白色           |
//|                                3、设置好背景和网格颜色           |
//+------------------------------------------------------------------+
#property  copyright "Copyright 2015, houxinyu "
#property  link      "http://www.metaquotes.net/"

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 2
#property indicator_color1 Yellow//黄色均线
#property indicator_color2 Red//红色零轴(昨收盘价)      

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];

int shift;
int i;
int loopbegin;
double VolumeSum;
double AmountSum;
//double tmp ;
//int c;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
   
//---- drawing settings
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   //SetIndexBuffer(2,sum);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);

//---- initialization done
   return(0);
  }

int start()

  {   
      //从每天的0点计算到现在的柱体数量
      string time=TimeToString(TimeCurrent(),TIME_DATE);
      datetime d=StringToTime(time);
      loopbegin=iBarShift(0, 0, d, false);
      
      for(shift = 0; shift <= loopbegin; shift++)
      {
         AmountSum = 0;
         VolumeSum = 0;
         for(i = 0; i <= loopbegin-shift  ; i++)//shift为0的时候是最左面的主体,累加数量最多为loopbegin根
         {
         AmountSum+=(iVolume(0, 0, loopbegin-i)*Close[loopbegin-i]);
         VolumeSum+=iVolume(0, 0, loopbegin-i);
         }
         ExtMapBuffer1[shift] = AmountSum/VolumeSum;
         ExtMapBuffer2[shift]=iClose(0,PERIOD_D1,1);//零轴采用昨天的收盘价
      }
   
      return(0);
  }
  
//+------------------------------------------------------------------+





""
还没有人打赏,支持一下

评论|共 2 个

641386452

发表于 2025-3-17 12:39:05 | 显示全部楼层

请帮忙

641386452

发表于 2025-3-27 10:42:58 | 显示全部楼层

1111

您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则