{
//----
if (OrdersTotal() == 0){
OrderSend(Symbol(), OP_BUY, 1,Ask, 3,Ask + stop_loss * Point, Bid - take_profit * Point, IDENT, MAGIC, 0, Blue);
}
//----
return(0);
}
Simple that is all.
why code experts not run?
Because u did not declare the variables: stop_loss, take_profit, IDENT, MAGIC. When u press compile, pay attention to the errors u get; in this case it would list each variable as "variable not defined".
Thanks Gordon !
here my variables.
extern color Do = Red;
#define MAGIC 1234#define IDENT "Akira"
extern double lots = 1;
extern double stop_loss = 80;
extern double take_profit = 600;
please help me!!!!!!!!!!!!!
Your stoploss and takeprofit are reversed... Stoploss should be lower than opening price and takeprofit higher (for buy). You should always add a print to GetLastError() after each trading function so as to have an indication of what went wrong if it did. In this case it outputs error 130 which is 'invalid stops' (and indeed they are...).
You can see an example in the documentation for GetLastError() -> https://docs.mql4.com/check/GetLastError.
And one more thing - next time:
Play videoPlease edit your post.
For large amounts of code, attach it.- What are Function return values ? How do I use them ? - MQL4 forum
- Not adjusting 4/5 digit brokers (including slippage) Not adjusting for ECN brokers.
- TP/SL wrong direction.
- Not filtering OrdersTotal using magic number makes it incompatible (on multiple charts) with every EA (including itself) and manual trading.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 start learning code MQl4. please help me . How to use OrderSend for BUY, set it... thanks a lot