交易危机

 找回密码
 快捷注册(禁q号)

QQ登录

只需一步,快速开始

搜索
广告位
查看: 1609|回复: 5
打印 上一主题 下一主题

[其他] 主图的K线指标,想改成放在副图的K线指标

[复制链接]

1

主题

29

积分

0

精华

外汇入门

金钱
29 美元
权重
0
跳转到指定楼层
楼主
发表于 2015-6-13 10:02 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 wccmcd 于 2015-12-4 13:06 编辑

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 Blue
#property indicator_color3 Yellow
#property indicator_color4 Blue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3
//----
extern color color1 = Yellow;
extern color color2 = Blue;
extern color color3 = Yellow;
extern color color4 = Blue;
extern int     MAPeriod   = 10;
extern string  strType    = "Moving Average Types:";
extern string  strm0      = "0 = SMA,  1 = EMA";
extern string  strm1      = "2 = SMMA, 3 = LWMA";
extern int     MAType     = 0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//----
int ExtCountedBars = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
{
//---- indicators
   SetIndexStyle(0, DRAW_HISTOGRAM, 0, 1, color1);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1, DRAW_HISTOGRAM, 0, 1, color2);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(2, DRAW_HISTOGRAM, 0, 3, color3);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(3, DRAW_HISTOGRAM, 0, 3, color4);
   SetIndexBuffer(3, ExtMapBuffer4);
//----
   SetIndexDrawBegin(0, MAPeriod);
   SetIndexDrawBegin(1, MAPeriod);
   SetIndexDrawBegin(2, MAPeriod);
   SetIndexDrawBegin(3, MAPeriod);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   IndicatorShortName("MA-Candlesticks(" + MAPeriod + ")");
//---- initialization done
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   double MAOpen, MAHigh, MALow, MAClose;
   if(Bars <= (MAPeriod)) return(0);
   ExtCountedBars = IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos = Bars - ExtCountedBars - 1;
   while(pos >= 0)
   {
      MAClose = iMA(NULL, 0, MAPeriod, 0, MAType, PRICE_CLOSE, pos);
      MAOpen = iMA(NULL, 0, MAPeriod, 0, MAType, PRICE_OPEN, pos);
      MAHigh = iMA(NULL, 0, MAPeriod, 0, MAType, PRICE_HIGH, pos);
      MALow = iMA(NULL, 0, MAPeriod, 0, MAType, PRICE_LOW, pos);
      
      if (MAClose > MAOpen)
      {
         ExtMapBuffer1[pos]=MALow;
         ExtMapBuffer2[pos]=MAHigh;
      }
      else
      {
         ExtMapBuffer1[pos]=MAHigh;
         ExtMapBuffer2[pos]=MALow;
      }
      ExtMapBuffer3[pos]=MAOpen;
      ExtMapBuffer4[pos]=MAClose;
          
           pos--;
   }
//----
   return(0);
}
//+------------------------------------------------------------------+
这个为在主图的K线指标,想改成放在副图的K线指标,
我把#property indicator_chart_window改成#property indicator_separate_window的,
结果指标变成在副图了,但是显示却出错了,请问高手,这个怎么改?

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 保留保留

1

主题

29

积分

0

精华

外汇入门

金钱
29 美元
权重
0
沙发
 楼主| 发表于 2015-6-13 10:43 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 13:06 编辑

在副图下面怎么都是蓝色的一片,不能像主图一样吗,也只是显是K线


1

主题

29

积分

0

精华

外汇入门

金钱
29 美元
权重
0
板凳
 楼主| 发表于 2015-6-13 10:46 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 13:06 编辑

下面都是蓝色的,都看不到下影线了

1

主题

29

积分

0

精华

外汇入门

金钱
29 美元
权重
0
地板
 楼主| 发表于 2015-6-13 11:01 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 13:06 编辑

那这样不是很麻烦?有没有更好的解决办法?


1

主题

29

积分

0

精华

外汇入门

金钱
29 美元
权重
0
5
 楼主| 发表于 2015-6-13 11:03 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 13:06 编辑

这个为什么会这样,是什么原因呢?有没有直接加截上就正常的办法?真心感激


1

主题

29

积分

0

精华

外汇入门

金钱
29 美元
权重
0
6
 楼主| 发表于 2015-6-13 11:07 | 只看该作者
本帖最后由 wccmcd 于 2015-12-4 13:06 编辑

好的,有时间的时候希望能帮解决下,感谢


您需要登录后才可以回帖 登录 | 快捷注册(禁q号)

本版积分规则

QQ|黄金吧|黄金论坛|手机版|指标下载|非农|目录|交易危机

版权所有: ©2014-2021 fx3q.com Powered by Discuz! X3
浙ICP备: ICP14039028

浙公网安备 33011802001420号

风险提示:杠杆风险高,交易要谨慎 声明:坛友发言和回复均为个人观点,不代表论坛立场。
若有侵权请联系fx3q@qq.com删除

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