MENU
  • FX・CFD必要証拠金計算ツール(ハイレバ対応)
  • FX複利計算シミュレーター
  • 余力に応じたロット計算ツール
  • お問い合わせ
FX取引に関するあれこれ
  • FX・CFD必要証拠金計算ツール(ハイレバ対応)
  • FX複利計算シミュレーター
  • 余力に応じたロット計算ツール
  • お問い合わせ
  1. ホーム
  2. MQL
  3. 【MT4インジケーター】マルチタイムボリンジャーバンド

【MT4インジケーター】マルチタイムボリンジャーバンド

2025 6/02
MQL
2025年6月2日
当ページのリンクには広告が含まれています。
//+------------------------------------------------------------------+
//|                                                    MTF_Bands.mq4 |
//|                                  Copyright 2025, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 LightSeaGreen
#property indicator_color3 LightSeaGreen
//--- indicator parameters
input ENUM_TIMEFRAMES TimeFrame = PERIOD_D1;  // 時間足
input int    InpBandsPeriod=20;      // Bands Period
input int    InpBandsShift=0;        // Bands Shift
input double InpBandsDeviations=2.0; // Bands Deviations
//--- buffers
double ExtMovingBuffer[];
double ExtUpperBuffer[];
double ExtLowerBuffer[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
//--- 1 additional buffer used for counting.
   IndicatorBuffers(3);
   IndicatorDigits(Digits);
//--- middle line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMovingBuffer);
   SetIndexShift(0,InpBandsShift);
   SetIndexLabel(0,"Bands SMA");
//--- upper band
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtUpperBuffer);
   SetIndexShift(1,InpBandsShift);
   SetIndexLabel(1,"Bands Upper");
//--- lower band
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtLowerBuffer);
   SetIndexShift(2,InpBandsShift);
   SetIndexLabel(2,"Bands Lower");

//--- check for input parameter
   if(InpBandsPeriod<=0)
     {
      Print("Wrong input parameter Bands Period=",InpBandsPeriod);
      return(INIT_FAILED);
     }
//---
   SetIndexDrawBegin(0,InpBandsPeriod+InpBandsShift);
   SetIndexDrawBegin(1,InpBandsPeriod+InpBandsShift);
   SetIndexDrawBegin(2,InpBandsPeriod+InpBandsShift);
//--- initialization done
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
//---
   if (_Period > TimeFrame && TimeFrame != PERIOD_CURRENT) return -1;

   int limit = Bars - IndicatorCounted() - 1;
   int min = PeriodSeconds(TimeFrame) / PeriodSeconds();
   if (limit < min) limit = min;

   for (int i = limit; i >= 0; i--) {
      int bar = iBarShift(NULL, TimeFrame, Time[i]);
      ExtUpperBuffer[i] = iBands(NULL,TimeFrame,InpBandsPeriod,InpBandsDeviations,InpBandsShift,PRICE_CLOSE,MODE_UPPER,bar);
      ExtMovingBuffer[i] = iBands(NULL,TimeFrame,InpBandsPeriod,InpBandsDeviations,InpBandsShift,PRICE_CLOSE,MODE_MAIN,bar);
      ExtLowerBuffer[i] = iBands(NULL,TimeFrame,InpBandsPeriod,InpBandsDeviations,InpBandsShift,PRICE_CLOSE,MODE_LOWER,bar);

   }

  return(rates_total);
}
MQL
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
  • 証拠金計算ツールの計算式
  • ボリンジャーバンドの「長所」と「短所」、そして実践的なトレード手法2選!

関連記事

  • 【MT4インジケーター】マルチタイムADX
    2025年6月2日
  • 【MT4インジケーター】マルチタイム平均足
    2025年5月14日

コメント

コメントする コメントをキャンセル

新着記事
  • FXで負けている人がやっていること【10選】
    2025年6月6日
    FXの基礎
人気記事
  • ボリンジャーバンドの「長所」と「短所」、そして実践的なトレード手法2選!
    2025年6月2日
    FXの基礎 3
  • 【MT4インジケーター】マルチタイムADX
    2025年6月2日
    MQL 3
  • 証拠金計算ツールの計算式
    2025年5月29日
    証拠金計算ツール 3
スポンサーリンク

\ すぐ始められる!/

XMでトレードする
目次

© FX取引に関するあれこれ.

目次