コーディングのヘルプ - ページ 62

 

...

2つのことをしなければなりません
: - "period "変数をdoubleとして宣言する(MQLは、除算で整数型変数が使われると時々奇妙な動作をします)

- "period "変数を初期化する(今は初期化されていないので、最後のステップがうまくいかなかった理由です)

その後、あなたはこのようなものを得るでしょう。

よい週末を

chenairbin:
#property indicator_separate_window

#プロパティ indicator_buffers 1

#property indicator_color1 レッド

#プロパティ indicator_maximum 100

#property indicator_level1 70 (インジケーターレベル1)

#property indicator_level2 50

#property indicator_level3 30

#property indicator_minimum 0

//---- 入力パラメータ

extern int rsiperiod = 14 ;

extern int Shortperiod = 5 ;

extern int Middleperiod = 8;

extern int Longperiod = 13;

extern int mamode = 2 ;

//---- バッファ

double RSI[];

double ShortRSI[];

double MiddleRSI[];

double LongRSI[];

double SMRSI[];

int period ;

//+------------------------------------------------------------------+

//| カスタムインジケータ初期化関数

//+------------------------------------------------------------------+

int init()

{

//---- インジケータ

IndicatorBuffers(5);

SetIndexBuffer(0,SMRSI)。

SetIndexBuffer(1,RSI); //SetIndexBuffer(0,SMRSI)を設定します。

SetIndexBuffer(2,ShortRSI); SetIndexBuffer(2,ShortRSI);

SetIndexBuffer(3,MiddleRSI)。

SetIndexBuffer(4,LongRSI)を設定します。

//DataWindowとIndicatorサブウィンドウのラベルの名前

IndicatorShortName("SMRSI("+rsiperiod+", "+Shortperiod+", "+Middleperiod+", "+Longperiod+", "+mamode+")");

SetIndexDrawBegin(0,rsiperiod+Longperiod)を設定します。

period=Shortperiod+Middleperiod+Longperiod。

return(0);

}

//+------------------------------------------------------------------+

//| カスタムインジケーターイテレーション機能

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted();

int i,limit;

if(counted_bars<0)リターン(-1);

if(counted_bars>0)counted_bars--。

limit = Bars-counted_bars;

for( i=limit; i>=0; i--) RSI=iRSI(NULL,0,rsiperiod,0,i);

for( i=limit; i>=0; i--) ShortRSI=iMAOnArray(RSI,0,Shortperiod,0,mamode,i);

for( i=limit; i>=0; i--) MiddleRSI=iMAOnArray(RSI,0,Middleperiod,0,mamode,i)。

for( i=limit; i>=0; i--) LongRSI=iMAOnArray(RSI,0,Longperiod,0,mamode,i)。

for( i=limit; i>=0; i--) { if(period!=0) SMRSI=(Shortperiod/period)*ShortRSI+(Middleperiod/period)*MiddleRSI+(Longperiod/period)*LongRSI;}; }.

return(0);

//+------------------------------------------------------------------+
ファイル:
smrsi.gif  33 kb
_test0.mq4  3 kb
 

n_n

mladen:
2つのことをしなければなりません
: - "period "変数をdoubleとして宣言する(MQLは、除算で整数型変数が使われると、時々奇妙な動作をします)

- "period "変数を初期化する(今は初期化されていないので、最後のステップはうまくいかないわけです)

その後、あなたはこのようなものを取得します。

良い週末をお過ごしください。

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

 

こんにちは。

mql4のサイトに添付されているインジケータをダウンロードしました。このインディケータをベースにEAを作ろうとしたのですが、バックテストを始めると数秒後にプラットフォームがクラッシュしてしまいます。

そこで、この問題を解決するために、コードを軽くすることが可能かどうかを尋ねています。

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

cronex_taichi.mq4

ファイル:
 

ダシオ

このスニペットでテストしてみましたが、問題なく動きました。パラメータが分からないので、デフォルトのインジケータを呼び出しているだけですが、この方法で問題ありません。

int init()

{

return(0);

}

int start()

{

Comment(iCustom(NULL,0,"Cronex Taichi",0,0));

return(0);

}

dasio:
こんにちは。

mql4のサイトに添付されているインジケータをダウンロードしました。このインジケータをベースにEAを作ろうとしたのですが、数秒後にバックテストを開始するとプラットフォームがクラッシュしてしまいます。

そこで、この問題を解決するために、コードを軽くすることが可能かどうかを尋ねています。

ご対応ありがとうございます。

cronex_taichi.mq4
 
mladen:
ダシオ

このスニペットでテストしてみましたが、問題なく動きました。使用したパラメータが分からないので、デフォルトのインジケータを呼び出しているだけですが、この方法で問題ありません

int init()

{

return(0);

}

int start()

{

Comment(iCustom(NULL,0,"Cronex Taichi",0,0));

return(0);

}

