//+------------------------------------------------------------------+
I added the order code after the error and that is not fixing it either.
Anyone have any ideas on how to get this to retry until filled when market is busy..What am I missing here??
//| Scalp LONG.mq4 |
//| Copyright ? 2009, |
//|
http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script "trading for all money" |
//+------------------------------------------------------------------+
int start()
{
int ticket_1;
while(true) // Cycle that opens an order
{
Alert("The request was sent to the server. Waiting for reply..");
//---- StopLoss = Ask-20*Point Take Profit = Ask + 20*Point
ticket_1=OrderSend(Symbol(),OP_BUY,0.02,Ask,3,Ask-15*Point,Ask+10*Point,"HOTKEY SCALP LONG",265,0,Green);
//--------------------------------------------------------------------7 --
if (ticket_1>0) // Got it!:)
{
Alert ("Opened Scalp Order Long ",ticket_1);
break; // Exit cycle
}
//--------------------------------------------------------------------8 --
int Error=GetLastError(); // Failed
switch(Error) // Overcomable errors
{
case 135:Alert("The price has changed. Retrying..");
RefreshRates(); // Update data
ticket_1=OrderSend(Symbol(),OP_BUY,0.02,Ask,3,Ask-15*Point,Ask+10*Point,"HOTKEY SCALP LONG",265,0,Green);
continue; // At the next iteration
case 136:Alert("No prices. Waiting for a new tick..");
while(RefreshRates()==false) // Up to a new tick
Sleep(1); // Cycle delay
ticket_1=OrderSend(Symbol(),OP_BUY,0.02,Ask,3,Ask-15*Point,Ask+10*Point,"HOTKEY SCALP LONG",265,0,Green);
continue; // At the next iteration
case 146:Alert("Trading subsystem is busy. Retrying..");
Sleep(500); // Simple solution
RefreshRates(); // Update data
ticket_1=OrderSend(Symbol(),OP_BUY,0.02,Ask,3,Ask-15*Point,Ask+10*Point,"HOTKEY SCALP LONG",265,0,Green);
continue; // At the next iteration
}
switch(Error) // Critical errors
{
case 2 : Alert("Common error.");
break; // Exit 'switch'
case 5 : Alert("Outdated version of the client terminal.");
break; // Exit 'switch'
case 64: Alert("The account is blocked.");
break; // Exit 'switch'
case 133:Alert("Trading forbidden");
break; // Exit 'switch'
default: Alert("Occurred error ",Error);// Other alternatives
}
break; // Exit cycle
}
return; // Exit start()
}
//+------------------------------------------------------------------+