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

 

Is any good pratice to detect Market Execution and Instant Execution ?

There is cases where booth can be as RFQ as normal mode for diler and confirmation by trader.. (for example gold, silver around maintenance window)

 
nduru22: 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?
  1. Why didn't you state what variables were not defined?
  2. 'ERR_COMMON_ERROR' - variable not defined       C:\IBFX\experts\include\OrderReliable_2010.10.12.mqh (175, 13)
    'ERR_TRADE_CONTEXT_BUSY' - variable not defined C:\IBFX\experts\include\OrderReliable_2010.10.12.mqh (189, 13)
    'ERR_NO_ERROR' - variable not defined   C:\IBFX\experts\include\OrderReliable_2010.10.12.mqh (234, 10)
    
    include #include <stderror.mqh> before
 

I was trying to modify the ordermodify reliable section to cater for Error 130.

Sometimes my TP is just too close to the market price. On my standard account this isn't an issue as the whole trade is not placed. However with my ECN account the trade is placed but then I have errors when trying to modify the trade, and therefore no SL or TP is entered.

Therefore what I was hoping to achieve was to add a solution for Error 130 by adding the mode_stoplevel to the takeprofit. I thought i had achieved it but in testing every now and then I still get a trade which doesn't get modified.

Can anyone shed some light on what I have done wrong in my coding attempt?

I added from case ERR_INVALID_STOPS: down to default:

I have uploaded the whole .mqh if necessary.

case ERR_PRICE_CHANGED:
case ERR_REQUOTE:
      RefreshRates();
        continue;       // we can apparently retry immediately according to MT docs.
                                
case ERR_INVALID_STOPS:  //(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)
      for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) 
      if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)                    // Only my orders w/
                              
            &&  OrderSymbol()       == Symbol())                 // and my pair.
         {
               int TradeType = OrderType();
                                 if (TradeType == OP_BUY)   
                                { 
                                result=OrderModify(ticket, price, stoploss  , 
                                                                 (takeprofit + (MarketInfo(Symbol(),MODE_STOPLEVEL)*Point) ) , expiration, arrow_color);  
                                                        OrderReliablePrint("non-retryable error, so TP+mode_stoplevel "  + OrderReliableErrTxt(err));
                                }
                                else if (TradeType == OP_SELL)  
                                {
                                result=OrderModify(ticket, price, stoploss , 
                                                                 (takeprofit - (MarketInfo(Symbol(),MODE_STOPLEVEL)*Point) ) , expiration, arrow_color);  
                                                        OrderReliablePrint("non-retryable error, so TP+mode_stoplevel "  + OrderReliableErrTxt(err));
                                }
                                                        
                                                                
                                }
                                exit_loop = true;
                                break; 
                                
                        default:
                                // an apparently serious, unretryable error.
                                exit_loop = true;
                                break; 
 
simoncs:

I was trying to modify the ordermodify reliable section to cater for Error 130.

Sometimes my TP is just too close to the market price. On my standard account this isn't an issue as the whole trade is not placed. However with my ECN account the trade is placed but then I have errors when trying to modify the trade, and therefore no SL or TP is entered.

Therefore what I was hoping to achieve was to add a solution for Error 130 by adding the mode_stoplevel to the takeprofit. I thought i had achieved it but in testing every now and then I still get a trade which doesn't get modified.

Can anyone shed some light on what I have done wrong in my coding attempt?

I added from case ERR_INVALID_STOPS: down to default:

I have uploaded the whole .mqh if necessary.

MarketInfo( StopLevel ) is already in Points. So why are you multiplying by Point?

(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)
 
ubzen:

MarketInfo( StopLevel ) is already in Points. So why are you multiplying by Point?


on my standard broker mode_stoplevel = 20 for eurusd therefore i think i needed to multiply by Point or really by pips2dbl (code provided by WHR). I was testing the code against the standard broker, as this is where i have the historical data. I appreciate this complicates the testing a little, but i should be able to get a solution working as i know the stoplevel=20 on this platform.

