whn i compile i get the error "{" unexpected end of the program..could anyone help me in correcting the error ..it would be honoured...here is the code.
//+------------------------------------------------------------------+
//| FIRSTEA.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| GLOBAL |
//+------------------------------------------------------------------+
double LotSize=0.1;
double TakeProfit=1.0;
double StopLoss=500.0;
int SlippagePips=5;
int MagicNumber=1133;
//Variables
double UsePipUpdate;
double UseSlippUpdate;
static datetime LastBarTime;
int BuyTicket;
int SellTicket;
int ErrCode;
//Indicator
int FastMAPeriod=10;
int SlowMAPeriod=25;
//+------------------------------------------------------------------+
//| START |
//+------------------------------------------------------------------+
int start(){
double UsePipUpdate=PipUpdate(Symbol());
double UseSlippUpdate=SlippageUpdate(Symbol(),CalcSlipp);
//IndicatorTrade
double FastMA=iMA(NULL,0,FastMAPeriod,0,0,0,1);
double SlowMA=iMA(NULL,0,SlowMAPeriod,0,0,0,1);
double LastFastMA=iMA(NULL,0,FastMAPeriod,0,0,0,2);
double LastSlowMA=iMA(NULL,0,SlowMAPeriod,0,0,0,2);
//BuyOrderTrade
if(FastMA >SlowMA && LastFastMA<=LastSlowMA && BuyMarketCount(String Symbol,int MagicNumber==0)
{
//Close SellOrder
OrderSelect(SellTicket,SELECT_BY_TICKET);
if(OrderCloseTime()==0 && SellTicket>0){
while(IsTradeContextBusy()) Sleep(10);
double CloseLots=OrderLots();
double ClosePrice=Ask;
bool Closed= OrderClose(SellTicket,CloseLots,ClosePrice,UseSlippUpdate,Blue);
if(Closed==false){
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Close Sell Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
}
//OpenBuyOrder
while(IsTradeContextBusy()) Sleep(10);
BuyTicket= OrderSend(Symbol(),OP_BUY,LotSize,Ask,UseSlippUpdate,0,0,"FIRSTSTRIKE",MagicNumber,0,Green);
if(BuyTicket==-1){
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Open Buy Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
//ModifyBuyOrder
else{
OrderSelect(BuyTicket,SELECT_BY_TICKET);
double OpenPrice=OrderOpenPrice();
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)* Point;
double UpperStopLevel=Ask+StopLevel;
double LowerStopLevel=Bid-StopLevel;
double MinStop=5*UsePipUpdate;
double BuyStopLoss=OpenPrice-(StopLoss * UsePipUpdate);
double BuyTakeProfit=OpenPrice+(TakeProfit * UsePipUpdate);
if(BuyStopLoss >0 && BuyStopLoss>LowerStopLevel){
BuyStopLoss=LowerStopLevel-MinStop;
}
if(BuyTakeProfit>0 && BuyTakeProfit <UpperStopLevel){
BuyTakeProfit=UpperStopLevel+MinStop;
}
if(IsTradeContextBusy()) Sleep(10);
if(BuyStopLoss>0 || BuyTakeProfit>0){
bool TicketMod=OrderModify(BuyTicket,OpenPrice,BuyStopLoss,BuyTakeProfit,0,);
if(TicketMod == false) {
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Modify Buy Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
}
}
}
//SellOrderTrade
if(FastMA<SlowMA && LastFastMA>=LastSlowMA && SellMarketCount(Symbol(),MagicNumber==0)
{
//Close BuyOrder
OrderSelect(SellTicket,SELECT_BY_TICKET);
if(OrderCloseTime()==0 && BuyTicket>0){
while(IsTradeContextBusy()) Sleep(10);
double CloseLots=OrderLots();
double ClosePrice=Bid;
bool Closed= OrderClose(BuyTicket,CloseLots,ClosePrice,UseSlippUpdate,Blue);
if(Closed==false){
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Close Buy Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
}
//OpenSellOrder
while(IsTradeContextBusy()) Sleep(10);
SellTicket= OrderSend(Symbol(),OP_SELL,LotSize,Bid,UseSlippUpdate,0,0,"FIRSTSTRIKE",MagicNumber,0,Red);
if(SellTicket==-1){
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Open Sell Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
//ModifyBuyOrder
else{
OrderSelect(SellTicket,SELECT_BY_TICKET);
double OpenPrice=OrderOpenPrice();
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)* Point;
double UpperStopLevel=Ask+StopLevel;
double LowerStopLevel=Bid-StopLevel;
double MinStop=5*UsePipUpdate;
double SellStopLoss=OpenPrice+(StopLoss * UsePipUpdate);
double SellTakeProfit=OpenPrice-(TakeProfit * UsePipUpdate);
if(SellStopLoss >0 && SellStopLoss<UpperStopLevel){
SellStopLoss=UpperStopLevel+MinStop;
}
if(SellTakeProfit>0 && SellTakeProfit >LowerStopLevel){
SellTakeProfit=LowerStopLevel-MinStop;
}
if(IsTradeContextBusy()) Sleep(10);
if(SellStopLoss>0 || SellTakeProfit>0){
bool TicketMod=OrderModify(SellTicket,OpenPrice,SellStopLoss,SellTakeProfit,0,);
if(TicketMod == false) {
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Modify Sell Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
}
}
}
//+------------------------------------------------------------------+
//| CUSTOM |
//+------------------------------------------------------------------+
//NewBarCheck
datetime NewBarCheck(){
LastBarTime=Time[1];
CurrentBarTime=Time[0];
bool NewBar=CurrentBarTime!=LastBarTime;
LastBarTime=CurrentBarTime;
return(NewBar);
}
//PipUpdate
double PipUpdate(string Currrency){
double CalcDigits=MarketInfo(Currency,MODE_DIGITS);
if(CalcDigits==2 || CalcDigits ==3 ) CalcPoint =0.01;
if(CalcDigits==4 || CalcDigits ==5 ) CalcPoint=0.0001;
return(CalcPoint);
}
//SlippageUpdate
double SlippageUpdate(string Currency,int SlippagePips){
double CalcDigits=MarketInfo(Currency,MODE_DIGITS);
if(CalcDigits==2 || CalcDigits ==3) CalcSlipp=SlippagePips;
if(CalcDigits==4 || CalcDigits ==5) CalcSlipp=SlippagePips *10;
return(CalcSlipp);
}
//TotalOrderCount
int TotalOrderCount(String Symbol,int MagicNumber){
int OrderCount;
TotalNumberOfOrders=OrdersTotal();
for(PositionIndex=OrdersTotal-1;PositionIndex>=0;PositionIndex--)
{
OrderSelect(Counter,SELECT_BY_POS);
if(OrderSymbol()== Symbol && OrderMagicNumber() ==MagicNumber)
{
OrderCount--;
}
}
return(OrderCount);
}
//BuyMarketCount
int BuyMarketCount(String Symbol,int MagicNumber){
int OrderCount;
TotalNumberOfOrders=OrdersTotal();
for(PositionIndex=OrdersTotal-1;PositionIndex>=0;PositionIndex--)
{
OrderSelect(Counter,SELECT_BY_POS);
if(OrderSymbol()== Symbol && OrderMagicNumber() ==MagicNumber && OrderTypee()==OP_BUY)
{
OrderCount--;
}
}
return(OrderCount);
}
//SellMarketCount
int SellMarketCount(String Symbol,int MagicNumber){
int OrderCount;
TotalNumberOfOrders=OrdersTotal();
for(PositionIndex=OrdersTotal-1;PositionIndex>=0;PositionIndex--)
{
OrderSelect(Counter,SELECT_BY_POS);
if(OrderSymbol()== Symbol && OrderMagicNumber() ==MagicNumber && OrderTypee()==OP_SELL)
{
OrderCount--;
}
}
return(OrderCount);
}
//| FIRSTEA.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| GLOBAL |
//+------------------------------------------------------------------+
double LotSize=0.1;
double TakeProfit=1.0;
double StopLoss=500.0;
int SlippagePips=5;
int MagicNumber=1133;
//Variables
double UsePipUpdate;
double UseSlippUpdate;
static datetime LastBarTime;
int BuyTicket;
int SellTicket;
int ErrCode;
//Indicator
int FastMAPeriod=10;
int SlowMAPeriod=25;
//+------------------------------------------------------------------+
//| START |
//+------------------------------------------------------------------+
int start(){
double UsePipUpdate=PipUpdate(Symbol());
double UseSlippUpdate=SlippageUpdate(Symbol(),CalcSlipp);
//IndicatorTrade
double FastMA=iMA(NULL,0,FastMAPeriod,0,0,0,1);
double SlowMA=iMA(NULL,0,SlowMAPeriod,0,0,0,1);
double LastFastMA=iMA(NULL,0,FastMAPeriod,0,0,0,2);
double LastSlowMA=iMA(NULL,0,SlowMAPeriod,0,0,0,2);
//BuyOrderTrade
if(FastMA >SlowMA && LastFastMA<=LastSlowMA && BuyMarketCount(String Symbol,int MagicNumber==0)
{
//Close SellOrder
OrderSelect(SellTicket,SELECT_BY_TICKET);
if(OrderCloseTime()==0 && SellTicket>0){
while(IsTradeContextBusy()) Sleep(10);
double CloseLots=OrderLots();
double ClosePrice=Ask;
bool Closed= OrderClose(SellTicket,CloseLots,ClosePrice,UseSlippUpdate,Blue);
if(Closed==false){
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Close Sell Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
}
//OpenBuyOrder
while(IsTradeContextBusy()) Sleep(10);
BuyTicket= OrderSend(Symbol(),OP_BUY,LotSize,Ask,UseSlippUpdate,0,0,"FIRSTSTRIKE",MagicNumber,0,Green);
if(BuyTicket==-1){
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Open Buy Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
//ModifyBuyOrder
else{
OrderSelect(BuyTicket,SELECT_BY_TICKET);
double OpenPrice=OrderOpenPrice();
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)* Point;
double UpperStopLevel=Ask+StopLevel;
double LowerStopLevel=Bid-StopLevel;
double MinStop=5*UsePipUpdate;
double BuyStopLoss=OpenPrice-(StopLoss * UsePipUpdate);
double BuyTakeProfit=OpenPrice+(TakeProfit * UsePipUpdate);
if(BuyStopLoss >0 && BuyStopLoss>LowerStopLevel){
BuyStopLoss=LowerStopLevel-MinStop;
}
if(BuyTakeProfit>0 && BuyTakeProfit <UpperStopLevel){
BuyTakeProfit=UpperStopLevel+MinStop;
}
if(IsTradeContextBusy()) Sleep(10);
if(BuyStopLoss>0 || BuyTakeProfit>0){
bool TicketMod=OrderModify(BuyTicket,OpenPrice,BuyStopLoss,BuyTakeProfit,0,);
if(TicketMod == false) {
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Modify Buy Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
}
}
}
//SellOrderTrade
if(FastMA<SlowMA && LastFastMA>=LastSlowMA && SellMarketCount(Symbol(),MagicNumber==0)
{
//Close BuyOrder
OrderSelect(SellTicket,SELECT_BY_TICKET);
if(OrderCloseTime()==0 && BuyTicket>0){
while(IsTradeContextBusy()) Sleep(10);
double CloseLots=OrderLots();
double ClosePrice=Bid;
bool Closed= OrderClose(BuyTicket,CloseLots,ClosePrice,UseSlippUpdate,Blue);
if(Closed==false){
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Close Buy Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
}
//OpenSellOrder
while(IsTradeContextBusy()) Sleep(10);
SellTicket= OrderSend(Symbol(),OP_SELL,LotSize,Bid,UseSlippUpdate,0,0,"FIRSTSTRIKE",MagicNumber,0,Red);
if(SellTicket==-1){
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Open Sell Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
//ModifyBuyOrder
else{
OrderSelect(SellTicket,SELECT_BY_TICKET);
double OpenPrice=OrderOpenPrice();
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL)* Point;
double UpperStopLevel=Ask+StopLevel;
double LowerStopLevel=Bid-StopLevel;
double MinStop=5*UsePipUpdate;
double SellStopLoss=OpenPrice+(StopLoss * UsePipUpdate);
double SellTakeProfit=OpenPrice-(TakeProfit * UsePipUpdate);
if(SellStopLoss >0 && SellStopLoss<UpperStopLevel){
SellStopLoss=UpperStopLevel+MinStop;
}
if(SellTakeProfit>0 && SellTakeProfit >LowerStopLevel){
SellTakeProfit=LowerStopLevel-MinStop;
}
if(IsTradeContextBusy()) Sleep(10);
if(SellStopLoss>0 || SellTakeProfit>0){
bool TicketMod=OrderModify(SellTicket,OpenPrice,SellStopLoss,SellTakeProfit,0,);
if(TicketMod == false) {
ErrCode=GetLastError();
string ErrDesc=ErrorDescription(ErrCode);
String ErrLog=StringConcatenate("Modify Sell Order -Error",ErrorCode ,":",ErrDesc);
Print(ErrLog);
}
}
}
}
//+------------------------------------------------------------------+
//| CUSTOM |
//+------------------------------------------------------------------+
//NewBarCheck
datetime NewBarCheck(){
LastBarTime=Time[1];
CurrentBarTime=Time[0];
bool NewBar=CurrentBarTime!=LastBarTime;
LastBarTime=CurrentBarTime;
return(NewBar);
}
//PipUpdate
double PipUpdate(string Currrency){
double CalcDigits=MarketInfo(Currency,MODE_DIGITS);
if(CalcDigits==2 || CalcDigits ==3 ) CalcPoint =0.01;
if(CalcDigits==4 || CalcDigits ==5 ) CalcPoint=0.0001;
return(CalcPoint);
}
//SlippageUpdate
double SlippageUpdate(string Currency,int SlippagePips){
double CalcDigits=MarketInfo(Currency,MODE_DIGITS);
if(CalcDigits==2 || CalcDigits ==3) CalcSlipp=SlippagePips;
if(CalcDigits==4 || CalcDigits ==5) CalcSlipp=SlippagePips *10;
return(CalcSlipp);
}
//TotalOrderCount
int TotalOrderCount(String Symbol,int MagicNumber){
int OrderCount;
TotalNumberOfOrders=OrdersTotal();
for(PositionIndex=OrdersTotal-1;PositionIndex>=0;PositionIndex--)
{
OrderSelect(Counter,SELECT_BY_POS);
if(OrderSymbol()== Symbol && OrderMagicNumber() ==MagicNumber)
{
OrderCount--;
}
}
return(OrderCount);
}
//BuyMarketCount
int BuyMarketCount(String Symbol,int MagicNumber){
int OrderCount;
TotalNumberOfOrders=OrdersTotal();
for(PositionIndex=OrdersTotal-1;PositionIndex>=0;PositionIndex--)
{
OrderSelect(Counter,SELECT_BY_POS);
if(OrderSymbol()== Symbol && OrderMagicNumber() ==MagicNumber && OrderTypee()==OP_BUY)
{
OrderCount--;
}
}
return(OrderCount);
}
//SellMarketCount
int SellMarketCount(String Symbol,int MagicNumber){
int OrderCount;
TotalNumberOfOrders=OrdersTotal();
for(PositionIndex=OrdersTotal-1;PositionIndex>=0;PositionIndex--)
{
OrderSelect(Counter,SELECT_BY_POS);
if(OrderSymbol()== Symbol && OrderMagicNumber() ==MagicNumber && OrderTypee()==OP_SELL)
{
OrderCount--;
}
}
return(OrderCount);
}
Please use the SRC button when posting code.
I have done it for you this time and also removed some of the huge gaps.
Do not double post - I have deleted your other post.
}
} //This "}" was missing
}
//+------------------------------------------------------------------+
//| CUSTOM |
Adding in the missing } will reveal other problems ie
int TotalOrderCount(String Symbol,int MagicNumber){
String should be string will a small "s".
double UseSlippUpdate=SlippageUpdate(Symbol(),CalcSlipp);
CalcSlipp has not been declared
There are many more errors, so you will need to check them all

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
I've eliminate all of the compile errors in my EA mq4 source code except this one: '\End-of-program - unexpected square bracket'. I don't see any square brackets at the end of the program or anywhere else in the file. Can anyone suggest what to look for to remove this error. Thanks for any comments.
William