メタトレーダー4でMT4の時間ベースのエントリ信号
-
22-09-2019 - |
質問
んの誰もがメタトレーダー4に進入信号をベースと時刻を生成する方法のための任意のコード例がありますか?例えば毎日の特定の時間と分での
解決
私は、このようなA機能に取り組んできました。 sが、それは、独自のinclude
ファイルが必要になりますので、大きくて退屈になるだろう。それは多くのことを - 私はより一般的なバージョンを作ることに取り組んでカスタマイズする必要があります。しかし、コードを変更せずに別のチャートに貼り付けできるように価値があるでしょう。それは基本的に私はここに、個々の時間枠に、既にカスタマイズされているものとの一つの大きなcase文になります。
あなたは上で何をして取り組んできましたか?時間や外国為替にご関心をお寄せいただきありがとうございます!
bool existordertime( datetime time, int otype = -37 ) {
// +---------------------------------------------------------------+
// | this function is intended for use inside of if() and other conditionals
// | usually called with TimeCurrent() example:
// |
// | if ( !existordertime( TimeCurrent() ) )
// |
// | it accepts a datetime. A datetime is:
// | a number of seconds elapsed from 00:00 January 1, 1970
// | they can be treated as integers as such or accessed with other functions
// | so that if statements can be commented in and out easily based on what
// | timeframe we plan on looking at.
// | there is an optional parameter for an order type if you need it.
// |
// | KEEP IN MIND if you want to use this to trade something like a 5min 15min
// | or 4hr your gonna need a lot of if statements like:
// |
// | if ( MathMod( Minute() + 5, 5 ) == 0 )
// |
// +------------------------------------------------------------------+
for (int cnt = 0; cnt < OrdersTotal(); cnt++) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == otype || -37 == otype)
// COMMENT OUT THE if()S YOU DON'T NEED HERE:
// also add new lines as needed
// if ( MathMod( TimeMinute( time ) + 5, 5 ) == 0 ) // 5min chart
// if ( MathMod( TimeMinute( time ) + 15, 15 ) == 0 ) // 15min chart
// if ( MathMod( TimeMinute( time ) + 30, 30 ) == 0 ) // 30min chart
// if ( MathMod( TimeHour( time ) + 4, 4 ) == 0 ) // 4hour chart
int dbOrderOpenTime = OrderOpenTime(); // re-use SAVEs dbPOOL-access time ...
if ( TimeSeconds( time ) == TimeSeconds( dbOrderOpenTime ) )
if ( TimeMinute( time ) == TimeMinute( dbOrderOpenTime ) )
if ( TimeHour( time ) == TimeHour( dbOrderOpenTime ) )
if ( TimeDay( time ) == TimeDay( dbOrderOpenTime ) )
if ( TimeMonth( time ) == TimeMonth( dbOrderOpenTime ) )
if ( TimeYear( time ) == TimeYear( dbOrderOpenTime ) )
return (TRUE);
}
for (cnt = 0; cnt < OrdersHistoryTotal(); cnt++) {
OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
if (OrderType() == otype || -37 == otype)
// COMMENT OUT THE if()S YOU DON'T NEED HERE:
// also add new lines as needed
// if ( MathMod( TimeMinute( time ) + 5, 5 ) == 0 ) // 5min chart
// if ( MathMod( TimeMinute( time ) + 15, 15 ) == 0 ) // 15min chart
// if ( MathMod( TimeMinute( time ) + 30, 30 ) == 0 ) // 30min chart
// if ( MathMod( TimeHour( time ) + 4, 4 ) == 0 ) // 4hour chart
int dbOrderOpenTime = OrderOpenTime(); // re-use SAVEs dbPOOL-access time ...
if ( TimeSeconds( time ) == TimeSeconds( dbOrderOpenTime ) )
if ( TimeMinute( time ) == TimeMinute( dbOrderOpenTime ) )
if ( TimeHour( time ) == TimeHour( dbOrderOpenTime ) )
if ( TimeDay( time ) == TimeDay( dbOrderOpenTime ) )
if ( TimeMonth( time ) == TimeMonth( dbOrderOpenTime ) )
if ( TimeYear( time ) == TimeYear( dbOrderOpenTime ) )
return (TRUE);
}
return (FALSE);
}
他のヒント
TimeLocal()
があなたのローカルコンピュータ(クライアント端末)の真夜中月1日1970年からの秒数を与えます。
TimeCurrent()
あなたのブローカーのコンピュータ(サーバ)の真夜中月1日1970年からの秒数を与えます。
あなたがそうのような文字列にこれらのいずれかの変換することができます:
string ct = TimeToStr(TimeLocal(),TIME_DATE|TIME_SECONDS);
Print("Client Time: ", ct);
string st = TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);
Print("Server Time: ", st);
また、そのような日付番号の個々の要素を取得することができます
Print("Year:",TimeYear(TimeCurrent())," Month:",TimeMonth(TimeCurrent()));
MQL4オンラインプログラマガイドを見つけることができますここします。
希望このことができます。
乾杯、
マーク
所属していません StackOverflow