1

私はプログラミングが初めてで、コードがコンパイルされない理由とコンパイルする方法がわかりません。

MetaTrader Terminal 4 のシンプルな EA です。

問題は、変数を宣言して初期化した位置にあると思います。変数を別の関数の下に配置しようとしましたが (コード内のコメントで示されています)、それでもコードはコンパイルされず、コードが添付されています。どんな助けでも大歓迎です。

#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern double ema_red    = iMA( NULL, 0,  6, 0, MODE_EMA, PRICE_CLOSE, 0 );
extern double ema_purple = iMA( NULL, 0, 30, 0, MODE_EMA, PRICE_CLOSE, 0 );
extern double ema_blue   = iMA( NULL, 0,  8, 1, MODE_EMA, PRICE_CLOSE, 0 );

// int point;
/*
void start()
{
  double ema_red    = iMA( NULL, 0,  6, 0, MODE_EMA, PRICE_CLOSE, 0 );
  double ema_purple = iMA( NULL, 0, 30, 0, MODE_EMA, PRICE_CLOSE, 0 );
  double ema_blue   = iMA( NULL, 0,  8, 1, MODE_EMA, PRICE_CLOSE, 0 );
  return;
 }
*/
void OnTick()
{
 // double ema_red    = iMA( NULL, 0,  6, 0, MODE_EMA, PRICE_CLOSE, 0 );
 // double ema_purple = iMA( NULL, 0, 30, 0, MODE_EMA, PRICE_CLOSE, 0 );
 // double ema_blue   = iMA( NULL, 0,  8, 1, MODE_EMA, PRICE_CLOSE, 0 );
 if (OrdersTotal()<=21)
   {   
      if (ema_red == ema_purple)&&(ema_red > ema_blue) // check when the ea's cross/meet
        Buy_Order();
      if (ema_red == ema_purple)&&(ema_red < ema_blue) // check when the ea's cross/meet
        Sell_Order();                                
   }
  }
void Buy_Order()
{ 
         double TP = Ask +(PipsToPointFactor()*15);
         double SL = (MarketInfo(Symbol(),MODE_TICKVALUE)) - (PipsToPointFactor()*5);
         OrderSend(Symbol(),OP_BUY,0.6,Ask,(3*PipsToPointFactor()),SL,TP,"",0,0,Green);  
  }
void Sell_Order()
{  
         double TP = (Bid - (15*PipsToPointFactor()));
         double SL = ((MarketInfo(Symbol(),MODE_TICKVALUE)) + (PipsToPointFactor()*5 );
         OrderSend(Symbol(),OP_SELL,0.6,Bid,(3*PipsToPointFactor()),SL,TP,"",0,0,Red); 
  }
int OnInit()
{
    return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
{  
  }
int PipsToPointFactor()              // NOT MY OWN FUNCTION, takes care of pips to points issue
{
   int point;
   if(Digits==5 || Digits==3)        // Check whether it's a 5 digit broker ( 3 digits for Yen )
   point=10;                         // 1 pip to 10 point if 5 digit
   else if(Digits==4 || Digits==2)
   point=1;                          // 1 pip to 1 point if 4 digit
   return(point);
  }
4

3 に答える 3