//+------------------------------------------------------------------+
//| MTF_ADX.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_separate_window
#property indicator_level1 20
#property indicator_buffers 3
#property indicator_color1 LightSeaGreen
#property indicator_color2 YellowGreen
#property indicator_color3 Wheat
/*
double iADX(
string symbol, // 通貨ペア
int timeframe, // 時間軸
int period, // 平均期間
int applied_price, // 適用価格
int mode, // ラインインデックス
int shift // シフト
);
*/
//--- indicator parameters
input ENUM_TIMEFRAMES TimeFrame = PERIOD_D1; //時間足
input int InPeriod=20;
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_DOT,1);
SetIndexStyle(2,DRAW_LINE,STYLE_DOT,1);
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]);
ExtMapBuffer1[i]=iADX(NULL,TimeFrame,InPeriod,PRICE_HIGH,MODE_MAIN,bar) ;
ExtMapBuffer2[i]=iADX(NULL,TimeFrame,InPeriod,PRICE_HIGH,MODE_PLUSDI,bar) ;
ExtMapBuffer3[i]=iADX(NULL,TimeFrame,InPeriod,PRICE_HIGH,MODE_MINUSDI,bar) ;
}
return(rates_total);
}
【MT4インジケーター】マルチタイムADX
当ページのリンクには広告が含まれています。

コメント