求助,我的EA只卖不买,请高手帮我看看哪里出了错?

 

//+------------------------------------------------------------------+
//| EA_20120123_啸月寒天.mq4 |
//| Copyright ?2011, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net//"


extern string Lotset="交易手数设置";
extern double lot=0.1; //交易手数设置
extern int feijianxorders=5; //最多持单数
extern string Indset="指标设置";
extern int MACD_fast=12; //MACD参数设置
extern int MACD_slow=26;
extern int MACD_SMA=9; //MA参数设置
extern double MACD_valumebuy=0.0003; //MACD做多值
extern double MACD_valumesell=-0.0003; //MACD做空值
extern int MA_fast=2;
extern int MA_slow=19;
extern int CCI_period=35; //CCI参数设置
extern double CCI_valumebuy=50; //CCI做多单的值
extern double CCI_valumesell=-50; //CCI做空单的值

extern string Profitset="止盈,止损设置";
extern int stoploss=100; //止损
extern int takeprofit=200; //止盈
extern int trailstart=50; //跟踪止损开始
extern int trailstop=30; //跟踪止损回撤点数

int feijianbuysignal=0;
int feijiansellsignal=0;
int tickbuy=0;
int ticksell=0;
int magic=888;
int wei=1;
//+------------------------------------------------------------------+
int init()
{
if(Digits==5 ||Digits==3)wei=10;
else wei=1;
return(0);
}
//+------------------------------------------------------------------+
int start()
{
closeorder();
firstorder();
Trailingstop();
return(0);
}
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
int firstorder()
{
int ticketB,ticketS;
double feijian_1=iCustom(NULL,0,"非均线箭头指示",0,1);//蓝色
double feijian_2=iCustom(NULL,0,"非均线箭头指示",1,1);//红色
double fastma_0=iMA(NULL,0,MA_fast,0,MODE_SMA,PRICE_CLOSE,1);
double slowma_0=iMA(NULL,0,MA_slow,0,MODE_SMA,PRICE_CLOSE,1);
double fastma_1=iMA(NULL,0,MA_fast,0,MODE_SMA,PRICE_CLOSE,2);
double slowma_1=iMA(NULL,0,MA_slow,0,MODE_SMA,PRICE_CLOSE,2);
if(feijian_1>0)
{
feijiansellsignal=0;
feijianbuysignal=1;
ticksell=0;
}
if(feijian_2>0)
{
feijiansellsignal=-1;
feijianbuysignal=0;
tickbuy=0;
}



double ccivalume=iCCI(NULL,0,CCI_period,PRICE_CLOSE,0);
double MACD=iMACD(NULL,0,MACD_fast,MACD_slow,MACD_SMA,PRICE_CLOSE,MODE_MAIN,0);

if(tickbuy==0 && CheckOrders(0)<feijianxorders && feijianbuysignal==1 &&fastma_0>slowma_0 && fastma_1<=slowma_1 && MACD>=MACD_valumebuy && ccivalume>=CCI_valumebuy && Samebaropened1()==false && Samebaropened2()==false)
{
ticketB=OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,"",magic,0,Blue);
if(ticketB>0)
{
OrderSelect(ticketB,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-stoploss*Point*wei,OrderOpenPrice()+takeprofit*Point*wei,0,0);
tickbuy++;
return(0);
}
if(ticketB<0)
{
Print("OrderSend 失败错误 #",GetLastError());
return(0);
}
}
if(ticksell==0 && CheckOrders(1)<feijianxorders && feijiansellsignal==-1 &&fastma_0<slowma_0 && fastma_1>=slowma_1 && MACD<=MACD_valumesell && ccivalume<=CCI_valumesell && Samebaropened1()==false && Samebaropened2()==false)
{
ticketS=OrderSend(Symbol(),OP_SELL,lot,Bid,3,0,0,"",magic,0,Red);
if(ticketS>0)
{
OrderSelect(ticketS,SELECT_BY_TICKET);
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+stoploss*Point*wei,OrderOpenPrice()-takeprofit*Point*wei,0,0);
ticksell++;
}
if(ticketS<0)
{
Print("OrderSend 失败错误 #",GetLastError());
return(0);
}
}
}

//+------------------------------------------------------------------+
void closeorder()
{
double fastma_0=iMA(NULL,0,MA_fast,0,MODE_SMA,PRICE_CLOSE,0);
double slowma_0=iMA(NULL,0,MA_slow,0,MODE_SMA,PRICE_CLOSE,0);
double ccivalume=iCCI(NULL,0,CCI_period,PRICE_CLOSE,0);
double MACD=iMACD(NULL,0,MACD_fast,MACD_slow,MACD_SMA,PRICE_CLOSE,MODE_MAIN,0);
if(CheckOrders(1)>0 && MACD>=MACD_valumebuy && ccivalume>CCI_valumebuy && fastma_0>slowma_0)
{
closeord(1);
closeord(1);
}
if(CheckOrders(0)>0 && MACD<=MACD_valumesell && ccivalume<CCI_valumesell && fastma_0<slowma_0)
{
closeord(0);
closeord(0);
}
}
//+------------------------------------------------------------------+
void closeord(int type)
{
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==type)
{
OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,0);
}
}
}

//+------------------------------------------------------------------+
bool Samebaropened1()//
{
bool currentbar=false;
datetime newtime=0;
if(OrdersTotal()>0)
{
for(int i=0;i<=OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
newtime=OrderOpenTime();
}
}
}
int openbar=iBarShift(NULL,0,newtime);
if(openbar>1)currentbar=false;
if(openbar<=1)currentbar=true;
return(currentbar);
}
//+------------------------------------------------------------------+
int CheckOrders(int type)
{
int ordercnt = 0;
for (int i = 0; i < OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() == type)
ordercnt++;
}
return (ordercnt);
}
//+------------------------------------------------------------------+
void Trailingstop() //跟踪止损
{
int ordtype=99;
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS)==true)
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
ordtype=OrderType();
if(ordtype==OP_BUY)
{
int tickbuy=OrderTicket();
if(OrderClosePrice()-OrderOpenPrice()>=trailstart*Point)
{
if(OrderStopLoss()<OrderClosePrice()-trailstop*Point)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderClosePrice()-trailstop*Point,OrderTakeProfit(),0,0);
}
}
}
if(ordtype==OP_SELL)
{
int ticksell=OrderTicket();
if(OrderOpenPrice()-OrderClosePrice()>=trailstart*Point)
{
if(OrderStopLoss()>OrderClosePrice()+trailstop*Point || OrderStopLoss()==0)
{
OrderModify(ticksell,OrderOpenPrice(),OrderClosePrice()+trailstop*Point,OrderTakeProfit(),0,0);
}
}
}
}
}
}
}

//+------------------------------------------------------------------+
bool Samebaropened2()//
{
bool currentbar=false;
datetime newclosetime=0;
if(OrdersHistoryTotal()>0)
{
for(int i=0;i<=OrdersHistoryTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
newclosetime=OrderCloseTime();
}
}
}
int openbar=iBarShift(NULL,0,newclosetime);
if(openbar>0)currentbar=false;
if(openbar==0)currentbar=true;
return(currentbar);
}

求高手指点,不胜感激!!!

 
看不懂 嘿嘿
 

好像是mt4 出问题:

https://forum.mql4.com/46046

原因: