交易危机

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

QQ登录

只需一步,快速开始

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

[其他] 布林线指标详解(二)我的布林

[复制链接]

2127

主题

6万

积分

157

精华

大型投行

金钱
61335 美元
权重
640
跳转到指定楼层
楼主
发表于 2017-8-18 10:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

炒外汇论坛
这一篇叫:我的布林

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Black
#property indicator_color3 Black
//---- indicator parameters
extern int    BP=60;
extern int    BS=0;
extern double BD=2;
//---- buffers
double MB[];
double UB[];
double LB[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,0,2,Blue);
   SetIndexBuffer(0,MB);
   SetIndexStyle(1,DRAW_LINE,0,2,Black);
   SetIndexBuffer(1,UB);
   SetIndexStyle(2,DRAW_LINE,0,2,Black);
   SetIndexBuffer(2,LB);
//----
   SetIndexDrawBegin(0,BP+BS);
   SetIndexDrawBegin(1,BP+BS);
   SetIndexDrawBegin(2,BP+BS);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Bollinger Bands                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k,counted_bars=IndicatorCounted();
   double deviation;
   double sum,oldval;
//----
   if(Bars<=BP) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=BP;i++)
        {
         MB[Bars-i]=EMPTY_VALUE;
         UB[Bars-i]=EMPTY_VALUE;
         LB[Bars-i]=EMPTY_VALUE;
        }
//----
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++;
   for(i=0; i<limit; i++)
      MB=iMA(NULL,0,BP,BS,0,0,i);
//----
   i=Bars-BP+1;
   if(counted_bars>BP-1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      sum=0.0;
      k=i+BP-1;
      oldval=MB;
      while(k>=i)
        {
         sum+=MathAbs(Close[k]-oldval);
         k--;
        }
      deviation=sum/BP*BD;
      UB=oldval+deviation;
      LB=oldval-deviation;
      i--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

本帖被以下淘专辑推荐:

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

5

主题

1万

积分

1

精华

操盘专家

金钱
12951 美元
权重
0
沙发
发表于 2017-10-27 18:33 | 只看该作者
占领沙发

0

主题

179

积分

0

精华

见习操盘手

金钱
179 美元
权重
0
板凳
发表于 2018-3-4 20:22 | 只看该作者
好东西,谢谢分享

1

主题

1810

积分

0

精华

初级操盘手

金钱
1810 美元
权重
0
地板
发表于 2018-3-14 10:23 | 只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 快捷注册(禁q号)

本版积分规则

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

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

浙公网安备 33011802001420号

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

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