BULL 导师,能帮我看下吗?

楼主  收藏   举报   帖子创建时间:  2019-05-05 04:58 回复:0 关注量:199
BULL 导师,你好,能帮我看下吗?
  总有一个错误,但是我总找不出来。谢谢<div class="blockcode"><div id="code_d5G"><ol>
//+------------------------------------------------------------------+
#property copyright "2009"
#property link " "

int MagicNumber = 0;
string EAname ="顺势";
int MAGICMA = 2000;


//定义资金管理--------------------------------------------------------+
extern string _资金管理_ ="任选一个";
extern bool zijiguanli1= true;//false true、、
extern bool zijiguanli2= false;//false true、、
extern bool zijiguanli3= false;//false true、、

// 定义各参数--------------------------------------------------------+
extern int FastEMA = 12;
extern int SlowEMA = 26;
extern int SignalSMA = 9;

//定义指标函数--------------------------------------------------------+
    double ema120;
    double sma20,sma21;
    double ema15,ema16;

  //定义止赢止损,滑点---------------------------------------------------+
    double TP=0,TPP=0,SL=0,SLL=0; //赚120点出场,亏20点出场
    int slip=6;  
//定义移动止损-------------------------------------------------------+
    int cnt;
    extern double TrailingStop=20;//移动止损为20点
//+------------------------------------------------------------------+
    double mode=0;
    double LastOrderType;
    double LastPricesell;
    double LastPricebuy;
    double LastPrice;
    double OpenSells;
    double OpenSellStops;
    double OpenBuys;
    double OpenBuyStops;
    double SLauto;
    string text="";

//定义下单信息--------------------------------------------------------+   
    extern double cheng=1;
    double aa=0;
    int s=0,b=0,i,panduan=0;
    double CurrentBasket=0;
    double LotMM=0;
    double lotstart=0;
    double LotsMax=100;
    double LotsMin=0.1;
    extern double lotab=1;
    extern double Stoploss=0,no60=60;
    double lots=0;

//关于保证金-----------------------------------------------------------+
double BaoZhenJing;

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

int 判断=0,buy1=1,buy2=1,buy3=1,buy4=1,sell1=1,sell2=1,sell3=1,sell4=1;

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//以后可能有用到
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//以后可能有用到
return(0);
}
//+------------------------------------------------------------------+
//| expert start 主程式
//+------------------------------------------------------------------+
int start()
{
MoneyManagement();//资金管理
ma();//指标管理
zhangchang();//战场管理
jiancha();//检查
TrailingStop();//移动止损
xianshi();//显示管理

return(0);
}

//资金管理-------------------------------------------------------------+
void MoneyManagement() {
lotstart=(AccountBalance()*lotab/10000);
lots=lotstart;
if(cheng==0){cheng=1;}
CurrentBasket=AccountEquity()-AccountBalance();
/////////////////////////////////////////////////////////////////
if(zijiguanli1){ LotMM = lots;}
/////////////////////////////////////////////////////////////////
if(zijiguanli2){
if(CurrentBasket=10){aa=66;}
if(CurrentBasket= 1 ) { return(0); }
BaoZhenJing = MarketInfo( Symbol(), MODE_MARGINREQUIRED); // 一个标准手需保证金金额。
BaoZhenJing = BaoZhenJing * LotMM ; // 下单需用的保证金
if( (AccountMargin()+BaoZhenJing) / (AccountMargin()+AccountFreeMargin()) >= 1 ) { return(0); }
//+-------------------------------------------------------------------+

if(s+b==111){buyme();sellme();CloseSell();CloseBuy();closeall();}

datetime Time0 = 0;
if (Time0 != Time[0]){
Time0 = Time[0];


if(
(b==0 && ema120ema15 && sma21sma21 && sma20ema16)){判断=2;sellme();}


}
if(判断==2 && b>0){CloseBuy();}
if(判断==1 && s>0){CloseSell();}
//if(s+b>0 && AccountProfit()>30){closeall();}

if(sma20>ema15 b>0){CloseBuy();}
if(sma200){CloseSell();}
    return(0);
}


//下单后没成交 撤单--------------------------------------------------------------+
//if (OrderSend==OP_BUY)
//if((OrderOpenPrice-OrderClosePrice)/Point  > 100)
//OrderDelete(OrderTicket)};
//if (OrderSend==OP_SELL)
//if((OrderClosePrice-OrderOpenPrice)/Point  > 100)
//OrderDelete(OrderTicket)};


//买入开单--------------------------------------------------------------+
void buyme(){
if (TP==0) { TPP=0; } if(TP>0) { TPP=Ask+TP*Point; }
if (SL==0) { SLL=0; } if(SL>0) { SLL=Ask-SL*Point; }
OrderSend(Symbol(),OP_BUY,LotMM,Ask,slip,SLL,TPP,"M"+Period()+"",0,0,Violet);
return(0); }


//卖出开单--------------------------------------------------------------+
void sellme(){
if (TP==0) { TPP=0; } if(TP>0) { TPP=Bid-(TP*Point); }
if (SL==0) { SLL=0; } if(SL>0) { SLL=Bid+(SL*Point); }
OrderSend(Symbol(),OP_SELL,LotMM,Bid,2,SLL,TPP,"M"+Period()+"",0,0,GreenYellow);
return(0); }

//平仓持有的买单-------------------------------------------------------+
void CloseBuy()
{
if (OrdersTotal( ) > 0 )   
{
   for(i=OrdersTotal()-1;i>=0;i--)
   {
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)     break;
   if(OrderType()==OP_BUY)
   {
     OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
     Sleep(5000);
   }  }}}

//平仓持有的卖单--------------------------------------------------------+
void CloseSell()
{
if (OrdersTotal( ) > 0 )   
{
   for(i=OrdersTotal()-1;i>=0;i--)
   {
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)     break;
   if(OrderType()==OP_SELL)
     {
     OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
     Sleep(5000);
     }  }}}

//平仓所有--------------------------------------------------------+
void closeall()
{
if (OrdersTotal( ) > 0 )   
{
   for(i=OrdersTotal()-1;i>=0;i--)
   {
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)     break;
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)     break;
   if(OrderType()==OP_SELL)
   if(OrderType()==OP_BUY)
     {
     OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
     OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
     Sleep(5000);
     }  }}}

   
//移动止损-----------------------------------------------------------+

void TrailingStop()
{
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() )//&& OrderMagicNumber()==MAGICMA)
{
if (OrderType()==OP_SELL)
{
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}

if (OrderType()==OP_BUY)
{
if(TrailingStop>0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()
打赏