So what is the error?
Marco vd Heijden:
So what is the error?
'if' - open parenthesis expected
void OnTick() { //--- double movingAverage = iMA(NULL,0,9,0,MODE_EMA,PRICE_MEDIAN,0); double currentPrice = Open[0]; double lastPrice = Open[1]; if { (currentPrice > movingAverage) && (currentPrice < lastPrice) } { // Sell order = OrderSend(NULL,OP_SELL,0.10,currentPrice,0,NULL,NULL,NULL,0,0,NULL); } else if { (currentPrice < movingAverage) && (currentPrice > lastPrice) } { // Buy order = OrderSend(NULL,OP_BUY,0.10,currentPrice,0,NULL,NULL,NULL,0,0,NULL); } Alert("Last Price: "+lastPrice+" Current Price: "+currentPrice); }Maybe these guy's...
if { (currentPrice > movingAverage) && (currentPrice < lastPrice) } { // Sell order = OrderSend(NULL,OP_SELL,0.10,currentPrice,0,NULL,NULL,NULL,0,0,NULL); } else if { (currentPrice < movingAverage) && (currentPrice > lastPrice) } {Those are not parentheses. Perhaps you should read the manual.
Language Basics / Operators / Conditional Operator if-else - Reference on algorithmic/automated trading language for MetaTrader 5
whroeder1:
Those are not parentheses. Perhaps you should read the manual.
Language Basics / Oper
ators / Conditional Operator if-else - Reference on algorithmic/automated trading language for MetaTrader 5
Those are not parentheses. Perhaps you should read the manual.
Language Basics / Oper
whroeder1:
Those are not parentheses. Perhaps you should read the manual.
Language Basics / Operators / Conditional Operator if-else - Reference on algorithmic/automated trading language for MetaTrader 5
Those are not parentheses. Perhaps you should read the manual.
Language Basics / Operators / Conditional Operator if-else - Reference on algorithmic/automated trading language for MetaTrader 5
ators / Conditional Operator if-else - Reference on algorithmic/automated trading language for MetaTrader 5
What should I do ?
2100111702:
What should I do ?
Read the link whroeder1 gave you, The answer is there!
2100111702:
Should i try removing them ?
It never hurt's to try ...
![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
Hello,
I'm trying to code an EA and everytime I compile it gives me 1 error message, PLEASE HELP ME ...
void OnTick()
{
//---
double movingAverage = iMA(NULL,0,9,0,MODE_EMA,PRICE_MEDIAN,0);
double currentPrice = Open[0];
double lastPrice = Open[1];
if { (currentPrice > movingAverage) && (currentPrice < lastPrice) } {
// Sell
order = OrderSend(NULL,OP_SELL,0.10,currentPrice,0,NULL,NULL,NULL,0,0,NULL);
} else if { (currentPrice < movingAverage) && (currentPrice > lastPrice) } {
// Buy
order = OrderSend(NULL,OP_BUY,0.10,currentPrice,0,NULL,NULL,NULL,0,0,NULL);
}
Alert("Last Price: "+lastPrice+" Current Price: "+currentPrice);
}