[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 197

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
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?