MT4 服务器信号,MetaTrader4中的MT4基于时间的输入信号

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

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值