Download MetaTrader 5

SendOrder

To add comments, please log in or register
Use MQL5 Cloud Network. It is secure!
graziani
1956
graziani 2012.10.08 20:24 

Hi all,

how is it possible that at one broker you can make deal with stop loss with one order,

and you cannot make that at other broker?

Is that a MT5  'feature'? 

graziani
1956
graziani 2012.10.08 21:54  

To clear up things, a little more explanation:

1) Same EA running on two different broker, both MT5 b705
2) I tried both filling the structure and calling OrderSend and i tried using the CTrade class
3) If i run the EA in debug mode on one broker, it opens a deal and places the SL after single OrderSend. The other broker doesnt.
4) In strategy tester, SL is not put in neither case !!Edit!! -> incorrect. it works in strategy tester

So, first of all, it is iritating that you cannot put SL while opening a deal.

Second, how am i supposed to write EAs, if the behavior of methods is different at different brokers?


Andrey Barinov
39241
Andrey Barinov 2012.10.08 22:06  

Hi,

it looks like one of your brokers is ECN broker. They do not allow putting SL/TP along with the initial trade. You need to place order without SL and TP first. And then, you can modify existing position to add SL/TP.

I hope it helps.

Andrey.

graziani
1956
graziani 2012.10.08 22:24  

Thanks Andrey,

it is so.

Is there a way that EA can recognize what type of a broker it is? 

Andrey Barinov
39241
Andrey Barinov 2012.10.09 07:17  
Hi, I do not know any automatic way to find it out. Usually it is done as true/false input in the EA.

But, to avoid this problem you can always do it in 2 steps (first open a position without stops and then modify it adding stops), even with non ECN brokers.
Alexey Petrov
Admin
1220
Alexey Petrov 2012.10.09 09:51  
graziani:

Is there a way that EA can recognize what type of a broker it is? 

You can check the Execution type of the symbol (ENUM_SYMBOL_TRADE_EXECUTION). In the Market and Exchanged execution mode, you cannot specify SLTP when opening a position (check the instructions on filling the MqlTradeRequest structure).
Andrey Barinov
39241
Andrey Barinov 2012.10.09 11:21  
Alexx:
You can check the Execution type of the symbol (ENUM_SYMBOL_TRADE_EXECUTION). In the Market and Exchanged execution mode, you cannot specify SLTP when opening a position (check the instructions on filling the MqlTradeRequest structure).

Alexx,

thanks for your kind reply. As they say, it is never too late to learn!

graziani
1956
graziani 2012.10.09 15:36  

Thnx Alex,

 at that moment i was reading the documentation, it was not clear to me what the connection between TRADE_ACTION_DEAL and different execution types are.

 IMO it would good if few extra lines explaining that would be included in documentation.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types - Documentation on MQL5
To add comments, please log in or register