How to avoid placing multiple orders in MT5? 新评论 Alax9988 2025.05.28 12:14 void OnTick() { //--- int PositionOfSymbol = 0; for(int i =PositionsTotal()-1;i>=0;i--){ string symbol = PositionGetString(POSITION_SYMBOL); int Magic = PositionGetInteger(POSITION_MAGIC); if(Symbol()==symbol && Magic==魔术号){ PositionOfSymbol ++; if(...){ if(trade.PositionClose(ticket,10)){ PositionOfSymbol --; } } } if(PositionOfSymbol<=0){ ... if(...){ trade.Buy(...); } } } This is part of my code. There can only be one order per symbol. I limit it through magic, but today I found that many orders were placed repeatedly for the GER40 symbol. Does my code have bugs or vulnerabilities? How can I improve my code?Help me please. Coding help MT4 code change to MT5 code How to Distinct Symbols of Open and Pending Orders in MT5 Sky All 2025.05.29 06:04 #1 您好,我是官网版主。在中文论坛请使用中文提问。感谢理解。 Hong Ma 2025.05.29 06:19 #2 Sky All #: 您好,我是官网版主。在中文论坛请使用中文提问。感谢理解。 我想一个可能是发出一个订单后,成交汇报太慢,还没等到汇报,就又发出去另外一个订单,优化办法是每发出一个订单,要等到汇报以后再发下一个, Alax9988 2025.05.30 08:07 #3 Hong Ma #: 我想一个可能是发出一个订单后,成交汇报太慢,还没等到汇报,就又发出去另外一个订单,优化办法是每发出一个订单,要等到汇报以后再发下一个, 我看了代码的,CTrade默认不是异步啊。而且,他订单重复还不是短期内的多个订单,时间相差挺多的。后来我看了一下,应该是魔术号的原因,我没有注意数据长度,导致代码中的魔术号和实际下单的魔术号不一致 新评论
This is part of my code.
There can only be one order per symbol. I limit it through magic, but today I found that many orders were placed repeatedly for the GER40 symbol.
Does my code have bugs or vulnerabilities? How can I improve my code?
Help me please.