However just checked on my ECN broker and mode_stoplevel = 0 at the moment, so this would be a problem, and therefore I am not sure i could use mode_stoplevel anyway. I don't want to hard code in amount.

 
The author of the EA should be able to confirm their EA has been tested on an ECN style account. Not just back tested, but run 'live' for a period of time. Sounds like that's not the case here.

 
leeanne:
The author of the EA should be able to confirm their EA has been tested on an ECN style account. Not just back tested, but run 'live' for a period of time. Sounds like that's not the case here.

It's not an EA its a library that is the issue . . .
 

the solution i have decided to go for, for now is

as I don't know with Error 130 whether it is the TP or the Sl that is stopping the modify...

I will try to amend the TP first,,and then if it still fails then amend the TP and SL using the Spread as my increment.

happy to hear any other suggestions...

        case ERR_INVALID_STOPS:  //(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point)
                        for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) 
      if (OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)                    // Only my orders w/
                              
            &&  OrderSymbol()       == Symbol())                 // and my pair.
         {
               int TradeType = OrderType();
                                 if (TradeType == OP_BUY)   
                                { 
                                result=OrderModify(ticket, price, stoploss, 
                                                                 (takeprofit + (MarketInfo(Symbol(), MODE_SPREAD)*pipstodbl)+pipstodbl) , expiration, arrow_color);  
                                                        OrderReliablePrint("Error 130, so TP+Spread "  + OrderReliableErrTxt(err));
                                                        
                                }
                                else if (TradeType == OP_SELL)  
                                {
                                result=OrderModify(ticket, price, stoploss  , 
                                                                 (takeprofit - (MarketInfo(Symbol(), MODE_SPREAD)*pipstodbl)-pipstodbl) , expiration, arrow_color);  
                                                        //OrderReliablePrint("Error 130, so TP+Spread "  + OrderReliableErrTxt(err));
                                                        Print("modespread=",DoubleToStr((MarketInfo(Symbol(), MODE_SPREAD)*pipstodbl),Digits));
                                }
                                
                                if (result== false)   //if ordermodify still isn't successful then try amending SL as well
                                {
                                if (TradeType == OP_BUY)   
                                { 
                                result=OrderModify(ticket, price, (stoploss - (MarketInfo(Symbol(), MODE_SPREAD)*pipstodbl))  , 
                                                                 (takeprofit + (MarketInfo(Symbol(), MODE_SPREAD)*pipstodbl)+pipstodbl) , expiration, arrow_color);  
                                                        OrderReliablePrint("Error 130 still, so TP+Spread and SL+Spread  "  + OrderReliableErrTxt(err));
                                }
                                else if (TradeType == OP_SELL)  
                                {
                                result=OrderModify(ticket, price, (stoploss + (MarketInfo(Symbol(), MODE_SPREAD)*pipstodbl)) , 
                                                                 (takeprofit - (MarketInfo(Symbol(), MODE_SPREAD)*pipstodbl)-pipstodbl) , expiration, arrow_color);  
                                                        OrderReliablePrint("Error 130 still, so TP+Spread and SL+Spread "  + OrderReliableErrTxt(err));
                                }
                                
                                }                       
                                                                
                                }
                                exit_loop = true;
                                break; 
 
simoncs:

happy to hear any other suggestions...

Fix the code so it checks that the proposed OrderModify() will not fail by making sure that it complies with this: Requirements and Limitations in Making Trades
 
simoncs:


on my standard broker mode_stoplevel = 20 for eurusd therefore i think i needed to multiply by Point or really by pips2dbl (code provided by WHR). I was testing the code against the standard broker, as this is where i have the historical data. I appreciate this complicates the testing a little, but i should be able to get a solution working as i know the stoplevel=20 on this platform.

However just checked on my ECN broker and mode_stoplevel = 0 at the moment, so this would be a problem, and therefore I am not sure i could use mode_stoplevel anyway. I don't want to hard code in amount.

Yeah... You're correct that was an over-sight by me sorry.
Reason: