# Ребят помогите ошибка '\end_of_program' - unbalanced left parenthesis не знаю что делать,не могу найти

Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
1695

//+--------------------------------------------------------------------+
//|Date of Design 03.18.12 Volfram.mq4 |
//| Copyright © 2012, MetaQuotes Software Corp. |
//| |
//|Author and Sole Owner of Tarusov Vladimir.|
//+--------------------------------------------------------------------+

#define MAGICMA 20120318

extern double AccountTarget = 10000.0; // To Set Target Level.
extern double Lots = 0.01; // Value For Lot default.
extern double LotsMinimum = 0.01; // Describe Minimum Lot Size On Lose Factor.
extern double LotsMaximum = 0.8; // Describe Maximum Lot Size On Profit Factor.
extern double RiskFactor = 1000; // Describe Risk level For order.
extern double DecreaseFactor = 300; // Describe Lot Decrease Factor For order.
extern double Order2Pips = 200; // Distance with the First order. Order No 2. Type Limit.
extern double Order3Pips = 400; // Distance with the First order. Order No 3. Type Limit.
extern double Order4Pips = 700; // Distance with the First order. Order No 4. Type Limit.
extern double Order5Pips = 1000; // Distance with the First order. Order No 5. Type Limit.
extern double Order6Pips = 1300; // Distance with the First order. Order No 6. Type Limit.
extern double Order7Pips = 1700; // Distance with the First order. Order No 7. Type Limit.
extern double Order8Pips = 2100; // Distance with the First order. Order No 8. Type Limit.
extern double Order9Pips = 2500; // Distance with the First order. Order No 9. Type Limit.
extern int Trall = 30; //traling
extern int Shag = 2; //level is a step
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) buys++; // Find and Calculate Long Orders.
if(OrderType()==OP_SELL) sells++; // Find and Calculate Short Orders.
if(OrderType()==OP_BUYLIMIT) buys++; // Find and Calculate Long Limit Orders.
if(OrderType()==OP_SELLLIMIT) sells++; // Find and Calculate Short Limit Orders.
}
}
//---- return orders volume
if(buys>0) return(buys); // Number of Order Controler.
else return(-sells);
}
//+------------------------------------------------------------------+
//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots;
int orders=HistoryTotal(); // history orders total
int losses=100; // number of losses orders without a break
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*0.01/RiskFactor,1);
//---- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
//----
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
}
//---- return lot size
if(lot<LotsMinimum) lot=LotsMinimum; // Describe Minimum Lot Size On Lose Factor.
return(lot); // and Controlar.
if(lot>LotsMaximum) lot=LotsMaximum; // Describe Maximum Lot Size On Profit Factor And Controlar.
return(LotsMaximum); // and Controlar.
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
double ma; double ma1; double ma2;
double lots2;
double lots3;
double lots4;
double lots5;
double lots6;
double lots7;
double lots8;
double lots9;
int res;
//---- get Moving Average.
ma=iMA(NULL,0,50,4,MODE_SMA,PRICE_CLOSE,0);
ma1=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0);
ma2=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,30);
lots2=(LotsOptimized()/100)*100;
lots3=(LotsOptimized()/100)*100;
lots4=(LotsOptimized()/100)*200;
lots5=(LotsOptimized()/100)*200;
lots6=(LotsOptimized()/100)*300;
lots7=(LotsOptimized()/100)*300;
lots8=(LotsOptimized()/100)*400;
lots9=(LotsOptimized()/100)*400;

//---- sell conditions.
if(ma>ma1 && ma<ma2) // Sell Order No 1. Type Instant.
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 2. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots2,Bid+Order2Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 3. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots3,Bid+Order3Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 4. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots4,Bid+Order4Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 5. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots5,Bid+Order5Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 6. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots6,Bid+Order6Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 7. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots7,Bid+Order7Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 8. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots8,Bid+Order8Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 9. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots9,Bid+Order9Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma<ma1 && ma>ma2) // Buy Order No 1. Type Instant.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 2. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 3. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 4. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 5. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 6. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 7. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 8. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 9. Type Buy Limit.
{
}

