masi_macdhist.mq5
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «masi_macdhist.mq5» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
Индикатор рассчитывает и отображает аналитические линии MACD, сигнальную линию и гистограмму в отдельном окне графика. Поддерживает индивидуальные режимы отображения каждой линии и гистограммы через настраиваемые переключатели.
Включает функцию обнаружения дивергенций — бычьих и медвежьих — на основе гистограммы и линии MACD. Поддерживает три типа дивергенций: классическую, скрытую и расширенную. Результаты отображаются стрелками на графике.
Предусмотрена отрисовка трендовых линий, связывающих точки дивергенций, а также система уведомлений о событиях. При деактивации индикатор автоматически удаляет созданные на графике объекты.
Настройки программы
| Настройка | Описание |
|---|---|
| Fast EMA Period (FastEMA) | Быстрая EMA — Период быстрой экспоненциальной скользящей средней |
| Slow EMA Period (SlowEMA) | Медленная EMA — Период медленной экспоненциальной скользящей средней |
| Signal SMA Period (SignalEMA) | Период сигнальной SMA — Период сигнальной простой скользящей средней |
| MACD line (ON_MACD) | Линия MACD — Отображение линии MACD |
| Signal line (ON_SIGNAL) | Сигнальная линия — Отображение сигнальной линии |
| ========================== (SECTION1) | Разделитель — Текстовый разделитель параметров дивергенций |
| MACD Histogram divergence indicator (ON_DIVER_HIST) | Дивергенция гистограммы — Индикатор дивергенции гистограммы MACD |
| MACD Line divergence indicator (ON_DIVER_LINE) | Дивергенция линии — Индикатор дивергенции линии MACD |
| Search classical (ON_CLASSIC) | Классическая — Поиск классической дивергенции |
| Search hidden (ON_HIDDEN) | Скрытая — Поиск скрытой дивергенции |
| Search extended (ON_EXPAND) | Расширенная — Поиск расширенной дивергенции |
| Show trend lines (ON_TREND_LINES) | Трендовые линии — Отображение трендовых линий |
| Show divergence indicator (ON_DIVER_SYMBOL) | Символ дивергенции — Отображение индикатора дивергенции |
| Show alerts (ON_ALERT) | Уведомления — Показ уведомлений |
Поиск по коду файла
#property description "Moving Averages Convergence/Divergence."
#property description "MACD line + Signal line + Histogram."
#property description "Divergence indicator."
#property version "1.6"
#property strict
#include <MovingAverages.mqh>
#property indicator_separate_window
#property indicator_buffers 9
#property indicator_plots 9
#property indicator_label1 "MACD"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrLightSeaGreen
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
#property indicator_label2 "Signal"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrChocolate
#property indicator_style2 STYLE_DOT
#property indicator_width2 1
#property indicator_label3 "MACD Histogram"
#property indicator_type3 DRAW_HISTOGRAM
#property indicator_label4 "Histogram"
#property indicator_type4 DRAW_HISTOGRAM
#property indicator_color4 clrGreen
#property indicator_style4 STYLE_SOLID
#property indicator_width4 2
#property indicator_label5 "Histogram"
#property indicator_type5 DRAW_HISTOGRAM
#property indicator_color5 C'0,90,0'
#property indicator_style5 STYLE_SOLID
#property indicator_width5 2
#property indicator_label6 "Histogram"
#property indicator_type6 DRAW_HISTOGRAM
#property indicator_color6 clrRed
#property indicator_style6 STYLE_SOLID
#property indicator_width6 2
#property indicator_label7 "Histogram"
#property indicator_type7 DRAW_HISTOGRAM
#property indicator_color7 C'142,0,0'
#property indicator_style7 STYLE_SOLID
#property indicator_width7 2
#property indicator_label8 "Bull Divergence"
#property indicator_type8 DRAW_ARROW
#property indicator_color8 clrGreen
#property indicator_width8 1
#property indicator_label9 "Bear Divergence"
#property indicator_type9 DRAW_ARROW
#property indicator_color9 clrRed
#property indicator_width9 1
double MacdBuffer[];
double SignalBuffer[];
double MacdHistBuffer[];
double HistGUBuffer[], HistGDBuffer[];
double HistRDBuffer[], HistRUBuffer[];
double BullDivBuffer[], BearDivBuffer[];
input int FastEMA = 12; // Fast EMA Period
input int SlowEMA = 26; // Slow EMA Period
input int SignalEMA = 9; // Signal SMA Period
input bool ON_MACD = true; // MACD line
input bool ON_SIGNAL = true; // Signal line
input string SECTION1 = "===== Divergence parameters =====";//==========================
input bool ON_DIVER_HIST = false; // MACD Histogram divergence indicator
input bool ON_DIVER_LINE = false; // MACD Line divergence indicator
input bool ON_CLASSIC = true; // Search classical
input bool ON_HIDDEN = true; // Search hidden
input bool ON_EXPAND = true; // Search extended
input bool ON_TREND_LINES = true; // Show trend lines
input bool ON_DIVER_SYMBOL = true; // Show divergence indicator
input bool ON_ALERT = true; // Show alerts
const int SEARCH_LEN = 120; // Lenght of peacks search
const int SEARCH_LEN_Z = 90; // Lenght of zero check
string prefix = "MASi_MACDHist";
string indicatorName;
int OnInit()
{
// код доступен только после оплаты
}
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[])
{
// код доступен только после оплаты
}
void OnDeinit(const int)
{
string label;
for( int i = ObjectsTotal()-1; i >= 0; i-- ) {
label = ObjectName(i);
if( StringFind( label, prefix ) >= 0 ) {
ObjectDelete( label );
}
}
}
void OnChartEvent(const int id, const long& lparam,
const double& dparam, const string& sparam)
{
}
void CatchBullishDivergence(const int bar, const double &array[],
double &divArray[], const bool zeroLine = false)
{
int troughIdx0 = bar;
if( !IsTrough( troughIdx0, array, zeroLine ) ) {
return;
}
int troughIdx1 = LastTroughIndex( troughIdx0, array, zeroLine );
if( troughIdx1 < 0 ) {
return;
}
int winID = WindowFind( indicatorName );
int lowIdx0 = ArrayMinValueIndex( Low, bar > 0 ? troughIdx0-1 : 0, 3 );
int lowIdx1 = ArrayMinValueIndex( Low, troughIdx1-1, 3 );
if( lowIdx0 < 0 || lowIdx1 < 0 ) {
return;
}
if( ON_CLASSIC ) {
if( array[troughIdx1] < array[troughIdx0] ) {
if( Low[lowIdx1] > Low[lowIdx0] ) {
divArray[troughIdx0] = array[troughIdx0];
if( ON_TREND_LINES ) {
DrawTrendLine( Time[lowIdx0], Time[lowIdx1], Low[lowIdx0], Low[lowIdx1], Green, STYLE_SOLID );
DrawTrendLine( Time[troughIdx0], Time[troughIdx1], array[troughIdx0], array[troughIdx1], Green, STYLE_SOLID, winID );
}
if( ON_ALERT ) {
if( bar <= 3 ) {
DisplayAlert( troughIdx0, "Classical bullish divergence on" );
}
}
}
}
}
if( ON_HIDDEN ) {
if( array[troughIdx1] > array[troughIdx0] ) {
if( Low[lowIdx1] < Low[lowIdx0] ) {
divArray[troughIdx0] = array[troughIdx0];
if( ON_TREND_LINES ) {
DrawTrendLine( Time[lowIdx0], Time[lowIdx1], Low[lowIdx0], Low[lowIdx1], Green, STYLE_DOT );
DrawTrendLine( Time[troughIdx0], Time[troughIdx1], array[troughIdx0], array[troughIdx1], Green, STYLE_DOT, winID );
}
if( ON_ALERT ) {
if( bar <= 3 ) {
DisplayAlert( troughIdx0, "Hidden bullish divergence on" );
}
}
}
}
}
if( ON_EXPAND ) {
double delta = Показано первые 50% кода (символов: 11817)
Открыть по тарифу
Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.
Разовая покупка файла
На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.
Зачем нужен email? После подтверждения оплаты файл сохранится в кабинете на этот email. Если аккаунта ещё нет, мы создадим его и пришлём ссылку для задания пароля. Если аккаунт уже есть, покупка добавится в него. Укажите адрес, к которому у вас есть доступ.
Чтобы оформить заказ, введите email и перейдите к оплате.