Comrades, help please... I wrote a simple code, but when compiling it says that the brackets are out of balance, but I've already counted them 300 times - everything is in place
The idea is simple - if MACD has been above (or below) 0 for 7 minutes or less, the position opens
And as for the brackets, I have a habit of specifying what the closing refers to
}//for
}// (signal...
"to taste and colour..." - but I must admit that this approach overloads the code with unnecessary information + takes time to write extra lines of code + does not solve the problem of deep nesting (numbering levels?)
Better structure the code - as in the example above
Good afternoon, could you please tell me how to write a condition so that after opening one order, the second cannot open on the same candle. I am writing the following:
// count the number of open orders for a security int CountOrder=0; for (int j=0; j<OrdersTotal(); j++) if (OrderSelect(j,SELECT_BY_POS,MODE_TRADES)) if (OrderSymbol()==Symbol()) CountOrder++;
// bar number of last closed position or -1, if it hasn't been opened yet int BarLast=BarLastClosePose();
и
// bar number of the last closed position int BarLastClosePose() { datetime t; int i;
for (i=0; i<OrdersHistoryTotal(); i++) { if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) { //if (OrderMagicNumber()!=Magic) continue; if (OrderSymbol()!=Symbol()) continue; if (OrderType()>1) continue; if (t<OrderCloseTime()) t=OrderCloseTime(); } }
Vinin, verified, everything is fine in this function... return(0) refers to the start function, and if you don't count the brackets attached to return'y, you get 14 brackets... 7 each way
Vinin, verified, everything is fine in this function... return(0) refers to the start function, and if you don't count the brackets that are attached to return'y, you get 14 brackets... 7 each way.
Copying each function into a separate file and verifying compilation helps.
If the brackets are correct, then indicate where the start ends and the MACD signal begins.
int start()
{
//---- int total,ticket; //объявил тотал и тикет int signal = signal_MACD(); //сигнал МАКД передает значение в сигнал
AnalyzeSignal(signal); //аналайз сигнал анализирует сигналint MACD[8] = {0,1,2,3,4,5,6,7}; //создал одномерный массив МАКД
MACD[0] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,7);
///Бла-бла-бла
MACD[7] = iMACD(Symbol(),1,5,34,5,PRICE_CLOSE,MODE_MAIN,0);
total = OrdersTotal(); //тотал считает ордера///Тут большая жирная закрывающая скобка, если конечно следующая строчка это функцияint signal_MACD()
Copying each function into a separate file and verifying compilation helps.
If the brackets are correct, indicate where the start ends and the MACD signal begins.
hmm... int signal_MACD() is indeed a function... but why does it have to be behind the start function? i honestly don't understand why some functions are written outside the start and some inside... what is the difference?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Comrades, help please... I wrote a simple code, but when compiling it says that the brackets are out of balance, but I've already counted them 300 times - everything is in place
The idea is simple - if MACD has been above (or below) 0 for 7 minutes or less, the position opens
Check this function
p.s. how do you draw a script as nicely as you do?
There's an SRC button when you write your answer.
As for brackets, I'm in the habit of specifying what the close bracket refers to
}//for
}// (signal...
And as for the brackets, I have a habit of specifying what the closing refers to
}//for
}// (signal...
"to taste and colour..." - but I must admit that this approach overloads the code with unnecessary information + takes time to write extra lines of code + does not solve the problem of deep nesting (numbering levels?)
Better structure the code - as in the example above
Good afternoon, could you please tell me how to write a condition so that after opening one order, the second cannot open on the same candle. I am writing the following:
if (... && CountOrder<2 && (BarLast>1 || BarLast==-1))
{
OrderSend(Symbol(),OP_BUY,MinLot,Ask,0,VStopLossLong,0, "BUY: ",MagicL,0,Green);
}
where
// count the number of open orders for a security
int CountOrder=0;
for (int j=0; j<OrdersTotal(); j++)
if (OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
if (OrderSymbol()==Symbol()) CountOrder++;
// bar number of last closed position or -1, if it hasn't been opened yet
int BarLast=BarLastClosePose();
и
// bar number of the last closed position
int BarLastClosePose()
{
datetime t;
int i;
for (i=0; i<OrdersHistoryTotal(); i++)
{
if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
//if (OrderMagicNumber()!=Magic) continue;
if (OrderSymbol()!=Symbol()) continue;
if (OrderType()>1) continue;
if (t<OrderCloseTime()) t=OrderCloseTime();
}
}
return (iBarShift(Symbol(),Period(),t,true));
}
Check this function
Vinin, verified, everything is fine in this function... return(0) refers to the start function, and if you don't count the brackets attached to return'y, you get 14 brackets... 7 each way
Vinin, verified, everything is fine in this function... return(0) refers to the start function, and if you don't count the brackets that are attached to return'y, you get 14 brackets... 7 each way.
Copying each function into a separate file and verifying compilation helps.
If the brackets are correct, then indicate where the start ends and the MACD signal begins.
Copying each function into a separate file and verifying compilation helps.
If the brackets are correct, indicate where the start ends and the MACD signal begins.
hmm... int signal_MACD() is indeed a function... but why does it have to be behind the start function? i honestly don't understand why some functions are written outside the start and some inside... what is the difference?