¡Espectáculo!
Autotrendlines es uno de los mejores indicadores gratuitos. Muchas gracias al creador de este indicador. ¡Pero tiene un gran problema! Elimina cualquier línea de tendencia que el propio usuario dibuja. He estado esperando mucho tiempo para ser solución de este problema. Así que estaré muy agradecido si este problema se resuelve en la nueva actualización.
[ARCHIVO] Cualquier pregunta de
Indicadores: EMA levels
Líneas horizontales
Autotrendlines es uno de los mejores indicadores gratuitos. Muchas gracias al creador de este indicador. ¡Pero tiene un gran problema! Elimina cualquier línea de tendencia que el propio usuario dibuja. He estado esperando mucho tiempo para ser solución de este problema. Así que estaré muy agradecido si este problema se resuelve en la nueva actualización.
[ARCHIVO] Cualquier pregunta de
Indicadores: EMA levels
Líneas horizontales
Aquí la revisión que eliminar sólo la línea creada por el indicador y dejar otra tendencia en el gráfico //+------------------------------------------------------------------+ //| AutoTrendLines.mq5 | //| Copyright 2012, Rone. | //| rone.sergey@gmail.com | //+------------------------------------------------------------------+ // https://www.mql5.com/es/code/1220 //+------------------------------------------------------------------+ //| Líneas de tendencia automáticas. | Tipo 1. Con dos extremos. | //| 1) Desde la barra actual "ir" hacia la izquierda y buscar el primer punto | //| (derecho) extremo con las barras InpRightExmSide en ambos | //| lados. | 2) Desde el primer punto, vuelva a "ir" a la izquierda y busque el segundo punto extremo (izquierdo) con las barras InpLeftExmSide a ambos lados. | //| 3) Dibuja una línea de tendencia. | Tipo 2. Con extremo y delta. | //| 1) Desde la barra actual "ir" hacia la izquierda y buscar el segundo punto extremo (izquierdo) con las barras InpLeftExmSide a ambos lados. | //| 2) Partiendo de la barra InpFromCurrent de la barra actual y hasta el segundo punto extremo encontrar la barra con delta mínimo. | //| 3) Dibuje una línea de tendencia. | //| | //| NOTA: | //| 1) Las líneas se recalculan sólo cuando aparece una nueva barra | //| 2) La barra actual no formada no se incluye en los cálculos | //| 3) El extremo significa una barra, para la cual las barras izquierda y derecha | //| N tienen mínimos por encima y máximos | //| por debajo. | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, Rone." #property link "rone.sergey@gmail.com" #property version "1.00" #property description "Líneas de tendencia automáticas" //--- #property indicator_chart_window //--- string prefisso="AUTO_TRND"; enum ENUM_LINE_TYPE { EXM_EXM, // 1: Por 2 extremos EXM_DELTA // 2: Extremo y delta }; //+------------------------------------------------------------------+ //| Clase 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) { precio = p; tiempo = t; } //--- void CPoint::setPoint(const double p, const datetime t) { precio = p; tiempo = t; } //--- bool CPoint::operator==(const CPoint &other) const { return precio == otro.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(precio); } //--- datetime CPoint::getTime(void) const { return(time); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ CPoint curLeftSup, curRightSup, curLeftRes, curRightRes, nullPoint;
//+------------------------------------------------------------------+ //| Parámetros de entrada | //+------------------------------------------------------------------+ input ENUM_LINE_TYPE InpLineType = EXM_DELTA;// Tipo de línea input int InpLeftExmSide = 10; // Extremo izquierdo (Tipo 1, 2) input int InpRightExmSide = 3; // Extremo derecho (Tipo 1) input int InpFromCurrent = 3; // Desplazamiento de la barra actual (Tipo 2) input bool InpPrevExmBar = false; // Tener en cuenta la barra anterior al extremo (Tipo 2) //--- input int InpLinesWidth = 2; // ancho de las líneas input color InpSupColor = clrRed; // Color de la línea de apoyo input color InpResColor = clrBlue; // Color de la línea de resistencia //--- variables globales int minRequiredBars;
//+------------------------------------------------------------------+ //| Función de inicialización del indicador personalizada | //+------------------------------------------------------------------+ int OnInit() { //--- minRequiredBars = InpLeftExmSide * 2 + MathMax(InpRightExmSide, InpFromCurrent) * 2;
//--- mapeo de buffers del indicador //--- return(0); } //+------------------------------------------------------------------+ //| Función personalizada de desinicialización del indicador |+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- int obj_total = ObjectsTotal(0,0); for(int i=obj_total -1; i>=0; i--) { string name= NombreObjeto(0,i); if(StringFind(nombre,prefisso,0) == 0) ObjectDelete(0, nombre); } //--- } //+------------------------------------------------------------------+ //| Función personalizada de iteración del indicador | //+------------------------------------------------------------------+ 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("No hay datos suficientes para calcular"); return(0); } //--- if ( prev_calculated != rates_total ) { switch ( InpLineType ) { case EXM_DELTA: //--- Support Left Point leftIndex = rates_total - InpLeftExmSide - 2; for ( ; !isLowestLow(leftIndex, InpLeftExmSide, low) && leftIndex > minRequiredBars; leftIndex-- ); curLeftSup.¡setPoint(low[leftIndex], time[leftIndex]); //--- Support Right Point 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]); //--- Resistencia Punto Izquierdo leftIndex = rates_total - InpLeftExmSide - 2; for ( ; !isHighestHigh(leftIndex, InpLeftExmSide, high) && leftIndex > minRequiredBars; leftIndex-- ); curLeftRes.¡setPoint(high[leftIndex], time[leftIndex]); //--- Resistencia Punto Derecho 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: //--- Support Right Point rightIndex = rates_total - InpRightExmSide - 2; for ( ; !isLowestLow(rightIndex, InpRightExmSide, low) && rightIndex > minRequiredBars; rightIndex-- ); curRightSup.setPoint(low[rightIndex], time[rightIndex]); //--- Support Left Point leftIndex = rightIndex - InpRightExmSide; for ( ; !isLowestLow(leftIndex, InpLeftExmSide, low) && leftIndex > minRequiredBars; leftIndex-- ); curLeftSup.setPoint(low[leftIndex], time[leftIndex]); //--- Resistencia Punto Derecho rightIndex = rates_total - InpRightExmSide - 2; for ( ; !isHighestHigh(rightIndex, InpRightExmSide, high) && rightIndex > minRequiredBars; rightIndex-- ); curRightRes.setPoint(high[rightIndex], time[rightIndex]); //--- Resistencia Punto Izquierdo leftIndex = rightIndex - InpRightExmSide; for ( ; !isHighestHigh(leftIndex, InpLeftExmSide, high) && leftIndex > minRequiredBars; leftIndex-- ); curLeftRes.setPoint(high[leftIndex], time[leftIndex]); //--- break; } //--- Draw Support & Resistance if ( curLeftSup != nullPoint && curRightSup != nullPoint ) { drawLine(prefisso+"Current_Support", curRightSup, curLeftSup, InpSupColor); } if ( curLeftRes != nullPoint && curRightRes != nullPoint ) { drawLine(prefisso+"Resistencia_actual", curRightRes, curLeftRes, InpResColor); } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| The Local Low search function | //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+ //| Función de búsqueda Local High | //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+ //| Draw trend line function | //+------------------------------------------------------------------+ 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); //--- } //+------------------------------------------------------------------+
Indicators: AutoTrendLines
asesor experto - preguntas
Ayuda a la codificación
un buen código, pero la línea de tendencia se está moviendo tan a menudo y se supone que tiene pendiente negativa para la tendencia a la baja y pendiente positiva para la tendencia alcista
Está perdiendo oportunidades comerciales:
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Registro
Entrada
Usted acepta la política del sitio web y las condiciones de uso
Si no tiene cuenta de usuario, regístrese