MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Freelancer services needed to perform 150+ jobs of traders

Ordersend error

Back to topics list To post a new topic, please log in or register
avatar
2
ARFX57 2009.10.24 23:43
 

Hello

I have an expert, in some special trades(I don't know the reason), Ordersend can not open the trade. It returns -1, but getlasterror() is 0. I can't understand what is the reason. Could you please help?

this is a part of log file of this expert:

Account balance=100004.00000000
InitialTradeVolumeBeforeMinlot=4.66000000
MinLot=0.10000000
InitialTradeVolumeAfterMinlot=4.66000000
Parameters of Opening Trade are : Trade Type=SELL Symbol=EURUSD current BID price is 1.50147 Instruction_Open_Price=1.50129 SL=1.55497 TP=0.00000 Volume=4.66000000 Leverage=4.66
Allowed slippage for EURUSD is 100 pis
Executing Trade failed with error #0

This expert works well some timesand thsi error some other times. Please help.

Thanks.

 
Five questions you’ll need to know the answer to if you want to pass the Series 7
If you want to score a high-paying job selling or trading securities in the U.S., you’ll need more than just a good resume. You’ll also need to pass a six-hour, 270-question exam commonly known as the Series 7, or the General Securities Representative Exam (GSRE). The test covers everything you’ll need to know to be a broker, from fairly simple procedural concepts to complex rules surrounding compliance and risk. Passing the Series 7 is particularly critical because you’ll already need to be employed by a FINRA member firm, and you can’t do your job without a license. Failing is an easy way to get fired before ever really getting started. While each exam has different questions, all cover the same general principles. Below are five questions you may see in some iteration, along with the correct answers and an explanation from Brian Marks, managing director at Knopman Financial Training, a New York-based FINRA licensing exam preparation firm. How would you do?
avatar
258
fx1.net 2009.10.25 10:00 #
 
may your broker make you problems? Why dont you keep trying to send the OrderSend in case you get -1? You may build a counter and send it 3 times after you got error. Of course you may loose some ticks but seems you anyways try to insert a sellstop order.
 
avatar
364
Irtron 2009.10.25 15:06 #
 
ARFX57:

Hello

I have an expert, in some special trades(I don't know the reason), Ordersend can not open the trade. It returns -1, but getlasterror() is 0. I can't understand what is the reason. Could you please help?

this is a part of log file of this expert:

Account balance=100004.00000000
InitialTradeVolumeBeforeMinlot=4.66000000
MinLot=0.10000000
InitialTradeVolumeAfterMinlot=4.66000000
Parameters of Opening Trade are : Trade Type=SELL Symbol=EURUSD current BID price is 1.50147 Instruction_Open_Price=1.50129 SL=1.55497 TP=0.00000 Volume=4.66000000 Leverage=4.66
Allowed slippage for EURUSD is 100 pis
Executing Trade failed with error #0

This expert works well some timesand thsi error some other times. Please help.

Thanks.

This is either Bid and OpenPrice mismatch (which is definitely a bug for sell order, slippage doesn't matter really) or incorrect error handling, Or both. Or something else.

You're the only person who has a privilege to see your code and find the right answer atm.

 
avatar
2
ARFX57 2009.10.25 17:54 #
 

Hello

thanks for the answers. this is part of the code:

if(SLPG>SlippageControl(Symbol1[j]+ Suffix))
{
Comment2("Could not send Trade_ID=" + TradeID[j] + " due to slippage of " + NormalizeDouble( SLPG, 0) + " Pips.");
}
else
{
int Ticket=-1;
if( CommandType[j] == OP_BUY)
Ticket=OrderSend(Symbol1[j]+ Suffix,CommandType[j],InitialTradeVolume, MarketInfo(Symbol1[j]+ Suffix,MODE_ASK), 50, SL[j], TP[j], "TradeID=" + TradeID[j],TradeID[j]+MaxMagicNumberOfOtherExperts);
else
Ticket=OrderSend(Symbol1[j]+ Suffix,CommandType[j],InitialTradeVolume, MarketInfo(Symbol1[j]+ Suffix,MODE_BID), 50, SL[j], TP[j], "TradeID=" + TradeID[j],TradeID[j]+MaxMagicNumberOfOtherExperts);

if(Ticket<=0)
{
if(GetLastError()==4 | GetLastError()==6 | GetLastError()==132 | GetLastError()==137)
{
Comment2("Trade is not executed due to Server busy or no connection or market closed or broker busy.");
Comment2("Command will be re-executed after 1 minute.");
NumberOfTriesForThisLine[j]--;
Sleep(60000);
}
else
{
Comment2("Executing Trade_ID=" + TradeID[j] + " failed with error #" + GetLastError());
Sleep(1000);
}
}
else
{
Comment2("Trade_ID=" + TradeID[j] + " was executed successfully." );
}

As you see, I'm directly using MarketInfo(). what may be the reason?

Thanks

avatar
9810
WHRoeder 2009.10.25 18:34 #
 

I see your using Sleep() but not RefreshRates()

Print each argument to SendOrder() to full Digits precision.

 
avatar
364
Irtron 2009.10.25 19:55 #
 
ARFX57:

if(GetLastError()==4 | GetLastError()==6 | GetLastError()==132 | GetLastError()==137)

{
Comment2("Trade is not executed due to Server busy or no connection or market closed or broker busy.");
Comment2("Command will be re-executed after 1 minute.");
NumberOfTriesForThisLine[j]--;
Sleep(60000);
}
else
{
Comment2("Executing Trade_ID=" + TradeID[j] + " failed with error #" + GetLastError());
Sleep(1000);
}


Incorrect error handling it is. GetLastError() zeros LastError value hence all the calls to GetLastError() except the very first one (GetlLastError() == 4) don't make sense.


BTW bitwise OR operator looks cool but may cause unexpected behaviour in condition statement.

 
Back to topics list  

To add comments, please log in or register