- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试下订单,但我对 OrderSend()
方法的调用 ( https://docs.mql4.com/trading/ordersend )
失败了:
2016.08.01 00:51:09.710 2016.07.01 01:00 s EURUSD,M1: OrderSend error 4111
void OnTick() {
if ( OrdersTotal() == 0 ){
int result = OrderSend( NULL, OP_SELL, 0.01, Bid, 5, 0, Bid - 0.002, NULL, 0, 0, clrGreen );
if ( result < 0 ) Print( "Order failed #", GetLastError() );
else Print( "Order success" );
}
}
你知道我做错了什么吗?
最佳答案
OrderSend()
先打电话:int result = OrderSend( NULL, // string: _Symbol,
OP_SELL, // int: OP_SELL,
0.01, // double: NormalizeLOTs( nLOTs ),
Bid, // double: NormalizeDouble( Bid, Digits ),
5, // int: slippagePOINTs,
0, // double: { 0 | NormalizeDouble( aSlPriceTARGET, Digits ) },
Bid-0.002, // double: { 0 | NormalizeDouble( aTpPriceTARGET, Digits ) },
NULL, // string: { NULL | aBrokerUnguaranteedStringCOMMENT },
0, // int: { 0 | aMagicNUMBER },
0, // datetime: { 0 | aPendingOrderEXPIRATION },
clrGreen // color: { clrNONE | aMarkerCOLOR }
);
为了更加安心,应该始终规范化所有在 MQL4
上有一些限制性处理的值 -side ( prices + lot ( quantised ) 值——因为这些不是 R 域中的连续值,而是量子步进的:
价格:0.00001
或 0.0001
或 0.001
或 0.01
或 0.1
或 1.0
等步进,
手数:受经纪人特定设置的更多限制,每个工具,三个关键值,所有允许的交易量大小必须满足:
[aMinLOTs<=, +aMinLotSTEP, <=aMaxLOTs]
<强> +
适当的数字归一化
~ 因此 double NormalizeLOTs( aProposedVOLUME ) {...}
是一个方便的工具,可以无缝地实现这一需求的两个部分。
Error 4111:
还有一些其他障碍会阻止您的 MetaTrader Terminal 4
顺利运行您的代码:
4111
ERR_SHORTS_NOT_ALLOWED
Shorts are not allowed. Check the Expert Advisor properties
if ( !TerminalInfoInteger( TERMINAL_TRADE_ALLOWED ) )
Alert( "Check if automated trading is allowed in the terminal settings!" );
else if ( !MQLInfoInteger( MQL_TRADE_ALLOWED ) )
Alert( "Automated trading is forbidden in the program settings for ",
__FILE__
);
这指示用户修改 MetaTrader Terminal 4
设置,
在 MT4 -> Tools -> Options -> ExpertAdvisor
下 选项卡
和经纪方交易工具条件,其中某些工具的卖空可能受到一般限制,或仅针对某些账户类型。
if ( !AccountInfoInteger( ACCOUNT_TRADE_EXPERT ) )
Alert( "Automated trading is forbidden for the account",
AccountInfoInteger( ACCOUNT_LOGIN ),
" at the trade server side. Contact Broker's Customer Care Dept."
);
有关更多详细信息,请参阅 printScreens 并演示了这组两者的编程处理 Terminal
-side/Broker-side barriers: ref.-> MQL4 引用/MQL4 程序/交易许可
关于algorithmic-trading - MQL4 - 调用 OrderSend() 方法时出现错误 4111,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38689063/
我有一个指示器,通过声音和警报发出 Action 信号: PlaySound("news.wav"); Alert(Symbol()," make an action"); 我想在那里添加 Order
我正在尝试下订单,但我对 OrderSend() 方法的调用 ( https://docs.mql4.com/trading/ordersend ) 失败了: 2016.08.01 00:51:09.
我想弄清楚是否有 正确方法设置止损 (SL) 和获利 (TP) 水平,当在 EA 交易中发送订单时,在 MQL4 (Metatrader4) 中。功能模板是: OrderSend( symbol, c
我是一名优秀的程序员,十分优秀!