I've been having issues as of late.
How do I capture the errors thrown by failed trades on ECN brokers?
How do I capture the errors thrown by failed trades on ECN brokers?
Cheapest ECN Comissions - Vantage FX ECN 10 replies
Detecting the new ECN broker setup 1 reply
Detecting brokers who deal in 1/10ths of a pip. 3 replies
Detecting stopped order? 1 reply
Detecting if last trade hit stop loss 10 replies
DislikedI've been having issues as of late.
How do I capture the errors thrown by failed trades on ECN brokers?Ignored
DislikedHey Hanover,
As far as I know, one way an ECN Broker handles orders entered with a SL/TP is it fails with no error code.
I'm trying to find a way to capture this error. One method I used was to check for an order ticket. That doesn't seem to be working. So I'm looking for alternatives.Ignored
DislikedRon, which br0ker are you having problems with? Is it FXCM?
Thanks,
DavidIgnored
DislikedFXCM and FXDD for now. I'm not sure if your research across 16 brokers has shown any patterns.Ignored
extern bool ECNBroker = False; int SendOrder(string OpenSymbol, int OpenCommand, double OpenVolume, double OpenPrice, int OpenSlippage, double OpenStopLoss, double OpenTakeProfit, string OpenComment, int OpenMagicNumber, datetime OpenExpiration, color OpenColor) { int FTicket = -2; if(!ECNBroker) { FTicket = OrderSend(OpenSymbol, OpenCommand, OpenVolume, OpenPrice, OpenSlippage, OpenStopLoss, OpenTakeProfit, OpenComment, OpenMagicNumber, OpenExpiration, OpenColor); if(FTicket == -1) { return(FTicket); } if(OrderSelect(FTicket, SELECT_BY_TICKET, MODE_TRADES)) { return(FTicket); } else { ECNBroker = True; } } if(ECNBroker) { FTicket = OrderSend(OpenSymbol, OpenCommand, OpenVolume, OpenPrice, OpenSlippage, 0.0, 0.0, OpenComment, OpenMagicNumber, OpenExpiration, OpenColor); if(FTicket > 0) { OrderSelect(FTicket, SELECT_BY_TICKET, MODE_TRADES); OrderModify(FTicket, OrderOpenPrice(), OpenStopLoss, OpenTakeProfit, OrderExpiration(), CLR_NONE); } return(FTicket); } }
Ticket = SendOrder(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink); if(Ticket > 0) { if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) { Print("SELL order opened : ", OrderOpenPrice()); if (SignalMail && ShortMailSignalBarCount != Bars) { SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal"); ShortMailSignalBarCount = Bars; } if (Alerts && ShortAlertSignalBarCount != Bars) { Alert("[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + "Sell Signal"); ShortAlertSignalBarCount = Bars; } if (PlaySounds && ShortSoundSignalBarCount != Bars) { PlaySound("alert.wav"); ShortSoundSignalBarCount = Bars; } TradesThisBar++; } else { Print("Error opening SELL order : ", GetLastError()); } }
DislikedIt's my own attempt at making a universal ECN Broker script. Errors are passed through to the error handling code in the Start() function. This is meant specifically to detect an ECN Broker and adjust its behavior accordingly.Ignored
DislikedI thought that too, except when I ran Print() functions in the second ECN section, the EA was still running through that section, so this block of code was changing the value of ECNBroker from False to True.
If the Ticket value passed as a result of the function was -1, there should've been a 'get last error' call at the end of the second block of code. No error call went through.
Perhaps a ticket of -1 returned is just a generic "error"?Ignored
DislikedI'm trying to do something a little unorthodox in programming.
I'm basically telling the EA to ignore any errors thrown by the original OrderSend request, and instead search for the trade using the OrderSelect() function. If that returns true, the EA knows the trade exists. If false, something really bad happened and /should/ be handled with the more traditional error handling.Ignored
extern bool ECNBroker = False; int SendOrder(string OpenSymbol, int OpenCommand, double OpenVolume, double OpenPrice, int OpenSlippage, double OpenStopLoss, double OpenTakeProfit, string OpenComment, int OpenMagicNumber, datetime OpenExpiration, color OpenColor) { int FTicket = -2; if(!ECNBroker) { FTicket = OrderSend(OpenSymbol, OpenCommand, OpenVolume, OpenPrice, OpenSlippage, OpenStopLoss, OpenTakeProfit, OpenComment, OpenMagicNumber, OpenExpiration, OpenColor); if(FTicket == -1) { return(FTicket); [color="Red"]// function exits here if order placement fails[/color] } if(OrderSelect(FTicket, SELECT_BY_TICKET, MODE_TRADES)) { return(FTicket);[color="Red"]// function exits here if order placement is successful[/color] } [color="red"]// the rest of the code, from here onward, will never be executed.......[/color] else { ECNBroker = True; } } if(ECNBroker) { FTicket = OrderSend(OpenSymbol, OpenCommand, OpenVolume, OpenPrice, OpenSlippage, 0.0, 0.0, OpenComment, OpenMagicNumber, OpenExpiration, OpenColor); if(FTicket > 0) { OrderSelect(FTicket, SELECT_BY_TICKET, MODE_TRADES); OrderModify(FTicket, OrderOpenPrice(), OpenStopLoss, OpenTakeProfit, OrderExpiration(), CLR_NONE); } return(FTicket); } }