//+------------------------------------------------------------------+
{ void modify =()

{
//+-----
}
//+------------------------------------------------------------------+
//----

//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
double ma; double ma1;

//---- get Moving Average.
ma=iMA(NULL,0,30,0,MODE_SMA,PRICE_CLOSE,1);
ma1=iMA(NULL,0,30,3,MODE_SMA,PRICE_CLOSE,1);
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;

//---- Check & Find Orders And Close If Account Total Profit Status In Positive.
{
if(AccountProfit()>15 && ma>ma1)
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
if(AccountProfit()>15 && ma<ma1)
break;
}

//---- Check & Find Orders And Close If Each Account Total profit in Lose &
//---- Some Orders Profit Status In Positive.
{
if(OrderProfit()>15 && ma>ma1)
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
if(OrderProfit()>15 && ma<ma1)
break;
}
//---- Check And Close If Order Type is Limit And Trend Is Changed.
if(ma>ma1)
{
OrderDelete(OrderTicket());
return(0);
}
if(OrderType()==OP_SELLLIMIT)
if(ma<ma1)
{
OrderDelete(OrderTicket());
return(0);
}

{

//---- Check And Close Orders Immidiate, If AccountEquity Reached to Target Fixied Level.
if(AccountEquity()>AccountTarget)
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
if(AccountEquity()>AccountTarget)
break;
}
}
//----
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//+--------
modify();

//+------------------------------------------------------------------+
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return; // Stop EA if Bars is Less then...
else
if(AccountNumber()>8132663 || IsTradeAllowed()==false) return; // Stop EA if A/c No Wrong...
else
if(AccountNumber()<8132663 || IsTradeAllowed()==false) return; // Stop EA if A/c No Wrong...
else
if(Year()>=2013 || IsTradeAllowed()==false) return; // Stop EA if Year is grater then...
else
if(AccountEquity()>AccountTarget && OrdersTotal()==0 || IsTradeAllowed()==false) return; //---
// // Stop Trade if EA successed on Target and Orders Total is 0...
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//----
}
//+------------------------------------------------------------------+
//----

// добавил тралл правильно ли ?

2301

//+------------------------------------------------------------------+
{ void modify =()

это что значит?

и для

void CheckForOpen()
{

закрывающей нет

Для вставки кода

1695

valenok2003:

это что значит?

и для

закрывающей нет

Для вставки кода

я не спец а большой любитель лезть в чужие кода... нахимичил многое так как и хотел... а вот с тралом получилась проблемка... автора не знаю...

2301

Volfram:

я не спец а большой любитель лезть в чужие кода... нахимичил многое так как и хотел... а вот с тралом получилась проблемка... автора не знаю...

тогда вот это
Модератор
17843

Ну вроде вышло. Смотрите свои настройки браузера, Volfram.

Только с отступами плоховато совсем. Как-то давно Rosh кидал программку, умеющую расставлять отступы, но сейчас не найду.

Вот в первой функции отступы расставил, там все нормально, фигурные скобки сбалансированы. Дальше разберитесь сами.

//+--------------------------------------------------------------------+
//|Date of Design 03.18.12 Volfram.mq4 |
//| Copyright © 2012, MetaQuotes Software Corp. |
//| |
//|Author and Sole Owner of Tarusov Vladimir.|
//+--------------------------------------------------------------------+

#define MAGICMA 20120318

extern double AccountTarget = 10000.0; // To Set Target Level.
extern double Lots = 0.01; // Value For Lot default.
extern double LotsMinimum = 0.01; // Describe Minimum Lot Size On Lose Factor.
extern double LotsMaximum = 0.8; // Describe Maximum Lot Size On Profit Factor.
extern double RiskFactor = 1000; // Describe Risk level For order.
extern double DecreaseFactor = 300; // Describe Lot Decrease Factor For order.
extern double Order2Pips = 200; // Distance with the First order. Order No 2. Type Limit.
extern double Order3Pips = 400; // Distance with the First order. Order No 3. Type Limit.
extern double Order4Pips = 700; // Distance with the First order. Order No 4. Type Limit.
extern double Order5Pips = 1000; // Distance with the First order. Order No 5. Type Limit.
extern double Order6Pips = 1300; // Distance with the First order. Order No 6. Type Limit.
extern double Order7Pips = 1700; // Distance with the First order. Order No 7. Type Limit.
extern double Order8Pips = 2100; // Distance with the First order. Order No 8. Type Limit.
extern double Order9Pips = 2500; // Distance with the First order. Order No 9. Type Limit.
extern int Trall = 30; //traling
extern int Shag = 2; //level is a step
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
{
if(OrderType()==OP_BUY) buys++; // Find and Calculate Long Orders.
if(OrderType()==OP_SELL) sells++; // Find and Calculate Short Orders.
if(OrderType()==OP_BUYLIMIT) buys++; // Find and Calculate Long Limit Orders.
if(OrderType()==OP_SELLLIMIT) sells++; // Find and Calculate Short Limit Orders.
}
}
//---- return orders volume
if(buys>0) return(buys); // Number of Order Controler.
else return(-sells);
}
//+------------------------------------------------------------------+
//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots;
int orders=HistoryTotal(); // history orders total
int losses=100; // number of losses orders without a break
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*0.01/RiskFactor,1);
//---- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
//----
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1) lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
}
//---- return lot size
if(lot<LotsMinimum) lot=LotsMinimum; // Describe Minimum Lot Size On Lose Factor.
return(lot); // and Controlar.
if(lot>LotsMaximum) lot=LotsMaximum; // Describe Maximum Lot Size On Profit Factor And Controlar.
return(LotsMaximum); // and Controlar.
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
double ma; double ma1; double ma2;
double lots2;
double lots3;
double lots4;
double lots5;
double lots6;
double lots7;
double lots8;
double lots9;
int res;
//---- get Moving Average.
ma=iMA(NULL,0,50,4,MODE_SMA,PRICE_CLOSE,0);
ma1=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0);
ma2=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,30);
lots2=(LotsOptimized()/100)*100;
lots3=(LotsOptimized()/100)*100;
lots4=(LotsOptimized()/100)*200;
lots5=(LotsOptimized()/100)*200;
lots6=(LotsOptimized()/100)*300;
lots7=(LotsOptimized()/100)*300;
lots8=(LotsOptimized()/100)*400;
lots9=(LotsOptimized()/100)*400;

