even wrote >>
if (iHigh(NULL,0,0)>92.00)
OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-17*Point,Ask+33*Point,"My order #2",16384,0,Green);
but this DOES NOT WORK .. for example high is 92.10 but there is no order (syntax of order is correct)
can somebody help me please?
Syntax is correct, but you probably have a problem with stop level limitation. The following is taken from https://book.mql4.com/appendix/limits :
Order Type |
Open Price | StopLoss (SL) | TakeProfit (TP) |
---|---|---|---|
Buy |
Modification is prohibited |
Bid-SL ≥ StopLevel | TP-Bid ≥ StopLevel |
Sell |
Modification is prohibited | SL-Ask ≥ StopLevel | Ask-TP ≥ StopLevel |
In your case the TP is probably fine, but SL might not comply with: Bid-SL ≥ StopLevel.
There is no reason to guess though. You need to check and print last error after the operations using GetLastError(). Please see the example given at the bottom of: MQL4 Reference -> Trading functions -> OrderSend. In your case the error returned might be (see error codes: MQL4 Reference ->Standard constants -> Error codes):
ERR_INVALID_STOPS | 130 | Invalid stops. |
OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-17*Point,Ask+33*Point,"My order #2",16384,0,Green);
If you're running on a 5 digit broker then your stops are 1.7 and 3.3 pips away. 1) Adjust for 5 digit brokers, 2) Test the return value from the function and Print
//++++ 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; } //... external SL.pips = 17; external TP.pips = 33; if (High[0] > 92.00) { // Equivalent if (iHigh(NULL,0,0)>92.00) int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3*pips2points, Ask-SL.pips*pips2dbl, Ask+TP.pips*pips2dbl, "My order #2", 16384, 0, Green); if (ticket) <= 0) { if (ticket < 0) { Alert( "OrderSend(type=", OP_BUY, " (", operation.text, "), lots=", lots.new, ", price=", DoubleToStr( now.open, Digits ), " (", DoubleToStr((now.open-Bid)/pips2dbl,Digits.pips), "), SL=0, TP=0, '", order.comment, "', ...) failed: ", GetLastError()); //...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello. I try to make simply algorythm. If high of current bar is less then 92 it wil buy 1 lot
USD JPY
if (iHigh(NULL,0,0)>92.00)
OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-17*Point,Ask+33*Point,"My order #2",16384,0,Green);
but this DOES NOT WORK .. for example high is 92.10 but there is no order (syntax of order is correct)
can somebody help me please?