请高手帮忙-----交易程序编译不通过
下面是我自己编的利用均线突破的交易程序,
COMPILE 后,显示
'\end_of_program' - unbalanced left parenthesis 括号不配对
感觉问题是出在
//---Check for TralingStop----
的那一段CODE
但我自己检查了好久,
也没法查出来,
只能请老师来帮我查错了,
先谢谢!
//+------------------------------------------------------------------+
//| MA Trend System.mq4 |
//| |
//| 突破长短期均线,趋势追随 |
//+------------------------------------------------------------------+
#define MAGICMA 20050610
extern double Lots = 0.1;
extern double TrailingStop = 70;
extern double MaximumRisk = 0.02;
extern double DecreaseFactor = 3;
extern double MovingShort = 60;
extern double MovingTrend = 240;
extern double MovingShortMode = 0; //0=sma, 1=ema, 2=smma, 3=lwma
extern double MovingTrendMode = 0; //0=sma, 1=ema, 2=smma, 3=lwma
double MAshort;
double MAtrend;
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//----
for(int i=0;i0) return(buys);
else return(-sells);
}
//+------------------------------------------------------------------+
//| Calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
double lot=Lots;
int orders=HistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,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<0.1) lot=0.1;
return(lot);
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
int res;
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//---- get Moving Average
MAshort=iMA(NULL,0,MovingShort,0,MovingShortMode,PRICE_CLOSE,0);
MAtrend=iMA(NULL,0,MovingTrend,0,MovingTrendMode,PRICE_CLOSE,0);
//---- sell conditions
if(Open[1]>MAshort && Close[1]MAshort && MAshort>MAtrend)
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask-(Point*TrailingStop),0,"",MAGICMA,0,Red);
return;
}
//----
}
//+------------------------------------------------------------------+
//| Check for TralingStop conditions |
//+------------------------------------------------------------------+
void CheckForClose()
{
//---- go trading only for first tiks of new bar
if(Volume[0]>1) return;
//----
for(int i=0;i(Point*TrailingStop))
{
if(OrderStopLoss()< (Bid-Point*TrailingStop))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,0,0,Green);
return;
}
}
}
if(OrderType()==OP_SELL)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,0,0,Red);
return;
}
}
}
}
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- check for history and trading
if(Bars<100 || IsTradeAllowed()==false) return;
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose();
//----
}
发表于:2006-05-02 08:12只看该作者
2楼
你代码里面有93个(,但是只有92个),问题就在这里
if((OrderStopLoss()>(Ask+Point*TrailingStop))
这里面多了一个(,去了就行了
发表于:2006-05-02 15:15只看该作者
4楼
应该去调哪一个( ?
韬客外汇论坛TALKFOREX.COM
发表于:2006-05-02 15:34只看该作者
5楼
那一行最开始两个(,随便去掉一个就行了
发表于:2006-05-02 16:58只看该作者
6楼
hawkie 高手,羡慕
韬客社区www.talkfx.co
发表于:2006-06-10 13:38只看该作者
7楼
原帖由 顶底背离 于 2006-5-2 15:24 发表 下面是我自己编的利用均线突破的交易程序, COMPILE 后,显示 '\end_of_program' - unbalanced left parenthesis 括号不配对 感觉问题是出在 //---Check for TralingStop---- 的那一段CODE 但我自己检查了 ...
韬客社区www.talkfx.co