Are you aware about MarketInfo(Symbol(), MODE_STOPLEVEL)??
On ECN brokers you must open the order with no TP or SL and set them after the order is open
For a 5 digit broker you must adjust 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
WHRoeder:
On ECN brokers you must open the order with no TP or SL and set them after the order is open
not a pending order
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
When I activate Drop Pending Buy or Sell, I've got the following error:
2010.11.23 16:17:36 DROP_PENDING_BUY EURUSD,M1: invalid stoploss/takeprofit for OrderSend function
no matter if I set Stop Loss/Take Profit to 10 or 9999999. What should I do?
Here's the script (drop pending buy):
#property show_inputs
//#property show_confirm
extern double Lots = 0.1;
extern int Slippage = 3;
extern int Stop_Loss = 20;
extern int Take_Profit = 20;
//+------------------------------------------------------------------+
//| script "Open a new Buy Order" |
//+------------------------------------------------------------------+
int start()
{
double Price = WindowPriceOnDropped();
bool result;
int cmd,total,error,slippage;
//----
int NrOfDigits = MarketInfo(Symbol(),MODE_DIGITS); // Nr. of decimals used by Symbol
int PipAdjust; // Pips multiplier for value adjustment
if(NrOfDigits == 5 || NrOfDigits == 3) // If decimals = 5 or 3
PipAdjust = 10; // Multiply pips by 10
else
if(NrOfDigits == 4 || NrOfDigits == 2) // If digits = 4 or 3 (normal)
PipAdjust = 1;
//----
slippage = Slippage * PipAdjust;
double stop_loss = Price - Stop_Loss * Point * PipAdjust;
double take_profit = Price + Take_Profit * Point * PipAdjust;
if(Ask > Price)
{
result = OrderSend(Symbol(),OP_BUYLIMIT,Lots,Price,slippage,stop_loss,take_profit,"",0,0,CLR_NONE);
}
if(Ask < Price)
{
result = OrderSend(Symbol(),OP_BUYSTOP,Lots,Price,slippage,stop_loss,take_profit,"",0,0,CLR_NONE);
}
//----
return(0);
}