SendOrder

 

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'? 

 

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?


 

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.

 

Thanks Andrey,

it is so.

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

 
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.
 
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).
 
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!

 

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