ICustom機能 - ページ 10

 

こんにちは、このエキスパートの精緻化について助けていただけませんか。

FreedomBarのインジケータをベースに...

前のマスが赤で閉じたら→売り(市場価格)→次の前のマスが青で閉じたら→買い(市場価格)。

買い注文の場合も同様

TF、TP、SL、トレーリングストップのオプションがあれば嬉しいです。

よろしくお願いします。

ファイル:
 

何か手助けがあればお願いします。icustomを使用したEAにインジケータを読み込んでいます。バックテストでは、トレンドは非常にうまく機能していますが、何らかの理由でicustomパラメータが反転し、インジケータがダウンを示していても、私のトレンドはダウンではなく、アップしています。

 
increase:
何かアドバイスがあればお願いします。私はicustomを使用してEAにインジケータを読み込んでいます。バックテストでは、トレンドは非常に幸せに実行されます。その後、何らかの理由でicustomパラメータが逆になって、私のトレンドはダウンではなくアップになっていますが、取引がアクティブになった後にインジケータはダウン表示になっています。その後、いくつかの時間後に再び起こります。

このインジケータはSuperTrend voltyに似ていますが、FX Sniper ErgodicやFisherの ような他の非リペイントインディケータでも問題がありました。

この問題は、インジケータが下降する方向を示しているのに、移動の開始点が終了点よりも低くなってしまい、インジケータは下降を示すがデータは上昇を示すということが多々あるように思われます。

また、このようなことがないリペイントしないインジケータをお持ちの方、または他のソリューションをお持ちの方はいらっしゃいますか?

添付の写真を見てください。

ファイル:
pic.jpg  38 kb
 

iCustom関数

こんにちは、初めての投稿です。

このEAは、インジケータの色に基づいてポジションをクローズするために使用されますが、私は手動でポジションを開くでしょう。

しかし、どのように色に基づいて関数を呼び出すのでしょうか?

例えば、Heikin Ashi_SWを使用していて、バーが閉じられた後、色が青の時に売りポジションを閉じたい場合、またはその逆の場合。

前もってありがとうございます。

 

ICustomの問題

私は#TestIndicatorというエクスターンなしのシンプルなカスタムインジケーターを持っていて、8つのバッファを1.0で満たしますが、私のEAでバッファを戻すと、バッファの結果は常に0です。あなたはこれで私を助けることができます。

#TestIndicator

#property indicator_chart_window

#property indicator_buffers 8

double buf4_up[];

double buf4_down[];

double buf3_up[];

double buf3_down[];

double buf2_up[];

double buf2_down[];

double buf1_up[];

double buf1_down[];

int UniqueNum = 0070;

string shortname = "";

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

//| Custom indicator initialization function |

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

int init()

{

shortname = "#TFX";

IndicatorBuffers(8);

IndicatorShortName(shortname);

//---- indicators

SetIndexBuffer(0,buf4_up);

SetIndexBuffer(1,buf4_down);

SetIndexBuffer(2,buf3_up);

SetIndexBuffer(3,buf3_down);

SetIndexBuffer(4,buf2_up);

SetIndexBuffer(5,buf2_down);

SetIndexBuffer(6,buf1_up);

SetIndexBuffer(7,buf1_down);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int limit;

int counted_bars = IndicatorCounted();

//---- the last calculated bar will be recalculated

if(counted_bars > 0)

counted_bars--;

limit = Bars - counted_bars - 1;

//---- the main cycle

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

{

//----

buf4_up=1.0;

buf4_down=1.0;

buf3_up=1.0;

buf3_down=1.0;

buf2_up=1.0;

buf2_down=1.0;

buf1_up=1.0;

buf1_down=1.0;

}

//----

//----

//----

return(0);

}

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

[/CODE]

EA Code

[CODE]

double test4_up[];

double test4_down[];

double test3_up[];

double test3_down[];

double test2_up[];

double test2_down[];

double test1_up[];

double test1_down[];

int UniqueNum = 009;

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

//| expert initialization function |

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

int init()

{

//----

Print("Inside init");

//----

return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{

//----

Print("Inside deinit");

//----

return(0);

}

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

//| expert start function |

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

int start()

{

//----

Print("Inside start");

int counted_bars=IndicatorCounted();

int y5m=0, y1h=0, y30m=0, y15m=0, yy=0;

int i=0;

int limit=Bars-counted_bars;

for(i=0;i<limit;i++)

{

test4_up = iCustom(NULL, 0, "#TestIndicator",0,i);

test4_down = iCustom(NULL, 0, "#TestIndicator",1,i);

}

for(i=0;i<30;i++)

{

Print("Test 4 UP ", test4_up," Bar ",i );

Print("Test 4 DOWN ", test4_down," Bar ",i );

//Print("This is a test");

}

//----

return(0);

}

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

テスターの結果

 
Xaun:
私は#TestIndicatorというエクスターンなしのシンプルなカスタムインジケーターを持っていて、8つのバッファを1.0という数字で埋めていますが、私のEAでバッファを戻すとバッファの結果は常に0です。この件で私を助けることができますか?

EAコード

double test4_up[];

double test4_down[];

double test3_up[];

double test3_down[];

double test2_up[];

double test2_down[];

double test1_up[];

double test1_down[];

int UniqueNum = 009;

..

..

...

......

..

int i=0;

int limit=Bars-counted_bars;

ArrayResize(test4_up, limit);

ArrayResize(test4_down, limit);

for(i=0;i<limit;i++)

{

test4_up = iCustom(NULL, 0, "#TestIndicator",0,i);

test4_down = iCustom(NULL, 0, "#TestIndicator",1,i);

}

for(i=0;i<30;i++)

{

Print("Test 4 UP ", test4_up," Bar ",i );

Print("Test 4 DOWN ", test4_down," Bar ",i );

//Print("This is a test");

}

//----

return(0);

}

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

]

多分、EAで配列のサイズを定義する必要があるのでしょう。

 

ありがとうございます

okfar:
多分、EAで配列のサイズを定義する必要があるのでしょう。

Okfarさん、ありがとうございます。まさにそれが問題でした。

 

データへのアクセス方法によっては、指標を再計算する必要がないように、各ティックで配列を再補充する必要はありません。

bool ArraySetAsSeries(double&array[],bool set) 配列のインデックス付けの方向を設定 します。set パラメータがTRUE値の場合、配列は逆順にインデックスされ、すなわち、最後の要素のインデックスは0となります。FALSE を指定すると、標準的なインデックス順序になります。この関数は,以前の状態を返します。

 

...

インジケータから専用に使用するための機能を使おうとしています。

IndicatorCounted() は、EAから呼び出された場合、全く意味を持ちません。EAコード内で呼び出された場合、常に-1を返します。代わりに定数を使うか(2番目のループのように)、Bars(全履歴が必要な場合)を使ってみてください。

また、EA内で使用される配列は、サイズや初期化など、通常メタトレーダーが指標や指標内のバッファに関して行うすべての作業を行う必要があります。EAには、インジケータで使われるSetIndexBuffer() に相当するものがありません。EAに初期化されていない配列があり、メタトレーダーだけがEAのクラッシュを防いでいます(読み込もうとする要素値が存在しないため、このような場合は常に0を返します)、実際、これらの配列は存在しません(宣言されているだけで、割り当て、初期化などされていません)。

よろしくお願いします。

mladen

Xaun:
私は#TestIndicatorというエクスターンなしのシンプルなカスタムインジケーターを持っていて、8つのバッファを数字1.0で満たします。この件で私を助けることができますか?

#TestIndicator

#property indicator_chart_window

#property indicator_buffers 8

double buf4_up[];

double buf4_down[];

double buf3_up[];

double buf3_down[];

double buf2_up[];

double buf2_down[];

double buf1_up[];

double buf1_down[];

int UniqueNum = 0070;

string shortname = "";

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

//| Custom indicator initialization function |

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

int init()

{

shortname = "#TFX";

IndicatorBuffers(8);

IndicatorShortName(shortname);

//---- indicators

SetIndexBuffer(0,buf4_up);

SetIndexBuffer(1,buf4_down);

SetIndexBuffer(2,buf3_up);

SetIndexBuffer(3,buf3_down);

SetIndexBuffer(4,buf2_up);

SetIndexBuffer(5,buf2_down);

SetIndexBuffer(6,buf1_up);

SetIndexBuffer(7,buf1_down);

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int limit;

int counted_bars = IndicatorCounted();

//---- the last calculated bar will be recalculated

if(counted_bars > 0)

counted_bars--;

limit = Bars - counted_bars - 1;

//---- the main cycle

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

{

//----

buf4_up=1.0;

buf4_down=1.0;

buf3_up=1.0;

buf3_down=1.0;

buf2_up=1.0;

buf2_down=1.0;

buf1_up=1.0;

buf1_down=1.0;

}

//----

//----

//----

return(0);

}

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

[/code]EA Code

[code]

double test4_up[];

double test4_down[];

double test3_up[];

double test3_down[];

double test2_up[];

double test2_down[];

double test1_up[];

double test1_down[];

int UniqueNum = 009;

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

//| expert initialization function |

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

int init()

{

//----

Print("Inside init");

//----

return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{

//----

Print("Inside deinit");

//----

return(0);

}

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

//| expert start function |

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

int start()

{

//----

Print("Inside start");

int counted_bars=IndicatorCounted();

int y5m=0, y1h=0, y30m=0, y15m=0, yy=0;

int i=0;

int limit=Bars-counted_bars;

for(i=0;i<limit;i++)

{

test4_up = iCustom(NULL, 0, "#TestIndicator",0,i);

test4_down = iCustom(NULL, 0, "#TestIndicator",1,i);

}

for(i=0;i<30;i++)

{

Print("Test 4 UP ", test4_up," Bar ",i );

Print("Test 4 DOWN ", test4_down," Bar ",i );

//Print("This is a test");

}

//----

return(0);

}

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

テスターでの結果...

 

コーディングに関する質問

あるインディケータが気に入っていて、2週間ほどデモを行い、かなり成功しました。 そのインジケーターに基づいて売買注文を自動化する方法はありますか? 簡単にまとめると、私が好きなインジケータが並ぶと、チャート上に小さな矢印が上下どちらかを指すというものです。 矢印がポップアップするときに、私のために注文を出す方法はありますか?