Покажи!
Autotrendlines - один из лучших бесплатных индикаторов. Большое спасибо создателю этого индикатора. Но у него есть большая проблема! Он удаляет все линии тренда, которые рисует сам пользователь. Я очень долго ждал, когда эта проблема будет решена. Поэтому я буду очень благодарен, если эта проблема будет решена в новом обновлении.
Мультитаймфреймовые индикаторы
[Архив!] Любой вопрос новичка,
Гармоническая торговля
Autotrendlines - один из лучших бесплатных индикаторов. Большое спасибо создателю этого индикатора. Но у него есть большая проблема! Он удаляет все линии тренда, которые рисует сам пользователь. Я очень долго ждал, когда эта проблема будет решена. Поэтому я буду очень благодарен, если эта проблема будет решена в новом обновлении.
Мультитаймфреймовые индикаторы
[Архив!] Любой вопрос новичка,
Гармоническая торговля
Вот обзор, который удаляет только линию, созданную индикатором, и оставляет на графике другие тренды //+------------------------------------------------------------------+ //| AutoTrendLines.mq5 | //| Copyright 2012, Rone. | //| rone.sergey@gmail.com | //+------------------------------------------------------------------+ // https://www.mql5.com/ru/code/1220 //+------------------------------------------------------------------+ //| Автоматические линии тренда. | //| Тип 1. С двумя экстремумами. | //| 1) От текущего бара "идем" влево и ищем первую | //| (правую) точку экстремума с барами InpRightExmSide с обеих | //| сторон. | //| 2) От первой точки снова "идем" влево и ищем | //| вторую (левую) экстремальную точку с барами InpLeftExmSide по | //| обеим сторонам. | //| 3) Постройте линии тренда. | //| | //| Тип 2. С экстремумом и дельтой. | //| 1) От текущего бара "идем" влево и ищем вторую | //| (левую) точку экстремума с барами InpLeftExmSide по обе стороны.| //| 2) Начиная с бара InpFromCurrent от текущего бара и | //| до второй точки экстремума находим бар с минимальной дельтой. | //| 3) Постройте линии тренда. | //| | //| ПРИМЕЧАНИЕ: | //| 1) Линии пересчитываются только при появлении нового бара | //| 2) Текущий несформированный бар не участвует в расчетах| //| 3) Под экстремумом понимается бар, для которого левый и правый | //| N баров имеют минимумы выше и максимумы | //| ниже. | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, Rone." #property link "rone.sergey@gmail.com" #property version "1.00" #property description "Автоматические линии тренда" //--- #property indicator_chart_window //--- string prefisso="AUTO_TRND"; enum ENUM_LINE_TYPE { EXM_EXM, // 1: По 2 экстремумам EXM_DELTA // 2: Экстремум и дельта }; //+------------------------------------------------------------------+ //| Class CPoint | //+------------------------------------------------------------------+ class CPoint { private: double price; datetime time; public: CPoint(); CPoint(const double p, const datetime t); ~CPoint() {}; void setPoint(const double p, const datetime t); bool operator==(const CPoint &other) const; bool operator!=(const CPoint &other) const; void operator=(const CPoint &other); double getPrice() const; datetime getTime() const; }; //--- CPoint::CPoint(void) { price = 0; time = 0; } //--- CPoint::CPoint(const double p, const datetime t) { цена = p; время = t; } //--- void CPoint::setPoint(const double p, const datetime t) { цена = p; время = t; } //--- bool CPoint::operator==(const CPoint &other) const { return price == other.price && time == other.time; } //--- bool CPoint::operator!=(const CPoint &other) const { return !operator==(other); } //--- void CPoint::operator=(const CPoint &other) { price = other.price; time = other.time; } //--- double CPoint::getPrice(void) const { return(price); } //--- datetime CPoint::getTime(void) const { return(time); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ CPoint curLeftSup, curRightSup, curLeftRes, curRightRes, nullPoint;
//+------------------------------------------------------------------+ //| Входные параметры | //+------------------------------------------------------------------+ input ENUM_LINE_TYPE InpLineType = EXM_DELTA;// Тип линии input int InpLeftExmSide = 10; // Левая крайняя сторона (тип 1, 2) input int InpRightExmSide = 3; // Правая крайняя сторона (тип 1) input int InpFromCurrent = 3; // Смещение от текущего бара (Тип 2) input bool InpPrevExmBar = false; // Учет бара перед экстремумом (Тип 2) //--- input int InpLinesWidth = 2; // Ширина линий input color InpSupColor = clrRed; // Цвет линии поддержки input color InpResColor = clrBlue; // Цвет линии сопротивления //--- global variables int minRequiredBars;
//+------------------------------------------------------------------+ //| Пользовательская функция инициализации индикатора | //+------------------------------------------------------------------+ int OnInit() { //--- minRequiredBars = InpLeftExmSide * 2 + MathMax(InpRightExmSide, InpFromCurrent) * 2;
//--- отображение буферов индикатора //--- return(0); } //+------------------------------------------------------------------+ //| Пользовательская функция деинициализации индикатора | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- int obj_total = ObjectsTotal(0,0); for(int i=obj_total -1; i>=0; i--) { string name= ObjectName(0,i); if(StringFind(name,prefisso,0) == 0) ObjectDelete(0, name); } //--- } //+------------------------------------------------------------------+ //| Пользовательская функция итерации индикатора | //+------------------------------------------------------------------+ 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[]) { //--- int leftIndex, rightIndex; double delta, tmpDelta; //--- if ( rates_total < minRequiredBars ) { Print("Недостаточно данных для расчета"); return(0); } //--- if ( prev_calculated != rates_total ) { switch ( InpLineType ) { case EXM_DELTA: //--- Поддерживаем левую точку leftIndex = rates_total - InpLeftExmSide - 2; for ( ; !isLowestLow(leftIndex, InpLeftExmSide, low) && leftIndex > minRequiredBars; leftIndex-- ); curLeftSup.setPoint(low[leftIndex], time[leftIndex]); //--- Поддерживаем правую точку rightIndex = rates_total - InpFromCurrent - 2; delta = (low[rightIndex] - low[leftIndex]) / (rightIndex - leftIndex); if ( !InpPrevExmBar ) { leftIndex += 1; } for ( int tmpIndex = rightIndex - 1; tmpIndex > leftIndex; tmpIndex-- ) { tmpDelta = (low[tmpIndex] - curLeftSup.getPrice()) / (tmpIndex - leftIndex); if ( tmpDelta < delta ) { delta = tmpDelta; rightIndex = tmpIndex; } } curRightSup.setPoint(low[rightIndex], time[rightIndex]); //--- Левая точка сопротивления leftIndex = rates_total - InpLeftExmSide - 2; for ( ; !isHighestHigh(leftIndex, InpLeftExmSide, high) && leftIndex > minRequiredBars; leftIndex-- ); curLeftRes.setPoint(high[leftIndex], time[leftIndex]); //--- Правая точка сопротивления rightIndex = rates_total - InpFromCurrent - 2; delta = (high[leftIndex] - high[rightIndex]) / (rightIndex - leftIndex); if ( !InpPrevExmBar ) { leftIndex += 1; } for ( int tmpIndex = rightIndex - 1; tmpIndex > leftIndex; tmpIndex-- ) { tmpDelta = (curLeftRes.getPrice() - high[tmpIndex]) / (tmpIndex - leftIndex); if ( tmpDelta < delta ) { delta = tmpDelta; rightIndex = tmpIndex; } } curRightRes.setPoint(high[rightIndex], time[rightIndex]); //--- break; case EXM_EXM: default: //--- Поддерживаем правую точку rightIndex = rates_total - InpRightExmSide - 2; for ( ; !isLowestLow(rightIndex, InpRightExmSide, low) && rightIndex > minRequiredBars; rightIndex-- ); curRightSup.setPoint(low[rightIndex], time[rightIndex]); //--- Поддерживаем левую точку leftIndex = rightIndex - InpRightExmSide; for ( ; !isLowestLow(leftIndex, InpLeftExmSide, low) && leftIndex > minRequiredBars; leftIndex-- ); curLeftSup.setPoint(low[leftIndex], time[leftIndex]); //--- Точка сопротивления справа rightIndex = rates_total - InpRightExmSide - 2; for ( ; !isHighestHigh(rightIndex, InpRightExmSide, high) && rightIndex > minRequiredBars; rightIndex-- ); curRightRes.setPoint(high[rightIndex], time[rightIndex]); //--- Левая точка сопротивления leftIndex = rightIndex - InpRightExmSide; for ( ; !isHighestHigh(leftIndex, InpLeftExmSide, high) && leftIndex > minRequiredBars; leftIndex-- ); curLeftRes.setPoint(high[leftIndex], time[leftIndex]); //--- break; } //--- Рисуем поддержку и сопротивление if ( curLeftSup != nullPoint && curRightSup != nullPoint ) { drawLine(prefisso+"Current_Support", curRightSup, curLeftSup, InpSupColor); } if ( curLeftRes != nullPoint && curRightRes != nullPoint ) { drawLine(prefisso+"Current_Resistance", curRightRes, curLeftRes, InpResColor); } } //--- возвращаем значение prev_calculated для следующего вызова return(rates_total); } //+------------------------------------------------------------------+ //| Функция поиска локального минимума | //+------------------------------------------------------------------+ bool isLowestLow(int bar, int side, const double &Low[]) { //--- for ( int i = 1; i <= side; i++ ) { //--- if ( Low[bar] > Low[bar-i] || Low[bar] > Low[bar+i] ) { return(false); } } //--- return(true); } //+------------------------------------------------------------------+ //| Функция поиска локального максимума | //+------------------------------------------------------------------+ bool isHighestHigh(int bar, int side, const double &High[]) { //--- for ( int i = 1; i <= side; i++ ) { //--- if ( High[bar] < High[bar-i] || High[bar] < High[bar+i] ) { return(false); } } //--- return(true); } //+------------------------------------------------------------------+ //| Функция рисования линии тренда | //+------------------------------------------------------------------+ void drawLine(string name, CPoint &right, CPoint &left, color clr) { //--- ObjectDelete(0, name); //--- ObjectCreate(0, name, OBJ_TREND, 0, right.getTime(), right.getPrice(), left.getTime(), left.getPrice()); ObjectSetInteger(0, name, OBJPROP_WIDTH, InpLinesWidth); ObjectSetInteger(0, name, OBJPROP_COLOR, clr); ObjectSetInteger(0, name, OBJPROP_RAY_LEFT, true); ObjectSetInteger(0, name, OBJPROP_SELECTABLE, true); //--- } //+------------------------------------------------------------------+
Помощь в кодировании
Любые вопросы новичков по
CHART_SHOW_OHLC для OBJ_CHART
хороший код, но линия тренда движется так часто, а она должна иметь отрицательный наклон для нисходящего тренда и положительный наклон для восходящего тренда
Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь