//+------------------------------------------------------------------+
//| MTF_ZigZag.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 1
#property indicator_color1 Red
//---- indicator parameters
input ENUM_TIMEFRAMES TimeFrame = PERIOD_D1; // 時間足
input int InpDepth=12; // Depth
input int InpDeviation=5; // Deviation
input int InpBackstep=3; // Backstep
//---- indicator buffers
double ExtZigZagBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexStyle(0,DRAW_SECTION);
SetIndexBuffer(0,ExtZigZagBuffer);
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 = rates_total - 1;
for (int i = limit; i >= 0; i--) {
int bar = iBarShift(NULL, TimeFrame, Time[i], false);
if (bar == -1) continue;
double zig = iCustom(NULL, TimeFrame, "ZigZag", InpDepth, InpDeviation, InpBackstep, 0, bar);
if (zig != 0.0) {
ExtZigZagBuffer[i] = zig;
}
}
return(rates_total);
}
【MQL】MTF-ZigZag
当ページのリンクには広告が含まれています。

コメント