Your Broker is 5 digit, so Stoploss must be >50 Point from Ask.
"Ask-20*Point" will Invalid Stops.
Your Broker is 5 digit, so Stoploss must be >50 Point from Ask.
"Ask-20*Point" will Invalid Stops.
I don't understand your explanation. What does the number of digits after the decimal point have to do with stoploss?!
I thought
MarketInfo(Symbol(), MODE_STOPLEVEL)
determines the stop level restrictions...
So if equals to 0.00000, then there are no restrictions. You should even be able to put in 1 pt. as stop level...
Okay, I figured it out myself!
Since order BUY is closed by Bid, then StopLoss has to be below Bid level, meaning below the level of the spread.
On my broker the average spread is 2.8 pips, so when I put in StopLoss of 20 pts. from Ask price (i.e. only 2 pips), it was below the value of the spread, and thus invalid.
@rockyhoangdn - I still have no idea what you were talking about, but thanks for trying!
nanquan
OrderSend(Symbol(),OP_BUY,0.1,Ask,1,Ask-(Ask-Bid)-20*Point,Ask+20*Point,"BUY ORDER",12345,0,Green);
Try it this way
You use Ask + Spread
The right one is Ask - Spread = Bid
- You BUY at the ASK, SELL at the bid, so your stops must be relative to the BID and outside the current value by stopLevel
- On ECN brokers you must open first and THEN set stops.
- On 5 digit brokers you must adjust TP, SL, AND slippage
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.015 0.0150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ OptParameters(); if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers. /* On ECN brokers you must open first and THEN set stops int ticket = OrderSend(..., 0,0,...) if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else if (!OrderSelect(ticket, SELECT_BY_TICKET)) Alert("OrderSelect failed: ", GetLastError()); else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0) Alert("OrderModify failed: ", GetLastError()); */
Guys, like I said, I already figured this out! :)
But thank you for your input!
nanquan
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm on a 5 digit broker. Using Strategy Tester!
This code,
returns 0.00000
However, this code:
generates error 130, i.e. "Invalid Stops".
So I don't get it... If broker Stop Level is set to 0, there should be no restrictions! How come StopLoss/TakeProfit of 20 pts. generates error 130?!
Thanks!
nanquan