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

【インジケーター】マルチタイム平均足

2025 5/22
MQL
2025年5月14日2025年5月22日
当ページのリンクには広告が含まれています。
//+------------------------------------------------------------------+
//|                                     MultiTimeFrameHeikenAshi.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 4
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3

input ENUM_TIMEFRAMES TimeFrame = PERIOD_H1;  // 時間足

input color ExtColor1 = Red;    // Shadow of bear candlestick
input color ExtColor2 = White;  // Shadow of bull candlestick
input color ExtColor3 = Red;    // Bear candlestick body
input color ExtColor4 = White;  // Bull candlestick body
//--- buffers
double ExtLowHighBuffer[];
double ExtHighLowBuffer[];
double ExtOpenBuffer[];
double ExtCloseBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   IndicatorShortName("Heiken Ashi");
   IndicatorDigits(Digits);
//--- indicator lines
   SetIndexStyle(0,DRAW_HISTOGRAM,0,1,ExtColor1);
   SetIndexBuffer(0,ExtLowHighBuffer);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,1,ExtColor2);
   SetIndexBuffer(1,ExtHighLowBuffer);
   SetIndexStyle(2,DRAW_HISTOGRAM,0,3,ExtColor3);
   SetIndexBuffer(2,ExtOpenBuffer);
   SetIndexStyle(3,DRAW_HISTOGRAM,0,3,ExtColor4);
   SetIndexBuffer(3,ExtCloseBuffer);
//---
   SetIndexLabel(0,"Low/High");
   SetIndexLabel(1,"High/Low");
   SetIndexLabel(2,"Open");
   SetIndexLabel(3,"Close");
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
   SetIndexDrawBegin(2,10);
   SetIndexDrawBegin(3,10);
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtLowHighBuffer);
   SetIndexBuffer(1,ExtHighLowBuffer);
   SetIndexBuffer(2,ExtOpenBuffer);
   SetIndexBuffer(3,ExtCloseBuffer);
//--- 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]);
      ExtLowHighBuffer[i] = iCustom(NULL,TimeFrame,"Heiken Ashi",ExtColor1,ExtColor2,ExtColor3,ExtColor4,0,bar);
      ExtHighLowBuffer[i] = iCustom(NULL,TimeFrame,"Heiken Ashi",ExtColor1,ExtColor2,ExtColor3,ExtColor4,1,bar);
      ExtOpenBuffer[i] = iCustom(NULL,TimeFrame,"Heiken Ashi",ExtColor1,ExtColor2,ExtColor3,ExtColor4,2,bar);
      ExtCloseBuffer[i] = iCustom(NULL,TimeFrame,"Heiken Ashi",ExtColor1,ExtColor2,ExtColor3,ExtColor4,3,bar);
   }

  return(rates_total);
}

    
MQL
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
  • XMで扱える「貴金属」の商品一覧
  • XMで扱える「コモディティ」の商品一覧

関連記事

関連する記事はまだ見つかりませんでした。

コメント

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

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

目次