OrderSend error 130 - Tickstory Data

 

Hi everyone,

I have started getting 'OrderSend error 130' when trying to use the strategy tester on a piece of code. 

I am incredibly confused as to why this is happening, as I am running the code live (With the same broker) and have no issues. Similarly, I tried inserting this basic buy signal code below (taken from mql4.com handbook), which also gets Error 130.

int start()                                  

  {                                          

   OrderSend(Symbol(),OP_BUY,0.1,Ask,2,Bid-25*Point,Bid+15*Point);

   return;                                   

  } 

I am using the data from tickstory, which is the only thing I could see perhaps being an issue? But I have been trying to rack my brain around this for days, so if someone could shed some light on this it would be greatly appreciated.

Thanks,


Euan 

 
euanmaca:

Hi everyone,

I have started getting 'OrderSend error 130' when trying to use the strategy tester on a piece of code. 

I am incredibly confused as to why this is happening, as I am running the code live (With the same broker) and have no issues. Similarly, I tried inserting this basic buy signal code below (taken from mql4.com handbook), which also gets Error 130.

I am using the data from tickstory, which is the only thing I could see perhaps being an issue? But I have been trying to rack my brain around this for days, so if someone could shed some light on this it would be greatly appreciated.

Thanks,


Euan 

I believe it is not from the Tickstory. It is from your code!

try to update your code in the regard of *Point to the following:

double   MyPoint = Point;


//+------------------------------------------------------------------+
//| Expert initialization function
//+------------------------------------------------------------------+
int OnInit()
{
//---
        if(Digits==3 || Digits==5) MyPoint=Point*10;
//---
   return(INIT_SUCCEEDED);

}

so, after that you have to use *MyPoint instead of *Point as below:


int start()                                  

  {                                          

   OrderSend(Symbol(),OP_BUY,0.1,Ask,2,Bid-25*MyPoint,Bid+15*MyPoint);

   return;                                   

  } 
 
euanmaca:

Hi everyone,

I have started getting 'OrderSend error 130' when trying to use the strategy tester on a piece of code. 

I am incredibly confused as to why this is happening, as I am running the code live (With the same broker) and have no issues. Similarly, I tried inserting this basic buy signal code below (taken from mql4.com handbook), which also gets Error 130.

I am using the data from tickstory, which is the only thing I could see perhaps being an issue? But I have been trying to rack my brain around this for days, so if someone could shed some light on this it would be greatly appreciated.

Thanks,


Euan 

It's probably your broker settings. If you would have 4 digit broker it would work in most cases. If you have 5 digits then Mohammad code will work for you. There is a variable called "Stop Level" and"Freeze Level"  which indicates what minimum distance needs to be set to set TP / SL / Pending order. If the price is too close to current market price, then you will get invalid stops error.

https://book.mql4.com/appendix/limits

Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
  • book.mql4.com
Tables below show calculation values that limit the conduction of trades when opening, closing, placing, deleting or modifying orders. To get the minimum distance to StopLevel and freezing distance FreezeLevel the MarketInfo() function should be called. Requirements. Correct prices used when performing trade operations. Order Type Open Price...
 
Bartlomiej Gorski:

It's probably your broker settings. If you would have 4 digit broker it would work in most cases. If you have 5 digits then Mohammad code will work for you. There is a variable called "Stop Level" and"Freeze Level"  which indicates what minimum distance needs to be set to set TP / SL / Pending order. If the price is too close to current market price, then you will get invalid stops error.

https://book.mql4.com/appendix/limits

Thanks for your responses both of you. 


I tried the solution and it worked, combined with the fact my broker for some reason does not allow the 'BUYSTOP' command (which I was using in my code)

 
int start()                                  

  {                                           
   int stopLevel = (int)SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL)+1;
   
   OrderSend(Symbol(),OP_BUY,0.1,Ask,2,Bid-(stopLevel>25 ? stopLevel : 25)*Point,Bid+(stopLevel>15 ? stopLevel : 15)*Point);

   return;                                   

  } 
 

From my own observations, using tick data from a 4 digit broker and backtesting with a 5 digit broker may cause problems.

I used a Stop Loss and Take Profit of 20 pips and received Order Send Errors 130 but when I altered the Stop Loss and Take Profit to 30 pips, the Order Send errors disappeared.

The EA Code allowed for correct interpretation of the Point value so I can only assume that there is an internal problem interpreting the "_0.fxt" (tick) data.

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
Reason: