Error Code 130 question

 

All -

I appear to be getting an Error Code 130 with the following code on a 1-minute candle chart:

RefreshRates();

currOrderTicket = OrderSend(/*1*/Symbol(),
/*2*/OP_BUY,
/*3*/LOT_SIZE,
/*4*/Ask,
/*5*/MAX_ALLOWED_SLIPPAGE,
/*6*/Ask-TAKE_PROFIT*Point,//getStopLimit(Low[1]),
/*7*/Ask+TAKE_PROFIT*Point,
/*8*/"ta-market-buy-order-##",
/*9*/MAGIC_NUMBER,
/*10*/0,
/*11*/Green);

From this page: https://docs.mql4.com/trading/errors it apperas like 130 is a problem with either param #4, param #6, or param #7. Right now I have set my "TAKE_PROFIT" to 40 pips.

Would appreciate all / any suggestions.

 

Have you adjusted for having a 5 digit broker ? if you have a 5 digit broker your "TAKE_PROFIT" is actually 4 pips and as a result your SL maybe too close to your entry . . . what is your

MarketInfo( Symbol(), MODE_STOPLEVEL) 
 
EA's must adjust for 5 digit brokers, TP, SL, AND slippage. On ECN brokers you must open the order and THEN set stops.
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  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

and next time

Reason: