Исходный код · ID 4933
macd_histogram_mc.mq5
Вы автор или правообладатель?
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «macd_histogram_mc.mq5» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
Краткий обзор
О программе
MACD Histogram MC — это пользовательский индикатор для MetaTrader 5, рассчитывающий классический индикатор MACD (Moving Average Convergence/Divergence) с отображением гистограммы. Индикатор строится на основе двух экспоненциальных скользящих средних (быстрой и медленной), разность между которыми формирует линию MACD, а сигнальная линия рассчитывается отдельной скользящей средней.
Настройки программы
| Настройка | Описание |
|---|---|
| InpFastEMA | Период быстрой экспоненциальной скользящей средней (EMA) |
| InpSlowEMA | Период медленной экспоненциальной скользящей средней (EMA) |
| InpSignalMA | Период сигнальной скользящей средней, применяемой к линии MACD |
| InpAppliedSignalMA | Метод скользящей средней, используемый для расчёта сигнальной линии (SMA, EMA, SMMA или LWMA) |
| InpUseMultiColor | Переключатель отображения гистограммы: многоцветный режим (цвет меняется в зависимости от направления изменения) или одноцветный режим |
| InpAppliedPrice | Применяемая цена для расчёта скользящих средних (например, закрытие, открытие, высокая, низкая и т.д.) |
Поиск по коду файла
#property description "Moving Average Convergence/Divergence, Histogram, Multi-color"
/*--------------------------------------------------------------------
2010 10 20: v04 Fixed bug with the colors of the histogram
2010 09 26: v03 Added MODE_SMMA and MODE_LWMA as MA methods for Signal line
Made ENUM_APPLIED_PRICE to the end of the input parameter list
----------------------------------------------------------------------*/
#include <MovingAverages.mqh>
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_plots 3
#property indicator_type1 DRAW_LINE
#property indicator_type2 DRAW_LINE
#property indicator_type3 DRAW_COLOR_HISTOGRAM
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green,Red,Blue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_label1 "MACD"
#property indicator_label2 "Signal"
#property indicator_label3 "Histogram"
enum colorswitch // use single or multi-color display of Histogram
{
MultiColor=0,
SingleColor=1
};
input int InpFastEMA=12; // Fast EMA period
input int InpSlowEMA=26; // Slow EMA period
input int InpSignalMA=9; // Signal MA period
input ENUM_MA_METHOD InpAppliedSignalMA=MODE_SMA; // Applied MA method for signal line
input colorswitch InpUseMultiColor=MultiColor; // Use multi-color or single-color histogram
input ENUM_APPLIED_PRICE InpAppliedPrice=PRICE_CLOSE; // Applied price
double ExtMacdBuffer[];
double ExtSignalBuffer[];
double ExtHistogramBuffer[];
double ExtHistogramColorBuffer[];
double ExtFastMaBuffer[];
double ExtSlowMaBuffer[];
int weightsum_global; // used for calculation of LWMA
int ExtFastMaHandle;
int ExtSlowMaHandle;
bool ShowErrorMessages=true; // turn on/off error messages for debugging
void OnInit()
{
// код доступен только после оплаты
}
SetIndexBuffer(0,ExtMacdBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ExtSignalBuffer,INDICATOR_DATA);
SetIndexBuffer(2,ExtHistogramBuffer,INDICATOR_DATA);
SetIndexBuffer(3,ExtHistogramColorBuffer,INDICATOR_COLOR_INDEX);
SetIndexBuffer(4,ExtFastMaBuffer,INDICATOR_CALCULATIONS);
SetIndexBuffer(5,ExtSlowMaBuffer,INDICATOR_CALCULATIONS);
ArraySetAsSeries(ExtMacdBuffer,true);
ArraySetAsSeries(ExtSignalBuffer,true);
ArraySetAsSeries(ExtHistogramBuffer,true);
ArraySetAsSeries(ExtHistogramColorBuffer,true);
ArraySetAsSeries(ExtFastMaBuffer,true);
ArraySetAsSeries(ExtSlowMaBuffer,true);
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpSlowEMA-1);
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpSlowEMA+InpSignalMA-1);
PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpSlowEMA+InpSignalMA-1);
IndicatorSetString(INDICATOR_SHORTNAME,"MACD("+string(InpFastEMA)+","+string(InpSlowEMA)+","+string(InpSignПоказано первые 50% кода (символов: 4966)