What is wrong with this code?

 
Hi everybody two days ago a convert custom indicator into EA, and here is the code but i need a little help i receive 1 mistake, and don't know how to receive this problem!

//| This MQL is generated by Expert Advisor Builder |
//| http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ |
//| |
//| In no event will author be liable for any damages whatsoever. |
//| Use at your own risk. |
//| |
//+------------------- DO NOT REMOVE THIS HEADER --------------------+

#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

#property copyright "Expert Advisor Builder"
#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"

extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = True;
extern double Lots = 1.0;
extern int Slippage = 3;
extern bool StopLossMode = True;
extern int StopLoss = 30;
extern bool TakeProfitMode = True;
extern int TakeProfit = 60;
extern bool TrailingStopMode = True;
extern int TrailingStop = 30;

int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init() {
BarCount = Bars;

if (EachTickMode) Current = 0; else Current = 1;

return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit() {
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() {
int Order = SIGNAL_NONE;
int Total, Ticket;
int newBar;
double StopLossLevel, TakeProfitLevel;



if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
static datetime Time0; newBar = Time[0] > Time0; if (!newBar) return;
Time0 = Time[0];
//+------------------------------------------------------------------+
//| Variable Begin |
//+------------------------------------------------------------------+







//+------------------------------------------------------------------+
//| Variable End |
//+------------------------------------------------------------------+

//Check position
bool IsTrade = False;

for(int index = OrdersTotal() - 1; index >= 0; index--) if (
OrderSelect(index, SELECT_BY_POS) // Only my orders w/
&& OrderMagicNumber() == MagicNumber // my magic number
&& OrderSymbol() == Symbol() ) { // and period and symbol
//...

//+------------------------------------------------------------------+
//| Signal Begin(Exit Buy) |
//+------------------------------------------------------------------+



//+------------------------------------------------------------------+
//| Signal End(Exit Buy) |
//+------------------------------------------------------------------+

if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(TrailingStopMode && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
} else {
//Close

//+------------------------------------------------------------------+
//| Signal Begin(Exit Sell) |
//+------------------------------------------------------------------+



//+------------------------------------------------------------------+
//| Signal End(Exit Sell) |
//+------------------------------------------------------------------+
int init;
if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
//Trailing stop
if(TrailingStopMode && TrailingStop > 0) {
if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
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)
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; }


continue;
}
}
}



//+------------------------------------------------------------------+
//| Signal Begin(Entry) |
//+------------------------------------------------------------------+




//+------------------------------------------------------------------+
//| Signal End |
//+------------------------------------------------------------------+

//Buy
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (StopLossMode) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
if (TakeProfitMode) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}

//Sell
if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (StopLossMode) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
if (TakeProfitMode) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else {
Print("Error opening SELL order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}

if (!EachTickMode) BarCount = Bars;

return(0);
}
}
}
}

//+------------------------------------------------------------------+
 

suggest 'you' format code into readable source.
the you will find your " '}' - unbalanced parentheses C:\Program Files\MetaTrader - Alpari UK - RUN ON DEMO ONLY\experts\^30831.mq4 (232, 1) "
is a real pig to sort out when code is 100% left-justified. is good learning exercise for you too...

 
1) You don't tell us what the error is...
2) There is an extreme LACK of indentation that makes this thing impossible to read/debug
 
Bauer_Boy wrote >>
1) You don't tell us what the error is...
2) There is an extreme LACK of indentation that makes this thing impossible to read/debug

'}' - unbalanced parentheses C:\Program Files\MetaTrader - Alpari UK - RUN ON DEMO ONLY\experts\^30831.mq4 (232, 1)
.
iow, the person should format the damn code and through this exercise the unbalanced { or } will be found.
 
malincho99:
Hi everybody two days ago a convert custom indicator into EA, and here is the code but i need a little help i receive 1 mistake, and don't know how to receive this problem!
For short code snippets u should use the SRC button, but for code such as this u should just attach the code in a file.

 
fbj:

'}' - unbalanced parentheses C:\Program Files\MetaTrader - Alpari UK - RUN ON DEMO ONLY\experts\^30831.mq4 (232, 1)
.
iow, the person should format the damn code and through this exercise the unbalanced { or } will be found.

I am sorry,but i am still novice in coding,and don't understand what do you mean with;

"the person should format the damn code"

Files:
cod.txt  8 kb
 

gordon, do you have tool to locate unbalanced parens,brackets,... ?
I may sound annoyed in prev post but the word unbalanced is exactly what happens to my head whenever I foolishly forget to hit F5 often enough due to total immersion in code entry/mods - over potentially dozens of modules. I use PSPad a lot due to the lack of MetaEd's features. But it only allows matching a single item at a time.
Have looked many times on net but just never have seen such a tool that can not get over zealous about the language and just concentrate on this generic unbalanced issue.
tia

 

malincho99
nothing wrong with being a coding novice. How you learn is through plodding along dealing with one issue at a time - reading widely and keep smiling!
.
"the person should format the damn code"
notice your code lines all start left side of line, yes?
have a visit here http://en.wikipedia.org/wiki/Programming_style and you will learn all about the word format
Then start lookin at various mql4 source files. You will soon understand the importance of formatting and as gordon said use the SRC button
.
hth

 
fbj:

gordon, do you have tool to locate unbalanced parens,brackets,... ?
I may sound annoyed in prev post but the word unbalanced is exactly what happens to my head whenever I foolishly forget to hit F5 often enough due to total immersion in code entry/mods - over potentially dozens of modules. I use PSPad a lot due to the lack of MetaEd's features. But it only allows matching a single item at a time.
Have looked many times on net but just never have seen such a tool that can not get over zealous about the language and just concentrate on this generic unbalanced issue.
tia

I use TextPad, but it too can only match a single brace at a time. Perhaps NotePad++ can do that? I never properly tried it out, but it seems to be the most popular coder's text editor for Windows...

 
gordon wrote >>

I use TextPad, but it too can only match a single brace at a time. Perhaps NotePad++ can do that? I never properly tried it out, but it seems to be the most popular coder's text editor for Windows...


Ok, thanks. I seem to remember installing NotePad++ and lived to regret it - for whatever reason!
I ended up with dodgy .exe which embedded itself so much that was nightmare to knife 'n fork out...
Is hard call I feel. On the one hand there's so much out there begging to be installed and looked at etc, and on the other hand the openness of Windows architecture which oftentimes lends itself to missuse by malware or even improperly designed apps.
Oh well, I'm gonna put a red light on the F5 key to keep reminding me! Does not happen often but when it does, many hours are lost tracking down the &(^*%$% unbalanced culprit!
 
fbj:

malincho99
nothing wrong with being a coding novice. How you learn is through plodding along dealing with one issue at a time - reading widely and keep smiling!
.
"the person should format the damn code"
notice your code lines all start left side of line, yes?
have a visit here https://en.wikipedia.org/wiki/Programming_style and you will learn all about the word format
Then start lookin at various mql4 source files. You will soon understand the importance of formatting and as gordon said use the SRC button
.
hth

https://en.wikipedia.org/wiki/Programming_style -

The page you have requested does not exist

Reason: