Dxdcn 如何实现若干个数值求和 我这个指标始终无法实现,请看看。 新评论 markblog 2008.03.06 11:34 //+------------------------------------------------------------------+ //| Lius-easy1.0- | //| Copyright ?2007, MetaQuotes Software Corp. | //| https://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright ?2007, MetaQuotes Software Corp." #property link "https://www.metaquotes.net/" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 DarkGreen #property indicator_color3 Black //---- buffers double sum1[]; double sum2[]; double sum3[]; double ExtMapBuffer1[]; // 多方力量的指标 double ExtMapBuffer2[]; // 空方力量的指标 double ExtMapBuffer3[]; // 多空力量的差值 extern int n=30; // 计算多个指标值相加的周期参数 共Periodma个指标值相加 //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,sum1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,sum2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,sum3); SetIndexDrawBegin(0,1); IndicatorShortName("Lius-easy1.0-"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- macd counted in the 1-st buffer double a0,b0,c0,d0,a1,b1,c1,d1; for(int i=limit; i>=0; i--) { a0=Open[i]; b0=Close[i]; c0=High[i]; d0=Low[i]; a1=Open[i+1]; b1=Close[i+1]; c1=High[i+1]; d1=Low[i+1]; if(b0>=a0) //yangzhu { if(a0-b1>0) { ExtMapBuffer1[i]=MathRound(((a0-b1)+(c0-d0))/Point); ExtMapBuffer2[i]=MathRound(((b0-c0)+(d0-a0))/Point); ExtMapBuffer3[i]=MathRound((b0-b1)/Point); } if (a0-b1<=0) { ExtMapBuffer1[i]=MathRound((c0-d0)/Point); ExtMapBuffer2[i]=MathRound(((b0-c0)+(d0-a0)+(a0-b1))/Point); ExtMapBuffer3[i]=MathRound((b0-b1)/Point); } } //yinzhu if(b0<a0) { if(a0-b1>0) { ExtMapBuffer1[i]=MathRound(((c0-a0)+(b0-d0)+(a0-b1))/Point); ExtMapBuffer2[i]=MathRound((d0-c0)/Point); ExtMapBuffer3[i]=MathRound((b0-b1)/Point); } if (a0-b1<=0) { ExtMapBuffer1[i]=MathRound(((c0-a0)+(b0-d0))/Point); ExtMapBuffer2[i]=MathRound(((d0-c0)+(a0-b1))/Point); ExtMapBuffer3[i]=MathRound((b0-b1)/Point); } } // } // // for(i=limit;i>=0;i--) { double SUM1=0; int j; for (j=0;j<n;j++) { SUM1=SUM1+ExtMapBuffer1[i+j]; } sum1[i]=SUM1; } //---- return(0); } //+------------------------------------------------------------------+ 持续改进中的多空力量对比指标,2个版本,请大家继续改进。 这么个简单的程序为什么画不出线呢?请教牛牛们。 欢迎来到MQL4课程 okwh 2008.03.11 14:18 #1 加上“ IndicatorBuffers(6); ..... SetIndexBuffer(3,sum1); SetIndexBuffer(4,sum2); SetIndexBuffer(5,sum3); markblog 2008.03.12 16:12 #2 谢谢 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
//+------------------------------------------------------------------+
//| Lius-easy1.0- |
//| Copyright ?2007, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2007, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 DarkGreen
#property indicator_color3 Black
//---- buffers
double sum1[];
double sum2[];
double sum3[];
double ExtMapBuffer1[]; // 多方力量的指标
double ExtMapBuffer2[]; // 空方力量的指标
double ExtMapBuffer3[]; // 多空力量的差值
extern int n=30; // 计算多个指标值相加的周期参数 共Periodma个指标值相加
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,sum1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,sum2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,sum3);
SetIndexDrawBegin(0,1);
IndicatorShortName("Lius-easy1.0-");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
double a0,b0,c0,d0,a1,b1,c1,d1;
for(int i=limit; i>=0; i--)
{
a0=Open[i];
b0=Close[i];
c0=High[i];
d0=Low[i];
a1=Open[i+1];
b1=Close[i+1];
c1=High[i+1];
d1=Low[i+1];
if(b0>=a0)
//yangzhu
{
if(a0-b1>0)
{
ExtMapBuffer1[i]=MathRound(((a0-b1)+(c0-d0))/Point);
ExtMapBuffer2[i]=MathRound(((b0-c0)+(d0-a0))/Point);
ExtMapBuffer3[i]=MathRound((b0-b1)/Point);
}
if (a0-b1<=0)
{
ExtMapBuffer1[i]=MathRound((c0-d0)/Point);
ExtMapBuffer2[i]=MathRound(((b0-c0)+(d0-a0)+(a0-b1))/Point);
ExtMapBuffer3[i]=MathRound((b0-b1)/Point);
}
}
//yinzhu
if(b0<a0)
{
if(a0-b1>0)
{
ExtMapBuffer1[i]=MathRound(((c0-a0)+(b0-d0)+(a0-b1))/Point);
ExtMapBuffer2[i]=MathRound((d0-c0)/Point);
ExtMapBuffer3[i]=MathRound((b0-b1)/Point);
}
if (a0-b1<=0)
{
ExtMapBuffer1[i]=MathRound(((c0-a0)+(b0-d0))/Point);
ExtMapBuffer2[i]=MathRound(((d0-c0)+(a0-b1))/Point);
ExtMapBuffer3[i]=MathRound((b0-b1)/Point);
}
}
//
}
//
//
for(i=limit;i>=0;i--)
{
double SUM1=0;
int j;
for (j=0;j<n;j++)
{
SUM1=SUM1+ExtMapBuffer1[i+j];
}
sum1[i]=SUM1;
}
//----
return(0);
}
//+------------------------------------------------------------------+