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

 

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

 

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

 

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)
 
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:

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

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

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

 

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);
}
 
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.

 
Thanks
 
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?
Reason: