如何编码? - 页 338

 
at120:
嗨,马登!

谢谢你的支持!;-)

甚至,当我像你告诉我的那样写代码时。

(我想是的...)

#property indicator_chart_window

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

for(int i = limit; i>=0; i--)

{

mom1 = iCustom(NULL,0,"custom name",0,i);

buffer = (

Mom(mom1,10,Bars,i);

//doesn't work - no value in indi

// Mom(mom1,10,Bars,i); //error: parameter conversation not allowed

// mom1 // this works

);

}

return(0);

}

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

);

所以当我使用 "第一个 "版本时,我没有得到任何值。

当我使用第二个版本时,我得到了错误...嗯。

只有调用mom1才有效...但这不是正确的值...

谢谢你的帮助!

再见,AT

"自定义名称 " 替换为你的指标名称(现有指标),在iCustom()调用中添加参数,就可以工作了。该名称只是作为一个例子放在那里

另外,你没有定义缓冲区的数量(没有使用#property indicator_buffers,也没有使用IndicatorBuffers()函数),指标 "认为 "有0个缓冲区,它永远不会把这些家伙初始化为真实大小。定义你要使用的缓冲区的数量

_______________________

 

嗨,Mladen!

谢谢你的信息...我已经这样做了...代码看起来像这样。

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

for(int i = limit; i>=0; i--)

{

mom1 = iCustom(NULL,0,"myIndi",0,i);

buffer = (

Mom(mom1,10,Bars,i); //doesn't work - no value in indi

// Mom(mom1,10,Bars,i); //error: parameter conversation not allowed

// mom1 // this works, but no subfunction incl.

);

}

return(0);

}

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

);

谈话的错误仍然存在...

谢谢你的帮助!

再见,AT

 
at120:
嗨,Mladen!

谢谢你的信息...我已经这样做了...代码看起来像这样。

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

for(int i = limit; i>=0; i--)

{

mom1 = iCustom(NULL,0,"myIndi",0,i);

buffer = (

Mom(mom1,10,Bars,i); //doesn't work - no value in indi

// Mom(mom1,10,Bars,i); //error: parameter conversation not allowed

// mom1 // this works, but no subfunction incl.

);

}

return(0);

}

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

);

谈话的错误仍然存在...

谢谢你的帮助!

再见,AT

下面是一个没有编译器错误的版本。_test.mq4

我不知道什么是 "myIndi",所以无法测试iCustom()是否从你的 "myIndi "指标中返回值。

附加的文件:
copiler.gif  52 kb
_test.mq4  2 kb
 

嗨,Mladen!

我的indi是JMA.mq4/JMA Indi的正常输出。

它也可能是MA输出或其他任何东西。"myIndi "不是特殊的indi。

调用indi在正常的indi窗口中工作......

我的代码看起来像这样。

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

for(int i = limit; i>=0; i--)

{

mom1 = iCustom(NULL,0,"JMA",0,i); //normal JMA / MA output

// I get this out put, and it's ok, but the second output (buffer) is zero...

buffer = (

Mom(mom1,10,Bars,i); //no compiler error, but doesn't work - no value in indi window

// Mom(mom1,10,Bars,i); //error: parameter conversation not allowed

// mom1 // this works, but it's the value i want

);

}

return(0);

}

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

);

我没有得到我所做的失败...

非常感谢你的帮助!!

再见,AT

 

嗨,Mladen!

当我这样写或改变它时...

我也得到了对话错误...有什么想法...?

非常感谢!

再见,AT

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

//#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

for(int i = limit; i>=0; i--)

{

mom1 = iMA(Symbol(),Period(),13,8,MODE_SMMA,PRICE_MEDIAN,i); //normal JMA / MA output

// I get this out put, and it's ok, but the second output (buffer) is zero...

buffer = (

// Mom(mom1,10,Bars,i) //no compiler error, but doesn't work - no value in indi window

Mom(mom1,10,Bars,i) //error: parameter conversation not allowed

// mom1 // this works, but it is NOT the value i want

);

}

return(0);

}

 
at120:
嗨,Mladen!

当我这样写或改变它时...

我也得到了对话错误......有什么想法吗?

非常感谢!

再见,AT

#property indicator_separate_window

#property indicator_color3 Red

#property indicator_width1 3

#property indicator_buffers 3

#property indicator_color1 LawnGreen

#property indicator_color2 Red

//#include // here the mom() function is incl.

double buffer[];

double mom1[];

int init() { SetIndexBuffer(0,buffer); SetIndexBuffer(1,mom1);return(0); }

//normaly in mqh incl.

double Mom(const double& series[], int period, int totcount, int index)

{

if (totcount<1 || period<1) return (EMPTY_VALUE);

if (indextotcount-1) return (EMPTY_VALUE);

return (series-series);

}

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

for(int i = limit; i>=0; i--)

{

mom1 = iMA(Symbol(),Period(),13,8,MODE_SMMA,PRICE_MEDIAN,i); //normal JMA / MA output

// I get this out put, and it's ok, but the second output (buffer) is zero...

buffer = (

// Mom(mom1,10,Bars,i) //no compiler error, but doesn't work - no value in indi window

Mom(mom1,10,Bars,i) //error: parameter conversation not allowed

// mom1 // this works, but it is NOT the value i want

);

}

return(0);

}

at120

当预期的参数 应该是const double[] 时,你不能使用演化为double 的元素。与其使用 "mom1",不如使用 "mom1"

 

嗨,Mladen!

谢谢你的回答,我现在的问题是,如何将我的双数 "转换 "为我的常数双数系列[] 。

因为当我只用mom1的时候,我得到一个 "0 "作为输出......

所以我怎样才能使mom1 "看起来像 "例如Close。是否有任何示例代码?

非常感谢,再见,AT

 
at120:
嗨,Mladen!

谢谢你的回答,那么我现在的问题是,如何将我的双数 "转换 "为我的常数双数系列[] 。

因为当我只使用mom1时,我得到一个 "0 "作为输出...。

所以我怎样才能使mom1 "看起来像 "例如Close。是否有任何示例代码?

非常感谢,再见,AT

你不需要 "转换 "任何东西。当""部分被删除时,它就 "变成 "适当的参数。

以下是它在图表上的样子。

这里是代码。_test_2.mq4

附加的文件:
_test_2.mq4  1 kb
test.gif  64 kb
 

嗨,Mladen!

现在对我有用了,似乎我忘记了IndicatorBuffers(2)。

现在看来,我得到了正确的值

非常感谢你的帮助!!

再见,AT

 

哪些数组需要在函数参数 中被声明为常数?