DislikedHow to filter, motherfucker. Signals are generated on a completed bar. Yes, I always knew that WPR had great potential. The main thing is in the cook, who cooks it and how. {image}Ignored
could you share the indi ? thanks
1
Will code your crazy ideas 40 replies
Help - any tools that can easily convert MQL4 code to Easy Language code? 7 replies
MQL4 Language Most Recent Version is it updated beyond the tutorial on the mql4 websi 6 replies
//+------------------------------------------------------------------+
//| Atr_Percent-Shargyn.mq4 |
//| Copyright 2025, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_separate_window
//--- Используем два буфера:
// Первый буфер - основная линия, рассчитываемая по динамическому ATR%
// Второй буфер - сдвинутая на один бар версия основной линии
#property indicator_buffers 2
//--- Настройки первой линии (динамический ATR%)
#property indicator_color1 clrBlue
#property indicator_width1 2
#property indicator_label1 "Dynamic_ATR_Percent"
//--- Настройки второй линии (смещённая на 1 бар)
#property indicator_color2 clrRed
#property indicator_width2 2
#property indicator_label2 "Shifted"
//--- Настройка уровня линии 0
#property indicator_level1 0
#property indicator_levelcolor clrBlue
#property indicator_levelstyle 2
//--- Входные параметры для динамического ATR
input int BasePeriodAtr = 3; // Базовый период для ATR
input int VolatilityLookback = 14; // Период для расчёта среднего диапазона (High-Low)
input double ThresholdHigh = 0.002; // Порог высокой волатильности (единицы цены)
input double ThresholdLow = 0.001; // Порог низкой волатильности (единицы цены)
input int ExtraBars = 2; // Дополнительное увеличение периода при высокой волатильности
input int ReduceBars = 1; // Снижение периода при низкой волатильности
//--- Объявляем буферы для расчёта линий
double DynamicATRBuffer[]; // Буфер для основной линии (ATR%)
double ShiftedBuffer[]; // Буфер для второй линии (сдвинутая на 1 бар)
//--- Статическая переменная для скользящей суммы диапазонов (High - Low)
// Она используется для вычисления среднего диапазона за VolatilityLookback баров
static double currentSumRange = 0.0;
//+------------------------------------------------------------------+
//| Функция инициализации индикатора |
//+------------------------------------------------------------------+
int OnInit()
{
// Выделяем два буфера для индикатора
IndicatorBuffers(2);
// Настраиваем первую линию: рисуем линию и связываем с буфером DynamicATRBuffer
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, DynamicATRBuffer);
// Настраиваем вторую линию: рисуем линию и связываем с буфером ShiftedBuffer
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, ShiftedBuffer);
// Возвращаем статус успешной инициализации
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 < VolatilityLookback + 1)
return(0);
// Определяем граничное значение, чтобы окно суммирования (баров для VolatilityLookback)
// полностью укладывалось в исторических данных
int limit = rates_total - VolatilityLookback - 1;
// Пересчитываем скользящую сумму для первого обрабатываемого бара
// Суммируем разности (high - low) для баров с индексами от 1 до VolatilityLookback
currentSumRange = 0.0;
for(int j = 1; j <= VolatilityLookback && j < rates_total; j++)
currentSumRange += ( high[j] - low[j] );
// Основной цикл расчёта по всем барам от 0 до limit
for(int i = 0; i < limit; i++)
{
// 1. Вычисляем средний диапазон за VolatilityLookback баров,
// начиная с бара с индексом i+1
double avgRange = currentSumRange / VolatilityLookback;
// 2. Определяем динамический период ATR:
// Начинаем с базового периода BasePeriodAtr и корректируем его
// в зависимости от того, насколько avgRange выше порога ThresholdHigh
// или ниже порога ThresholdLow.
int dynamicPeriod = BasePeriodAtr;
if(avgRange > ThresholdHigh)
dynamicPeriod = BasePeriodAtr + ExtraBars;
else if(avgRange < ThresholdLow)
dynamicPeriod = BasePeriodAtr - ReduceBars;
if(dynamicPeriod < 1)
dynamicPeriod = 1;
// 3. Вычисляем ATR с динамическим периодом для текущего бара i
// Функция iATR возвращает значение ATR для заданного периода и бара
double atrValue = iATR(_Symbol, PERIOD_CURRENT, dynamicPeriod, i);
// 4. Рассчитываем процентное отклонение ATR от среднего диапазона:
// ((atrValue / avgRange) - 1) * 100
double percentDeviation = 0.0;
if(avgRange != 0)
percentDeviation = ((atrValue / avgRange) - 1) * 100;
// Сохраняем вычисленное значение в буфер основной линии
DynamicATRBuffer[i] = percentDeviation;
// 5. Формируем вторую линию как значение предыдущего бара основной линии.
// Если i > 0, тогда берем значение из DynamicATRBuffer[i-1], иначе – текущее значение.
if(i > 0)
ShiftedBuffer[i] = DynamicATRBuffer[i-1];
else
ShiftedBuffer[i] = DynamicATRBuffer[i];
// 6. Обновляем скользящую сумму для следующего бара:
// - Вычитаем диапазон бара с индексом i+1
// - Прибавляем диапазон бара с индексом i+VolatilityLookback+1 (если он доступен)
if(i < limit - 1)
{
int removeIndex = i + 1;
int addIndex = i + VolatilityLookback + 1;
if(addIndex < rates_total)
{
currentSumRange = currentSumRange - (high[removeIndex] - low[removeIndex])
+ (high[addIndex] - low[addIndex]);
}
}
}
// Возвращаем общее количество баров, обработанных индикатором
return(rates_total);
}
//+------------------------------------------------------------------+ DislikedHow to filter, motherfucker. Signals are generated on a completed bar. Yes, I always knew that WPR had great potential. The main thing is in the cook, who cooks it and how. {image}Ignored
DislikedHow to filter, motherfucker. Signals are generated on a completed bar. Yes, I always knew that WPR had great potential. The main thing is in the cook, who cooks it and how. {image}Ignored
DislikedNew indicator development, for which I am developing an indicator based on the WPR algorithm. This is what came to my mind, how to filter out unnecessary impulses of my indicator.. Brief technical description of this indicator: This indicator calculates dynamic ATR% - the percentage deviation of the moving ATR value (with a dynamic period depending on volatility) from the average range (High–Low) for a given period. The first line shows the resulting ATR% value, and the second line is the same value, shifted one bar back.Thus, the indicator allows...Ignored
Disliked{quote} Hi there. Can you post the same date range (February) as of today? With the same settings. The main issue with too_good_to_be_true looking indicators - they're all repaint. So I'm interested on does it repaints the whole history or only the recent bars. In both cases you need to fix that issue for live tradingIgnored
DislikedHow to filter, motherfucker. Signals are generated on a completed bar. Yes, I always knew that WPR had great potential. The main thing is in the cook, who cooks it and how. {image}Ignored
Disliked{quote} Hey man, Is it possible to share this code ? Who knows, maybe other ideas from other people could prove as productive in the end .... All the bestIgnored
Disliked{quote}Well, to give someone the whole code is too much. I can help, for example, if you asked me that I have such a strategy (without code) and I encountered such a problem: for example, how to set a stop loss, or how to set a take profit. Or how to filter this or that signal. I would share my vision. Everything depends on your strategy that you are developing. I also ask my colleagues in the shop. We are programmers, and we have shoveled and programmed so many algorithms. Take my word for it, if you ask someone something, it is better...
Ignored