查看: 1026|回复: 4

【已解决】求助:想做iWPR的均线指标(有代码,在线等)

[复制链接]

11

主题

164

回帖

1106

积分

积分
1106
发表于 2014-6-17 16:41:09 | 显示全部楼层 |阅读模式
本帖最后由 shrimpn 于 2014-6-17 16:44 编辑

代码如下:
[mw_shl_code=cpp,true]#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 30
#property indicator_level2 70
#property indicator_buffers 1
#property indicator_color1  DodgerBlue

extern ushort   MA_Type=0;
extern int      MA_Period=1;
extern int      WR_Period=14;
//--- buffers
double MA_WPRBuffer[];
double WPRBuffer[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0,MA_WPRBuffer);
   SetIndexDrawBegin(0,WR_Period);

   IndicatorShortName("MA ("+IntegerToString(MA_Period)+") WPR("+IntegerToString(WR_Period)+")");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   int limit,i;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=MathMin(Bars-counted_bars,Bars-1);
   if(limit<WR_Period) return(-1);

   for(i=limit; i>=0; i--)
     {
      WPRBuffer=iWPR(NULL,0,WR_Period,i)+100;
      MA_WPRBuffer=iMAOnArray(WPRBuffer,0,MA_Period,0,MA_Type,i);
     }

   return(0);
  }
//+------------------------------------------------------------------+
[/mw_shl_code]

11

主题

164

回帖

1106

积分

积分
1106
 楼主| 发表于 2014-6-17 16:42:00 | 显示全部楼层
出来的结果不对,iMAOnArray的结果总是0。

点评

[attachimg]56087[/attachimg] [mw_shl_code=cpp,false]#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Aqua #property indicator_level1 0 #property indicator_  详情 回复 发表于 2014-6-17 17:31回复

40

主题

179

回帖

2913

积分

积分
2913
QQ
发表于 2014-6-17 17:31:52 | 显示全部楼层
shrimpn 发表于 2014-6-17 16:42
出来的结果不对,iMAOnArray的结果总是0。

eurusdh1.png

[mw_shl_code=cpp,false]#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Aqua
#property indicator_level1 0
#property indicator_level2 60
#property indicator_level3 -60

#property indicator_maximum 100
#property indicator_minimum -100
//---- input parameters

extern int WPR_Period= 14;
extern int  MA_Period=3;
extern int Limit=1440;
int  MA_Mode  =0;

double WPR[];
double MA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexDrawBegin(0,WPR_Period+MA_Period);
   SetIndexBuffer(0,MA);
   SetIndexBuffer(1,WPR);
   IndicatorShortName("MA_WPR("+WPR_Period+","+MA_Period+")");
   SetIndexLabel(0,"MA(WPR)");

   return(0); }

//+------------------------------------------------------------------+
int start() {
   int limit;
   int counted_bars=IndicatorCounted();
   int i;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   if (limit>Limit && Limit>0) limit = Limit;
   for (i = limit;i>=0;i--) WPR = (iWPR(Symbol(),Period(),WPR_Period,i)+50.0)*2.0;
   for (i = limit;i>=0;i--) MA = iMAOnArray(WPR,0,MA_Period,0,MA_Mode,i);
   return(0);
}
[/mw_shl_code]


评分

参与人数 1贡献 +10 金币 +5 收起 理由
熙羽 + 10 + 5 赞一个!

查看全部评分

QQ: 1034612103
博客: http://blog.sina.com.cn/boolapi

11

主题

164

回帖

1106

积分

积分
1106
 楼主| 发表于 2014-6-17 17:42:35 | 显示全部楼层
谢谢,本来我是想模拟Buffer的,看来不行。你的答案是对的。

1

主题

315

回帖

857

积分

积分
857
发表于 2014-12-17 19:23:04 | 显示全部楼层
不错,好好分享
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

风险提示:本站内容仅供学习交流,不构成投资建议;禁止开户导流、喊单与代客理财。系统已启用敏感词自动进审/禁发。 · 客服/举报
小黑屋|手机版|Archiver|联系我们|法律声明|智慧网

Powered by Discuz! X5.0 Licensed © 2001-2026 Discuz! Team.|京ICP备15025159号-2

QQ客服返回顶部