gpt4 book ai didi

algorithmic-trading - MQL4 - 调用 OrderSend() 方法时出现错误 4111

转载 作者:行者123 更新时间:2023-12-04 17:37:31 33 4
gpt4 key购买 nike

我正在尝试下订单,但我对 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.000010.00010.0010.010.11.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/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com