
目次
パラメータ

基本的にMT4標準の入力パラメータと同じにしています。
数値以外の設定項目に関しては、リストボックスで選択可能です。
- マルチタイムフレーム
- 期間
- 表示移動
- 移動平均の種別
- 適用価格
- 色
ソースコード
//+------------------------------------------------------------------+
//| MTF-MovingAverage.mq4 |
//| Copyright 2022,Greeds Co., Ltd. |
//| https://greeds.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022,Greeds Co., Ltd."
#property link "https://greeds.net"
#property version "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
double Buf1[];
input ENUM_TIMEFRAMES in_timeFrame = PERIOD_CURRENT; // マルチタイムフレーム
input int in_period=14; // 期間
input int in_shift=0; // 表示移動
input ENUM_MA_METHOD in_method=MODE_SMA; // 移動平均の種別
input ENUM_APPLIED_PRICE in_applied_price=PRICE_CLOSE; // 適用価格
input color in_color=Red; // 色
int OnInit()
{
SetIndexBuffer(0, Buf1 );
SetIndexStyle(0, DRAW_LINE , STYLE_SOLID , 1 ,in_color);
return( INIT_SUCCEEDED );
}
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[])
{
int limit = Bars - prev_calculated;
for(int i=0; i<limit; i++)
{
int shift = iBarShift(NULL, in_timeFrame, time[i]);
double ma = iMA(NULL,in_timeFrame,in_period,in_shift,in_method,in_applied_price,shift);
Buf1[i] = ma;
}
return(rates_total);
}
ダウンロード
“MTF-MovingAverage” をダウンロード
MTF-MovingAverage.ex4 – 18 回のダウンロード – 12.21 KB