MT5请教如何获取布林线上中下轨的指定柱线指标值

 
MT4里利用iBands()可以获取上中下轨指定柱线的指标值,但MT5里的iBands()没有了上中下轨的参数,请教如何获取MT5布林线上中下轨的指定柱线指标值,比如获取当前或最近第二个柱线对应的指标值,希望有人帮着解答,谢谢!
 

用copybuffer():

 0 - BASE_LINE, 1 - UPPER_BAND, 2 - LOWER_BAND

参见:https://www.mql5.com/en/docs/indicators/ibands

Documentation on MQL5: Technical Indicators / iBands
Documentation on MQL5: Technical Indicators / iBands
  • www.mql5.com
Technical Indicators / iBands - Reference on algorithmic/automated trading language for MetaTrader 5
 
enbo lu #:

用copybuffer():

 0 - BASE_LINE, 1 - UPPER_BAND, 2 - LOWER_BAND

参见:https://www.mql5.com/en/docs/indicators/ibands

还是不明白。请举例说明。谢谢!

 

供参考:

//+------------------------------------------------------------------+
//|                                                  test_iBands.mq5 |
//|                                           Copyright 2021,fxMeter |
//|                           https://www.mql5.com/zh/users/fxmeters |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021,fxMeter"
#property link      "https://www.mql5.com/zh/users/fxmeters"
#property version   "1.00"

input   int                 bands_period = 20;              // period for average line calculation
input   double              deviation = 2.0;                // number of standard deviations
input   ENUM_APPLIED_PRICE  applied_price = PRICE_CLOSE;    // type of price 

int handle = -1;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
//---
   handle = iBands(Symbol(),PERIOD_CURRENT,bands_period,0,deviation,applied_price);
   if(handle == -1)
   {
      return(INIT_FAILED);
   }

//---
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---

}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
//---

   //1.获取最近3个K线的布林线上轨
   double upper[];
   ArraySetAsSeries(upper,true);
   if(CopyBuffer(handle,UPPER_BAND,0,3,upper) == 3)
   {

   }

   //2.获取最近3个K线的布林线下轨
   double lower[];
   ArraySetAsSeries(lower,true);
   if(CopyBuffer(handle,LOWER_BAND,0,3,lower) == 3)
   {

   }

}
//+------------------------------------------------------------------+
 
Ziheng Zhuang #:

供参考:


谢谢,终于能正常调用BOLL函数的值。

原因: