MT4 做指标模版

时间:2021-05-05 21:51:26
//+------------------------------------------------------------------+
//| guo.mq4 |
//| Copyright 2015, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_separate_window #property indicator_buffers
#property indicator_color1 Red
#property indicator_width1
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
double ExtSignalBuffer[];
int OnInit()
{
//--- indicator buffers mapping
SetIndexStyle(,DRAW_LINE);
SetIndexBuffer(,ExtSignalBuffer);
SetIndexLabel(,"guo");
//---
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[])
{
//--- //--- return value of prev_calculated for next call
int i,limit;
//--- //--- last counted bar will be recounted
limit=rates_total-prev_calculated;
if(prev_calculated>)
limit++;
//--- macd counted in the 1-st buffer
for(i=; i<limit; i++)
ExtSignalBuffer[i]=close[i];
//--- signal line counted in the 2-nd buffer return(rates_total);
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//--- }
//+------------------------------------------------------------------+