本帖最后由 jy4444 于 2020-7-2 13:52 编辑
小白写的均线金叉,死叉,买入卖出的代码。为什么不运行,回测也没有。求大神指教
//--- input parameters
input int slow_line=14;
input int fast_line=7;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
double slowline=iMA(Symbol(),0,slow_line,0,MODE_EMA,PRICE_CLOSE,0);
double fastline=iMA(Symbol(),0,fast_line,0,MODE_EMA,PRICE_CLOSE,0);
double slowline1=iMA(Symbol(),0,slow_line,0,MODE_EMA,PRICE_CLOSE,0);
double fastline1=iMA(Symbol(),0,fast_line,0,MODE_EMA,PRICE_CLOSE,0);
if((fastline>slowline)&&(fastline1<slowline1))//GOLDEN CROSS
{
if(OrdersTotal()==0)
{
int ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,30,Ask-300*Point,Ask+300*Point,"buy",0,0,White);
}
}
if((fastline<slowline)&&(fastline1>slowline1))//DEATH CROSS
{
if(OrdersTotal()==0)
{
int ticket=OrderSend(Symbol(),OP_SELL,0.1,Bid,30,Bid-300*Point,Bid+300*Point,"sell",0,0,Red);
}
}
//---
}
|