简体   繁体   English

以不同于 EA 在 MQL4 中运行的交易品种进行交易

[英]Open trade in different symbol than the one the EA runs in MQL4

So I want to open trades depending on multiple criteria with my EA... Doesn't really matter TBH...所以我想根据我的 EA 的多个标准开立交易...... TBH 并不重要......

The problem is that EAs run in one window.问题是 EA 在一个 window 中运行。 So naturally, I'd like for an EA to open assess conditions and open all the trades within one chart.所以很自然,我希望 EA 能够打开评估条件并在一张图表中打开所有交易。 Everything's fine except...一切都很好,除了...

Broker won't allow an EA that runs in a chart open a trade on a different one.... It is surely that.经纪人不会允许在图表中运行的 EA 在不同的图表上打开交易......肯定是这样。 I eliminated any other case.我消除了任何其他情况。

Inputs just for this example:仅用于此示例的输入:

input double LotSize = 0.01;

input int Slippage = 10;

input double StopLoss = 1000.0;

input double TakeProfit = 1000.0;

input const string SymbolA = "EURUSD";

input const string SymbolB = "GBPUSD";

The commands I use (I have them copy-pasted from another EA that works just fine so I am certain they work as well, plus I used extreme TP/SL to surpass any restrictions that brokers might have):我使用的命令(我将它们从另一个运行良好的 EA 复制粘贴,因此我确信它们也能正常运行,而且我使用了极端的 TP/SL 来超越经纪人可能拥有的任何限制):

       TicketA = OrderSend(SymbolA,OP_SELL,LotSize,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,EAComment,OrderTicket(),0,clrDarkRed);

       Sleep(1000);

       TicketB = OrderSend(SymbolB,OP_BUY,LotSize,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,EAComment,OrderTicket(),0,clrDarkBlue);

Error (EURUSD one opens normal as the EA runs in the EURUSD chart):错误(当 EA 在 EURUSD 图表中运行时,EURUSD 一正常打开):

2020.12.18 01:01:45.318 '22644076': order buy market 0.01 GBPUSD sl: 1.21670 tp: 1.23670 2020.12.18 01:01:45.318 '22644076': 订单买入市场 0.01 GBPUSD sl: 1.21670 tp: 1.23670

2020.12.18 01:01:45.528 '22644076': order buy 0.01 GBPUSD opening at market sl: 1.21670 tp: 1.23670 failed [Invalid S/L or T/P] 2020.12.18 01:01:45.528 '22644076': 买入 0.01 GBPUSD 在市场开盘 sl: 1.21670 tp: 1.23670 failed [无效的 S/L 或 T/P]

Any suggestion how can I fix/bypass this?有什么建议我该如何解决/绕过这个问题?

Thanks in advance!提前致谢!

Obviously, you have to set a different open price, stop-loss, and take-profit for another symbol.显然,您必须为另一个交易品种设置不同的开盘价、止损和止盈。 So, if you are calling for the current (SymbolA) this sell:因此,如果您要求当前的(SymbolA)这个卖出:

TicketA = OrderSend(SymbolA,OP_SELL,LotSize,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,EAComment,OrderTicket(),0,clrDarkRed);

Then for a SymbolB (a different symbol), you have to first construct the price values:然后对于 SymbolB(不同的符号),您必须首先构造价格值:

double Ask_B = SymbolInfoDouble(SymbolB, SYMBOL_ASK);
double Point_B = SymbolInfoDouble(SymbolB, SYMBOL_POINT);
int Digits_B = SymbolInfoInteger(SymbolB, SYMBOL_DIGITS);
double SL_B = NormalizeDouble(Ask_B - StopLoss * Point_B, Digits_B);
double TP_B = NormalizeDouble(Ask_B + StopLoss * Point_B, Digits_B);

And only then call something like this:然后才调用这样的东西:

TicketB = OrderSend(SymbolB,OP_BUY,LotSize,Ask_B,Slippage,SL_B,TP_B,EAComment,OrderTicket(),0,clrDarkBlue);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM