Download MetaTrader 5

How do i Make my ea work with an ecn broker???????

To add comments, please log in or register
Store your source codes in MQL5 Storage. It is secure!
gavin
390
gavin 2010.10.21 16:15 

I have a working ea but changed to an ecn broker. What should i change or add to the code to make it work??

zzuegg
1505
zzuegg 2010.10.21 16:18  

Differences should only be in the OrderSend() function. On ECN's you can't set TP/SL in that function. You must first open the order, and then modify it with the right TP/SL

//z

Phillip
800
Phillip 2010.10.21 17:09  

I modified the "Order Reliable" include file such that it traps order-rejects for the ECN broker and transparently resends the order plus the follow-up ordermodify as needed to bring about the desired effect.

Placed the attached file in your "\experts\include\" path and add the following to the top of your EA:

#include <OrderReliable_2010.10.12.mqh>
Then replace all your OrderSend(), OrderModify(), and OrderClose() calls with OrderSendReliable(), OrderModifyReliable(), and OrderCloseReliable() respectively. (just do a search and replace for the terms, the actual parameters you currently pass to OrderSend() work without change as the correct parameter calls to send with OrderSendReliable(), etc).

OrderSendReliable() as I have modified it in the attached will first attempt to place the trade as if TP and SL can be sent with the OrderSend() request. If the broker rejects the Order request because of the specification of non-zero stops and takeprofit then the OrderSendReliable() function automatically proceeds to place an OrderSend() without the user specified SL and TP values, waits for confirmation that the order was executed and then automatically submits and OrderModify() request to set the SL and TP values as per the initial request by the calling EA.

(note I am not the originating author of the OrderSendReliable() file itself, I merely adapted it to suit my needs as I have detailed above, the original author info is all in the file)
gavin
390
gavin 2010.10.21 17:43  
1005phillip:

I modified the "Order Reliable" include file such that it traps order-rejects for the ECN broker and transparently resends the order plus the follow-up ordermodify as needed to bring about the desired effect.

Placed the attached file in your "\experts\include\" path and add the following to the top of your EA:

Then replace all your OrderSend(), OrderModify(), and OrderClose() calls with OrderSendReliable(), OrderModifyReliable(), and OrderCloseReliable() respectively. (just do a search and replace for the terms, the actual parameters you currently pass to OrderSend() work without change as the correct parameter calls to send with OrderSendReliable(), etc).

OrderSendReliable() as I have modified it in the attached will first attempt to place the trade as if TP and SL can be sent with the OrderSend() request. If the broker rejects the Order request because of the specification of non-zero stops and takeprofit then the OrderSendReliable() function automatically proceeds to place an OrderSend() without the user specified SL and TP values, waits for confirmation that the order was executed and then automatically submits and OrderModify() request to set the SL and TP values as per the initial request by the calling EA.

(note I am not the originating author of the OrderSendReliable() file itself, I merely adapted it to suit my needs as I have detailed above, the original author info is all in the file)

Cheers for the info. That should sort my problem. Many thanks..
gavin
390
gavin 2010.10.21 18:01  
gavin:

Cheers for the info. That should sort my problem. Many thanks..


Sorry wher exactly do i put all this code and do i need to put it all in my ea to work correctly??

Phillip
800
Phillip 2010.10.21 23:20  
gavin:


Sorry wher exactly do i put all this code and do i need to put it all in my ea to work correctly??


1005phillip:


Place the attached file in your "\experts\include\" path and add the following to the top of your EA:

#include <OrderReliable_2010.10.12.mqh>
Then replace all your OrderSend(), OrderModify(), and OrderClose() calls with OrderSendReliable(), OrderModifyReliable(), and OrderCloseReliable() respectively. (just do a search and replace for the terms, the actual parameters you currently pass to OrderSend() work without change as the correct parameter calls to send with OrderSendReliable(), etc).
Ahmed Soliman
15713
Ahmed Soliman 2010.10.22 00:19  

Simply send the order with OrderSend() without StopLoss and TakeProfit

Then use OrderModify to set the StopLoss and TakePofit.

fro more details check this answer:

mqltalk

Ahmed Soliman
15713
Ahmed Soliman 2010.10.22 16:31  

For ECN brokers you need to place the order without limits (StopLoss and TakeProfit) using OrderSebnd function.

Then you should modify the just placed order with OrderModify() function to set the SoptLoss and/or the TakeProfit.

This is an example:

int ticket=OrderSend(TradeSymbol,OP_BUY,TradeLot,Ask,TradeSlippage,0,0,TradeComment,
TradeMagicNumber,0,Green);
if(ticket>-1) 
{
  OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
  OrderModify(ticket,OrderOpenPrice(),TradeStopLoss,TradeTakeProfit,0,Green);
}
bernd
985
bernd 2010.10.26 16:35  
codersguru:

Simply send the order with OrderSend()

The question has already been answered.

Don't recommend a naked OrderSend() in an EA, there is no justifiable reason to ever put a call to OrderSend() into an EA unless it is only a quick and dirty prototype for backtesting only and even then it is not recommended. OrderSendReliable() as mentioned above is the way to go, everything else is half baked and creates only unneeded work and unneeded modifications to all EAs and unneeded code duplication.

jugivi
199
jugivi 2012.10.11 20:59  
Thanks
nduru22
132
nduru22 2013.03.23 14:47  
1005phillip:



How about the errors encountered when compiling my e.a after placing the OrderReliable include file? the "variable not defined" errors. Should I define them or what should I do?
123
To add comments, please log in or register