9评论

5收藏

在主图上叠加其他产品的指标

avatar maya111 | 2130 人阅读 | 9 人评论 | 2018-09-05

非常方便的叠加指标,只需要填写货币兑的代码即可显示。
网上很多代码是错误的,不能执行,这个代码完好,有需要的朋友拿去用!

//---------------------------------------------------------------------------------------
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Yellow
extern string 添加商品="EURUSD";
extern int 对准均线=5;
double MyBuffer1[];
double MyBuffer2[];
double MyBuffer3[];
double MyBuffer4[];
double multp;
string my_symbol;

int init()  {
   SetIndexBuffer(0, MyBuffer1);
   SetIndexBuffer(1, MyBuffer2);
   SetIndexBuffer(2, MyBuffer3);
   SetIndexBuffer(3, MyBuffer4);
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,0);
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,0);
   my_symbol=添加商品;
   int kk=PERIOD_D1/Period();
   if(kk<1) kk=1;
   multp=iMA(NULL,0,对准均线*kk,0,MODE_SMA,PRICE_CLOSE,0)/iMA(my_symbol,0,对准均线*kk,0,MODE_SMA,PRICE_CLOSE,0);
   return(0);
}

int start()  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int t=0; t<limit; t++)   {
      MyBuffer1[t]=iOpen(my_symbol,0,t)*multp;
      MyBuffer2[t]=iClose(my_symbol,0,t)*multp;
      if (iOpen(my_symbol,0,t)==iClose(my_symbol,0,t))
         MyBuffer2[t]=iClose(my_symbol,0,t)*multp-0.1*Point;
      if (iOpen(my_symbol,0,t)>=iClose(my_symbol,0,t))  {
         MyBuffer3[t]=iHigh(my_symbol,0,t)*multp;
         MyBuffer4[t]=iLow(my_symbol,0,t)*multp;
      }
      else  if(iOpen(my_symbol,0,t)<iClose(my_symbol,0,t))   {
         MyBuffer3[t]=iLow(my_symbol,0,t)*multp;
         MyBuffer4[t]=iHigh(my_symbol,0,t)*multp;
      }
   }
   return(0);
}
//-----------------------------------------------------------------------------------------------------

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

评论|共 9 个

slash

发表于 2018-9-5 22:16:05 | 显示全部楼层

楼主好人啊

沐铃咻咻

发表于 2020-4-29 11:15:16 | 显示全部楼层

支持一下:lol

rosken

发表于 2020-6-30 15:14:28 | 显示全部楼层

前排支持下

leftme

发表于 2020-7-13 17:05:30 | 显示全部楼层

帮你顶下哈!!

hncxr1385

发表于 2020-7-17 16:10:37 | 显示全部楼层

学习了,不错

vivi

发表于 2020-7-30 18:28:07 | 显示全部楼层

帮你顶下哈!!

hongtao7568@tom

发表于 2021-7-9 22:58:40 | 显示全部楼层

gbfhi

发表于 2021-7-16 18:52:38 | 显示全部楼层

叮咚咕嘟

发表于 2024-4-21 13:45:45 | 显示全部楼层

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

EA之家评论守则