//---- sell conditions.
if(ma>ma1 && ma<ma2) // Sell Order No 1. Type Instant.
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 2. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots2,Bid+Order2Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 3. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots3,Bid+Order3Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 4. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots4,Bid+Order4Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 5. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots5,Bid+Order5Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 6. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots6,Bid+Order6Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 7. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots7,Bid+Order7Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 8. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots8,Bid+Order8Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma>ma1 && ma<ma2) // Sell Order No 9. Type Sell Limit.
{
res=OrderSend(Symbol(),OP_SELLLIMIT,lots9,Bid+Order9Pips*Point,3,0,0,"",MAGICMA,0,Red);
}
if(ma<ma1 && ma>ma2) // Buy Order No 1. Type Instant.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 2. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 3. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 4. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 5. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 6. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 7. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 8. Type Buy Limit.
{
}
if(ma<ma1 && ma>ma2) // Buy Order No 9. Type Buy Limit.
{
}

//+------------------------------------------------------------------+
{ void modify =()

{
//+-----
}
//+------------------------------------------------------------------+
//----

//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
double ma; double ma1;

//---- get Moving Average.
ma=iMA(NULL,0,30,0,MODE_SMA,PRICE_CLOSE,1);
ma1=iMA(NULL,0,30,3,MODE_SMA,PRICE_CLOSE,1);
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;

//---- Check & Find Orders And Close If Account Total Profit Status In Positive.
{
if(AccountProfit()>15 && ma>ma1)
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
if(AccountProfit()>15 && ma<ma1)
break;
}

//---- Check & Find Orders And Close If Each Account Total profit in Lose &
//---- Some Orders Profit Status In Positive.
{
if(OrderProfit()>15 && ma>ma1)
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
if(OrderProfit()>15 && ma<ma1)
break;
}
//---- Check And Close If Order Type is Limit And Trend Is Changed.
if(ma>ma1)
{
OrderDelete(OrderTicket());
return(0);
}
if(OrderType()==OP_SELLLIMIT)
if(ma<ma1)
{
OrderDelete(OrderTicket());
return(0);
}

{

//---- Check And Close Orders Immidiate, If AccountEquity Reached to Target Fixied Level.
if(AccountEquity()>AccountTarget)
OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
break;
}
if(OrderType()==OP_SELL)
{
if(AccountEquity()>AccountTarget)
break;
}
}
//----
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//+--------
modify();

//+------------------------------------------------------------------+
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return; // Stop EA if Bars is Less then...
else
if(AccountNumber()>8132663 || IsTradeAllowed()==false) return; // Stop EA if A/c No Wrong...
else
if(AccountNumber()<8132663 || IsTradeAllowed()==false) return; // Stop EA if A/c No Wrong...
else
if(Year()>=2013 || IsTradeAllowed()==false) return; // Stop EA if Year is grater then...
else
if(AccountEquity()>AccountTarget && OrdersTotal()==0 || IsTradeAllowed()==false) return; //---
// // Stop Trade if EA successed on Target and Orders Total is 0...
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//----
}
//+------------------------------------------------------------------+
//----
634

Поищите по форуму "astyle". Была тема "Вот это стиль" и там эту утилиту давали.
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий