T3 Tillson MA
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «t3 tillson ma.mq5» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
Индикатор T3 Tillson MA рассчитывает скользящую среднюю T3 (Triple Exponential) по методике Тилсона и отображает её на графике цены в MetaTrader 5. Линия индикатора окрашивается в зелёный при восходящем тренде и в красный при нисходящем, что позволяет визуально оценивать направление движения рынка.
Расчёт основан на каскаде из шести экспоненциальных скользящих средних с последующим применением коэффициентов, определяемых параметром объёма. Индикатор поддерживает множество типов цен, включая варианты Хейкин Аси, что расширяет возможности анализа.
Индикатор использует три буфера для отрисовки: два линейных (зелёный и красный) и один для хранения направления наклона. Перед началом расчёта выполняется предварительное заполнение данных для обеспечения стабильности вычислений.
Настройки программы
| Настройка | Описание |
|---|---|
| MA_Period | Период расчёта скользящей средней T3. Определяет количество баров, используемых для стабилизации и вычисления индикатора. |
| b | Параметр объёма (volume factor) для расчёта коэффициентов T3. Влияет на степень сглаживания и отзывчивости индикатора. |
| T3Original | Переключатель между оригинальной формулой T3 и модифицированной версией. При значении true используется классический расчёт, при false — скорректированный параметр периода. |
| inpPrice | Тип цены, используемый для расчёта индикатора. Доступны варианты: Close, Open, High, Low, Median, Typical, Weighted, Average, а также различные варианты Хейкин Аси. |
Поиск по коду файла
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 clrGreen
#property indicator_color2 clrRed
#property indicator_width1 2 // Matched to SetIndexStyle
#property indicator_width2 2 // Matched to SetIndexStyle
enum ENUM_PRICE_TYPE {
PRICE_CHIUSURA, // Close
PRICE_APERTURA, // Open
PRICE_MAX, // High
PRICE_MIN, // Low
PRICE_MEDIO, // Median
PRICE_TIPICO, // Typical
PRICE_PESATO, // Weighted
PRICE_AVERAGE, // Average (high+low+open+close)/4
PRICE_MEDIANBODY, // Average median body (open+close)/2
PRICE_TRENDBIASED, // Trend biased price
PRICE_TRENDBIASEDEXT,// Trend biased (extreme) price
PRICE_HACLOSE, // Heiken ashi close
PRICE_HAOPEN, // Heiken ashi open
PRICE_HAHIGH, // Heiken ashi high
PRICE_HALOW, // Heiken ashi low
PRICE_HAMEDIAN, // Heiken ashi median
PRICE_HATYPICAL, // Heiken ashi typical
PRICE_HAWEIGHTED, // Heiken ashi weighted
PRICE_HAAVERAGE, // Heiken ashi average
PRICE_HAMEDIANB, // Heiken ashi median body
PRICE_HATBIASED, // Heiken ashi trend biased
PRICE_HATBIASED2, // Heiken ashi trend biased (extreme) price
PRICE_HABCLOSE, // Heiken ashi (better formula) close
PRICE_HABOPEN, // Heiken ashi (better formula) open
PRICE_HABHIGH, // Heiken ashi (better formula) high
PRICE_HABLOW, // Heiken ashi (better formula) low
PRICE_HABMEDIAN, // Heiken ashi (better formula) median
PRICE_HABTYPICAL, // Heiken ashi (better formula) typical
PRICE_HABWEIGHTED, // Heiken ashi (better formula) weighted
PRICE_HABAVERAGE, // Heiken ashi (better formula) average
PRICE_HABMEDIANB, // Heiken ashi (better formula) median body
PRICE_HABTBIASED, // Heiken ashi (better formula) trend biased
PRICE_HABTBIASED2 // Heiken ashi (better formula) trend biased (extreme) price
};
extern int MA_Period = 15;
extern double b = 0.7;
extern bool T3Original = true;
extern ENUM_PRICE_TYPE inpPrice = PRICE_TIPICO;
double MapBufferGreen[];
double MapBufferRed[];
double Slope[]; // Stores the slope direction: 1 for up, -1 for down
#define _priceInstances 1
#define _priceInstancesSize 4
double workHa[][_priceInstances*_priceInstancesSize]; // For Heiken Ashi calculations
double e1[], e2[], e3[], e4[], e5[], e6[]; // T3 calculation arrays
double c1, c2, c3, c4;
double n_param, w1, w2, b2, b3; // Renamed 'n' to 'n_param' to avoid conflict
int OnInit() // Changed from init() to OnInit() for modern MQL4
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2, clrGreen);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2, clrRed);
IndicatorDigits(Digits()); // Use Digits() instead of MarketInfo for simplicity
IndicatorShortName("T3_Tillson_MA_Cont"); // Added _Cont for continuous
int draw_begin_offset = MA_Period * 6; // Heuristic for T3 stabilization
if (draw_begin_offset < 20) draw_begin_offset = 20; // Minimum offset
SetIndexDrawBegin(0, draw_begin_offset);
SetIndexDrawBegin(1, draw_begin_offset);
SetIndexBuffer(0, MapBufferGreen);
SetIndexBuffer(1, MapBufferRed);
SetIndexBuffer(2, Slope);
SetIndexLabel(0, "T3 MA Green");
SetIndexLabel(1, "T3 MA Red");
ArrayInitialize(Slope, 0);
b2 = b * b;
b3 = b2 * b;
c1 = -b3;
c2 = (3 * (b2 + b3));
c3 = -3 * (2 * b2 + b + b3);
c4 = (1 + 3 * b + b3 + 3 * b2);
if (T3Original)
{
n_param = MA_Period;
if (n_param < 1) n_param = 1;
w1 = 2.0 / (n_param + 1.0);
}
else
{
n_param = 1 + 0.5 * (MA_Period - 1);
if (n_param < 1) n_param = 1;
w1 = 2.0 / (n_param + 1.0);
}
w2 = 1 - w1;
return(INIT_SUCCEEDED);
}
int OnDeinit(const int reason) // Changed from deinit() to OnDeinit()
{
ArrayFree(e1);
ArrayFree(e2);
ArrayFree(e3);
ArrayFree(e4);
ArrayFree(e5);
ArrayFree(e6);
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[])
{
// код доступен только после оплаты
}
if (rates_total < MA_Period * 6 + 5) // Ensure enough data for T3 stabilization
return (0);
if (ArraySize(e1) < rates_total + 1) {
ArrayResize(e1, rates_total + 1); ArrayResize(e2, rates_total + 1);
ArrayResize(e3, rates_total + 1); ArrayResize(e4, rates_total + 1);
ArrayResize(e5, rates_total + 1); ArrayResize(e6, rates_total + 1);
}
int start_bar_loop_idx; // This is the bar index on the chart (0 = current, rates_total-1 = oldest)
if (prev_calculated == 0)
{
start_bar_loop_idx = rates_total - 1 - (MA_Period * 6); // Start far enough back for stabilization
if (start_bar_loop_idx < 0) start_bar_loop_idx = 0;
if (start_bar_loop_idx < rates_total -1) { // Check if there is a bar before start_bar_loop_idx
double seed_price = getPrice(inpPrice, open, close, high, low, start_bar_loop_idx + 1, rates_total);
int seed_eN_array_idx = rates_total - (start_bar_loop_idx + 1); // This is the eN index for the bar *before* our loop starts
if (seed_eN_array_idx > 0 && seed_eN_array_idx <= rates_total) { // Bounds check
e1[seed_eN_array_idx] = seed_price; e2[seed_eN_array_idx] = seed_price; e3[seed_eN_array_idx] = seed_price;
e4[seed_eN_array_idx] = seed_price; e5[seed_eN_array_idx] = seed_price; e6[seed_eN_array_idx] = seed_price;
} else if (rates_total > 0) { // Fallback seed with oldest price if indexing is tricky
double oldest_price = getPrice(inpPrice, open, close, high, low, rates_total - 1, rates_total);
for(int k_seed = 0; k_seed <= rates_total; k_seed++) { // Initialize all eN to oldest price as a robust seed
e1[k_seed] = oldest_price; e2[k_seed] = oldest_price; e3[k_seed] = oldest_price;
e4[k_seed] = oldest_price; e5[k_seed] = oldest_price; e6[k_seed] = oldest_price;
}
}
} else if (rates_total > 0) { // If start_bar_loop_idx is rates_total-1 (oldest bar)
double first_price = getPrice(inpPrice, open, close, high, low, rates_total-1, rates_total);
e1[0] = first_price; e2[0] = first_price; e3[0] = first_price;
e4[0] = first_price; e5[0] = first_price; e6[0] = first_price;
}
}
else
{
start_bar_loop_idx = rates_total - prev_calculated;
if (start_bar_loop_idx > 0) start_bar_loop_idx +=2; // Recalculate 2 more bars
else start_bar_loop_idx = 2; // If only new bars, still calc a bit
if (start_bar_loop_idx >= rates_total) start_bar_loop_idx = rates_total - 1;
if (start_bar_loop_idx < 0) start_bar_loop_idx = 0;
}
for (int i = start_bar_loop_idx; i >= 0; i--)
{
double price = getPrice(inpPrice, open, close, high, low, i, rates_total);
int eN_current_idx = rates_total - i;
int eN_prev_idx = eN_current_idx - 1;
if (eN_prev_idПоказано первые 50% кода (символов: 10513)