コーディングの方法は? - ページ 338

 
at120:
こんにちは、Malden!

応援ありがとうございました! ;-)

教えていただいたようにコードを書いても

(そうだと思うのですが...)

#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);

}

);

ということで、「第一版」を使うと値が出ず...。

2番目のバージョンを使用すると、私はエラーが発生します...うーん。

mom1を呼ぶのだけはうまくいくのですが...これは正しい値ではないのですね...。

ありがとうございました。

バイバイ、AT

カスタム名 " をインジケータ(既存インジケータ)の名前に置き換え、iCustom()の呼び出しにパラメータを追加すれば、動作するようになります。この名前はあくまで例として置いてあります。

また、バッファの数を定義していません(#property indicator_buffersやIndicatorBuffers()関数を 使用していません)。使用するバッファの数を定義してください。

_______________________

 

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さん、こんにちは。

私のインジは、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

 

ムラデンさん、こんにちは。

このように書いたり変更したりすると

会話エラーも出てしまいます...何かいい方法はありませんか?

ありがとうございました。

さようなら、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!

そこで質問なのですが、double 型をどのように const double series[] に "変換" するのでしょうか?

というのも、mom1だけを使用すると、出力として「0」が得られるからです...。

というのも、mom1だけを使うと出力が「0」になってしまうからです。そのためのサンプルコードはありますか?

ありがとうございました。

 
at120:
こんにちは、Mladen!

回答ありがとうございます、そこで質問ですが、私のdoubleを私のconst double series[]に「変換」する方法です。

というのも、mom1だけを使用すると、出力として「0」が得られるからです...。

というのも、mom1だけを使うと出力が「0」になってしまうからです。サンプルコードはありますか?

どうもありがとうございます。

何も「変換」する必要はありません。""の部分を削除した瞬間に、ちゃんとしたパラメータになります。

チャート上での見え方はこんな感じです。

そして、これがコードです。_test_2.mq4

ファイル:
_test_2.mq4  1 kb
test.gif  64 kb
 

こんにちは、Mladen!

IndicatorBuffers(2)を忘れていたようで、これでうまくいきました。

今は正しい値が表示されているようです。

助けてくれてありがとうございます。

さようなら、AT

 

関数の パラメータでconstとして宣言する必要があるのはどのような配列ですか?