ご回答ありがとうございます。

履歴を見ると何度もインジケーターが読み込まれていたので、icustomのコードを新しいキャンドルイベントの中だけに移動させましたが、問題はまだ残っています。

私はなぜかわからない。

しかし、あなたの柔軟性をありがとうございました。

 

こんにちは。

問題を発見しました。今はすべてOKです。

私は別のEAで別の問題があります。

私はこの2つのコードを持っていて、関数 Lotti()は私にordersendのためのロット数を返すでしょう。

私はそれをコンパイルするとき、私はPosizioni Internal Errorを受け取る。何が間違っているのですか?ありがとうございます。

int OTBM(int intMagic)//OrdersTotalByMagic

{

int intCount=0;

int intPOS=0;

bool boolTerm=false;

while(boolTerm==false)

{

if(OrderSelect(intPOS,SELECT_BY_POS))

{

if(OrderMagicNumber()==intMagic) intCount++;

intPOS++;

}

else

boolTerm=true;

}

return(intCount);

}

[/PHP]

[PHP]int Lotti(){

int Lotti;

int Posizioni=OTBM(MagicNumber);

switch (Posizioni)

{

case 0 : Lotti=0.1; break;

case 1 : Lotti=0.2; break;

case 2 : Lotti=0.4; break;

case 3 : Lotti=0.8; break;

case 4 : Lotti=1.6; break;

case 5 : Lotti=3.2; break;

case 6 : Lotti=6.4; break;

case 7 : Lotti=12.8; break;

}

return(Lotti);

}
 

OTBM()を次のように置き換えてみてください。

int OTBM(int intMagic)//OrdersTotalByMagic

{

int intCount=0;

for (int i=OrdersTotal()-1; i>=0; i--)

{

if(OrderSelect(i,SELECT_BY_POS))

{

if(OrderMagicNumber()==intMagic) intCount++;

}

}

return(intCount);

}

[/PHP]

dasio:
Hi,

i found the problem. Now all its ok.

I have another problem with another ea.

I have this two code and the function Lotti() would be return me the number of lot for an ordersend.

When i compile it i receive Posizioni Internal Error. What's wrong? Thank you;

int OTBM(int intMagic)//OrdersTotalByMagic

{

int intCount=0;

int intPOS=0;

bool boolTerm=false;

while(boolTerm==false)

{

if(OrderSelect(intPOS,SELECT_BY_POS))

{

if(OrderMagicNumber()==intMagic) intCount++;

intPOS++;

}

else

boolTerm=true;

}

return(intCount);

}

[PHP]int Lotti(){

int Lotti;

int Posizioni=OTBM(MagicNumber);

switch (Posizioni)

{

case 0 : Lotti=0.1; break;

case 1 : Lotti=0.2; break;

case 2 : Lotti=0.4; break;

case 3 : Lotti=0.8; break;

case 4 : Lotti=1.6; break;

case 5 : Lotti=3.2; break;

case 6 : Lotti=6.4; break;

case 7 : Lotti=12.8; break;

}

return(Lotti);

}
 

ハイ、-.-"

私はこれらのコードで平和を見つけることはありませんeheheh。

私は私にすべてのopenorderの利益をもたらす必要がある関数の 問題を持っていますが、私はそれが条件が尊重されたことがないので、動作しないと思います。以下はそのコードです。

.....

if(Profit()>=0.....[/PHP]

[PHP]double Profit()

{

int total=OrdersTotal();

double profit=0;

for(int i=0; i<total; i++)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) continue;

profit+=OrderProfit();

}

return(profit);

}
 

ダシオ

こんな感じで試してみてください。

.....

if(Profit()>=0.....[/PHP]

double Profit()

{

int total=OrdersTotal();

double profit=0;

for(int i=0; i<total-1; i++)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;

profit+=OrderProfit();

}

return(profit);

}[/PHP]

dasio:
Hi, -.-"

I do not find peace with these codes eheheh.

I have a problem with a function that have to result me the profit of all openorder but i think it's not work because the condition never been respected. Below the code:

[PHP].....

if(Profit()>=0.....

[PHP]double Profit()

{

int total=OrdersTotal();

double profit=0;

for(int i=0; i<total; i++)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) continue;

profit+=OrderProfit();

}

return(profit);

}
 
mladen:
ダシオ

このように試してみてください。

.....

if(Profit()>=0.....[/PHP]

[PHP]double Profit()

{

int total=OrdersTotal();

double profit=0;

for(int i=0; i<total-1; i++)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;

profit+=OrderProfit();

}

return(profit);

}

この方法では、指定したマジックナンバーでオープンされていない注文をチェックするのですよね?特定のシンボルとマジックナンバーの注文をチェックする必要があるんだ。重要かどうかわかりませんが、Strategy Testerでエラーを 発見しました。