OrderSend error 130 - Tickstory Data

To add comments, please log in or register
euanmaca
11
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.

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 

Mohammad Soubra
31028
Mohammad Soubra  
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;                                   

  } 
Bartlomiej Gorski
11348
Bartlomiej Gorski  
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...
euanmaca
11
euanmaca  
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)

Konstantin Nikitin
7859
Konstantin Nikitin  
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;                                   

  } 
To add comments, please log in or register