if(ObjectFind(Trend2Name) != -1) // Check whether mid range line exists {
if((TimeDay(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeDay(TimeCurrent())) && (TimeMonth(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeMonth(TimeCurrent())) && (TimeYear(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeYear(TimeCurrent()))) // Indicator has already been ploted today { return(rates_total); } else// Indicator exists but in a past date, so delete it and plot it on current day { if(DebugLog) Print("Indicator in a past date! Deleting it and creating it today!");
if(ObjectFind(FibName) != -1) FiboLevelsDelete(0,FibName); // Indicator will be created by the OnChartEvent() when it detects the fib was deleted. } } else// Indicator doesn't exist, so create it { if(DebugLog) Print("Indicator doesn't exist! Creating it."); CreateIndicator(); } :
さて、皆さん、最初の部分は完了しました(すべてのペアのレートを読む)。
今私はRSIのようないくつかのグラフィック指標をポットする関数ArrayCopyRatesでコピーされたすべてのパリのレートを使用する必要があります...私は下の画像に描画するように。
私の最初の質問では、私はこれを行う方法を知っているつもりです...とレートを読み取ることについてではありません。私はそれを描画する前に、レートをコピーする必要があるとは思わないが、行う方法を知って良かった...今私はちょうどすべてのペアをプロットするための指標領域を分割する方法を発見する必要がある...
インジケータ領域を分割する方法はありません。すべて別々に描画する必要があり、バッファも自動スケーリングもありません。ご覧ください。
こんな絵があったんですか?(MetaQuotes Software Corp.) - MQL4 forum - Page 12
こんな絵があったんですか?(MetaQuotes Software Corp.) - MQL4 forum - Page 14
こんな写真見たことある?(MetaQuotes Software Corp.) - MQL4 forum - Page 36
インジケータ領域を分割する方法はありません。すべて別々に描画する必要があり、バッファも自動スケーリングもありません。ご覧ください。
こんな絵があったんですか?(MetaQuotes Software Corp.) - MQL4 forum - Page 12
こんな絵があったんですか?(MetaQuotes Software Corp.) - MQL4 forum - Page 14
こんな写真見たことある?(MetaQuotes Software Corp.) - MQL4 forum - Page 36
これはどこかで拾ったIndicatorだが、解読しようとしたことはない。現在のチャートの3つのタイムフレームを表示しています。面白いのはローソク足がヒストグラムで描かれていること。かなりきれいですが、私が今興味のあるものではありません。
ベストウィッシュ
このスレッドを見ている人たちに、最新情報をお知らせします
彼は英語が苦手で、私たちはポルトガル語を話すので、私はPMでOPのコードの修正を手伝っています。テストでは、"ArrayCopyRates() "関数で起こっている別の "おかしい "ことに気づきました。EAでMqlRates 配列を"ArrayCopyRates() "で使用する場合、データ配列は常に現在の状態を報告する仮想のものであり、データは常に新鮮である。
しかし、Indicatorの場合はそうではないようです。配列は仮想的なコピーではなく、「ArrayCopyRates()」が呼ばれた瞬間に設定された静的なコピーになっています。シンボルがチャートシンボルと異なる場合、データが更新されない。チャートと同じシンボルであれば、配列データは「ライブ」で期待通りに更新されますが、別のシンボルであれば、静的コピーとなります。
したがって、インジケータで動作させるためには、OnCalculate()イベントを呼び出すたびに、新しいデータが必要であれば、"ArrayCopyRates()"関数を呼び出さなければなりません。
Fernandoの知見を拡大すると、シンボルがチャートシンボルと同じであっても、タイムフレームが異なれば、配列は静的なものになります。
ですから、インジケータで仮想コピーを持つには、同じシンボルかつ同じタイムフレームでなければなりません。それ以外は静的です。
週半ばと仮定して、前日の高値と安値を見つけるために、私は単に使用します。
Lo = iLow(NULL, PERIOD_D1, 1);
それはいいのですが、今度は前日の最高値と最安値が何時だったかを調べる必要があります。そこで、iHighestとiLowestを使って、1時間足のローソク足の高値と安値の時刻を推定することにした。そこで問題が発生しました。
PrevDayEnd = iBarShift(NULL, PERIOD_H1, iTime(NULL, PERIOD_D1, 0)-1);
PrevDayBegin--;
MqlRates mqlrates_array_d1[];
MqlRates mqlrates_array_h1[];
MqlRates mqlrates_array[];
ArrayCopyRates(mqlrates_array_d1,NULL,PERIOD_D1);
ArrayCopyRates(mqlrates_array_h1,NULL,PERIOD_H1);
ArrayCopyRates(mqlrates_array,NULL,0);
OnInit();
:
isHistoryLoading = true;
:
OnCalculate( ... )
:
MqlRates mqlrates_array_d1[];
MqlRates mqlrates_array_h1[];
MqlRates mqlrates_array[];
if(isHistoryLoading)
{
ResetLastError();
if(ArrayCopyRates(mqlrates_array_d1,NULL,PERIOD_D1)>0)
{
if(GetLastError() == 0)
{
if((iTime(NULL,PERIOD_D1,0) > 0) && (iTime(NULL,PERIOD_D1,1) > 0))
{
ResetLastError();
if(ArrayCopyRates(mqlrates_array_h1,NULL,PERIOD_H1)>0)
{
if(GetLastError() == 0)
{
if((iTime(NULL,PERIOD_H1,0) > 0) && (iTime(NULL,PERIOD_H1,1) > 0))
{
ResetLastError();
if(ArrayCopyRates(mqlrates_array,NULL,0)>0)
{
if(GetLastError() == 0)
{
if((iTime(NULL,0,0) > 0) && (iTime(NULL,0,1) > 0))
{
isHistoryLoading = false;
if(DebugLog)
Print("Chart up-to-date!");
}
}
}
}
}
}
}
}
}
}
if(isHistoryLoading)
{
if(DebugLog)
Print("Waiting for chart to update!");
return(rates_total);
}
:
:
if(ObjectFind(Trend2Name) != -1) // Check whether mid range line exists
{
if((TimeDay(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeDay(TimeCurrent()))
&& (TimeMonth(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeMonth(TimeCurrent()))
&& (TimeYear(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeYear(TimeCurrent()))) // Indicator has already been ploted today
{
return(rates_total);
}
else // Indicator exists but in a past date, so delete it and plot it on current day
{
if(DebugLog)
Print("Indicator in a past date! Deleting it and creating it today!");
if(ObjectFind(FibName) != -1)
FiboLevelsDelete(0,FibName);
// Indicator will be created by the OnChartEvent() when it detects the fib was deleted.
}
}
else // Indicator doesn't exist, so create it
{
if(DebugLog)
Print("Indicator doesn't exist! Creating it.");
CreateIndicator();
}
:
数ティック後にデータが部分的にロードされ、上記のコード片はラインが前日にプロットされたことを検出し、fibを削除し、範囲の再計算とオブジェクト(すなわちfib、トレンドラインなど)の再描画をトリガーします。
CurrDayBegin = iTime(NULL, PERIOD_D1, 0);
while(TimeDayOfWeek(iTime(NULL, PERIOD_H1, iBarShift(NULL, PERIOD_H1, CurrDayBegin))) != TimeDayOfWeek(TimeCurrent()))
// If iBarShift can't find the 0am candle and returns the 11pm candle of prev day.
CurrDayBegin = CurrDayBegin + 3600; // Move 1h until you find the 1st candle of today.以下はインジケーターのスクリーンショットです。
(1) 不完全な履歴を使って計算したもの (水平線が日の初めから始まっていないことに注意してください)
(2) 完全な履歴を使用して再計算したもの(水平線が日の始めから始まっている)。