OrderSend & Error 130

 

sl_buy=Ask-SL*Point;

TPvalue= Ask+TP*Point;

OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,sl_buy,TPvalue,"CS",

MagicNumber,0,Blue);


sl_sell=Bid+SL*Point;

TPvalue= Bid-TP*Point;

OrderSend(Symbol(),OP_SELL,Lots,Bid,slippage,sl_sell,TPvalue,"CS",

MagicNumber,0,Red);


The Stoplevel is 0.00000!!

this 2 orders produced allways an error 130. Can anybody tell me the reason.

 
schiller:

sl_buy=Ask-SL*Point;

TPvalue= Ask+TP*Point;

OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,sl_buy,TPvalue,"CS",

MagicNumber,0,Blue);


sl_sell=Bid+SL*Point;

TPvalue= Bid-TP*Point;

OrderSend(Symbol(),OP_SELL,Lots,Bid,slippage,sl_sell,TPvalue,"CS",

MagicNumber,0,Red);


The Stoplevel is 0.00000!!

this 2 orders produced allways an error 130. Can anybody tell me the reason.

Hi Shiller,

Hard to tell without seeing the entire code.

To start by using what you have provided...where is "SL" given a value?

Your buy/sell use "SL" to calculate the values for the orders. That could be why you are getting stoplevel zero's and error 130?

Hope this helps,

Robert

 

Hi Robert

The stoplevel i got with the folleowing code

double stoplevel= MarketInfo("EURUSD",MODE_STOPLEVEL);
string strStoplevel= DoubleToStr(stoplevel, 8);
Alert ("strStoplevel= ", strStoplevel);

The entire code originally is from the article

Comfortable Scalping



Look at https://www.mql5.com/en/articles/1509


Herm

 
schiller:


Hi Robert

The stoplevel i got with the folleowing code

double stoplevel= MarketInfo("EURUSD",MODE_STOPLEVEL);
string strStoplevel= DoubleToStr(stoplevel, 8);
Alert ("strStoplevel= ", strStoplevel);

The entire code originally is from the article - Comfortable Scalping - Look at https://www.mql5.com/en/articles/1509

Herm

Hi Herm,

Seems to be a 5 digit SL/TP problem. Trades fine when I add a zero - SL = 20 error 130 : SL = 200 works fine

Couldn't actually get the arrows separated to play the game accurately...but I could delete one or the other arrow to make the test trades.

Hope this helps,

Robert

 
EA's must adjust for 5 digit brokers, TP, SL AND slippage.
//++++ These are adjusted for 5 digit brokers.
double  pips2points,    // slippage  3 pips    3=points    30=points
        pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
int     init(){
    if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
On ECN brokers, you must orderSend and THEN set the tp/sl.
Reason: