Hola, Sr. Nicholas,
He añadido "plazos relativos".
//+------------------------------------------------------------------+ //|Fib_SR_6.mq5 //|Copyright © 2006, Eli hayun | //| http://www.elihayun.com //+------------------------------------------------------------------+ //---- autoría del indicador #property copyright "Copyright © 2006, Eli Hayun". //---- enlace a la página web del autor #property link "http://www.elihayun.com" //---- número de versión del indicador #property version "1.00" //---- dibujar indicador en la ventana principal #property indicator_chart_window //---- no se utilizan buffers para el cálculo y dibujo del indicador #property indicator_buffers 0 //---- cero construcciones gráficas utilizadas #property indicator_plots 0 //+----------------------------------------------+ //| declarando constantes | //+----------------------------------------------+ #define RESET 0 // Constante para devolver al terminal la orden de recalcular el indicador #define FIB_RES3 "FIB_RES_3" #define FIB_RES2 "FIB_RES_2" #define FIB_RES1 "FIB_RES_1" #define FIB_SUP1 "FIB_SUP_1" #define FIB_SUP2 "FIB_SUP_2" #define FIB_SUP3 "FIB_SUP_3" //--- // enum enTimeFrames { tf_cu = PERIOD_CURRENT, // Marco temporal actual tf_m1 = PERIOD_M1, // 1 minuto tf_m2 = PERIOD_M2, // 2 minutos tf_m3 = PERIOD_M3, // 3 minutos tf_m4 = PERIOD_M4, // 4 minutos tf_m5 = PERIOD_M5, // 5 minutos tf_m6 = PERIOD_M6, // 6 minutos tf_m10 = PERIOD_M10, // 10 minutos tf_m12 = PERIOD_M12, // 12 minutos tf_m15 = PERIOD_M15, // 15 minutos tf_m20 = PERIOD_M20, // 20 minutos tf_m30 = PERIOD_M30, // 30 minutos tf_h1 = PERIOD_H1, // 1 hora tf_h2 = PERIOD_H2, // 2 horas tf_h3 = PERIOD_H3, // 3 horas tf_h4 = PERIOD_H4, // 4 horas tf_h6 = PERIOD_H6, // 6 horas tf_h8 = PERIOD_H8, // 8 horas tf_h12 = PERIOD_H12, // 12 horas tf_d1 = PERIOD_D1, // diario tf_w1 = PERIOD_W1, // semanal tf_mn = PERIOD_MN1, // mensual tf_cp1 = -1, // Siguiente marco temporal superior tf_cp2 = -2, // Segundo marco temporal superior tf_cp3 = -3, // Tercer marco temporal superior tf_cp4 = -4, // Cuarto marco temporal superior tf_cp5 = -5, // Quinto marco temporal superior tf_cp6 = -6 // Sexto marco temporal superior }; ENUM_TIMEFRAMES _tfsPer[]={PERIOD_M1,PERIOD_M2,PERIOD_M3,PERIOD_M4,PERIOD_M5,PERIOD_M6,PERIOD_M10,PERIOD_M12,PERIOD_M15,PERIOD_M20,PERIOD_M30,PERIOD_H1,PERIOD_H2,PERIOD_H3,PERIOD_H4,PERIOD_H6,PERIOD_H8,PERIOD_H12,PERIOD_D1,PERIOD_W1,PERIOD_MN1}; // //--- // //+----------------------------------------------+ //|| Parámetros de entrada del indicador //+----------------------------------------------+ input enTimeFrames InpTimeframe = tf_cp1; // Indicador Próximo marco temporal para calcular el indicador input uint NumberofBar = 1; // Número de barra para calcular el indicador input double Ratio1 = 0.618; // primera relación input double Ratio2 = 1.382; // segunda relación input double Ratio3 = 2.764; // segunda relación input double Step = 0.50; // paso de extensión input color Color_Res3 = clrAqua; // color de la tercera zona de resistencia input color Color_Res2 = clrLime; // color de la segunda zona de resistencia input color Color_Res1 = clrGreen; // color de la primera zona de resistencia input color Color_Sup1 = clrRed; // color de la primera zona de apoyo input color Color_Sup2 = clrMagenta; // color de la segunda zona de apoyo input color Color_Sup3 = clrYellow; // color de la tercera zona de apoyo input uint RightTail = 60; // protrusión de rectángulos más allá de la barra cero a la derecha en minutos input uint LeftTail = 60; // protrusión de rectángulos detrás de la barra de salida hacia la izquierda en minutos //+----------------------------------------------+ uint SecondRightTail,SecondLeftTail; //--- variables globales ENUM_TIMEFRAMES Timeframe; //+------------------------------------------------------------------+ //| Creación de un objeto rectangular| //+------------------------------------------------------------------+ void CreateRectangle ( long chart_id, // identificador del gráfico string name, // nombre del objeto int nwin, // índice de la ventana datetime time1, // tiempo 1 double price1, // precio 1 datetime time2, // tiempo 2 double price2, // precio 2 color Color, // color de la línea bool background, // visualización en segundo plano de la línea string text // texto ) //---- { //---- ObjectCreate(chart_id,name,OBJ_RECTANGLE,nwin,time1,price1,time2,price2); ObjectSetInteger(chart_id,name,OBJPROP_COLOR,Color); ObjectSetInteger(chart_id,name,OBJPROP_FILL,true); ObjectSetString(chart_id,name,OBJPROP_TEXT,text); ObjectSetInteger(chart_id,name,OBJPROP_BACK,background); ObjectSetString(chart_id,name,OBJPROP_TOOLTIP,"\n"); //prohibir información sobre herramientas ObjectSetInteger(chart_id,name,OBJPROP_BACK,true); //objeto en segundo plano //---- } //+------------------------------------------------------------------+ //|| Restablecer un objeto rectangular || //+------------------------------------------------------------------+ void SetRectangle ( long chart_id, // identificador del gráfico string name, // nombre del objeto int nwin, // índice de la ventana datetime time1, // tiempo 1 double price1, // precio 1 datetime time2, // tiempo 2 double price2, // precio 2 color Color, // color de la línea bool background, // visualización en segundo plano de la línea string text // texto ) //---- { //---- if(ObjectFind(chart_id,name)==-1) CreateRectangle(chart_id,name,nwin,time1,price1,time2,price2,Color,background,text); else { ObjectSetString(chart_id,name,OBJPROP_TEXT,text); ObjectMove(chart_id,name,0,time1,price1); ObjectMove(chart_id,name,1,time2,price2); } //---- } //+------------------------------------------------------------------+ //| Función de inicialización del indicador personalizada | //+------------------------------------------------------------------+ int OnInit() { //---Calcular el marco temporal del indicador Timeframe = MathMax(timeFrameGet((int)InpTimeframe),_Period); //---- SecondRightTail=RightTail*60; SecondLeftTail=LeftTail*60; //---- determinar la precisión de la visualización de los valores de los indicadores IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //---- crear etiquetas para mostrar en DataWindow y nombre para mostrar en subventana separada y tooltip IndicatorSetString(INDICATOR_SHORTNAME,"Fib_SR"); //---- inicialización completada return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Función personalizada de desinicialización del indicador || //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //---- ObjectDelete(0,FIB_SUP3); ObjectDelete(0,FIB_SUP2); ObjectDelete(0,FIB_SUP1); ObjectDelete(0,FIB_RES1); ObjectDelete(0,FIB_RES2); ObjectDelete(0,FIB_RES3); //---- ChartRedraw(0); } //+------------------------------------------------------------------+ //| Función de iteración del indicador personalizada | //+------------------------------------------------------------------+ int OnCalculate( const int rates_total, // cantidad de historia en barras en el tick actual const int prev_calculated,// cantidad de historia en barras en el tick anterior const datetime &time[], const double &open[], const double& high[], // matriz de precios máximos para el cálculo del indicador const double& low[], // matriz de precios mínimos para el cálculo del indicador const double &close[], const long &tick_volume[], const long &volume[], const int &spread[] ) { //---- if(prev_calculated==rates_total && NumberofBar) return(rates_total); //---- double nClose[1],nHigh[1],nLow[1]; datetime nTime[1]; int to_copy; //---- indexación de elementos en matrices como en timeseries ArraySetAsSeries(time,true); //---- to_copy=1; //---- if(CopyTime(NULL,Timeframe,0,to_copy,nTime)<to_copy)return(RESET); if(CopyClose(NULL,Timeframe,NumberofBar,to_copy,nClose)<to_copy)return(RESET); if(CopyHigh(NULL,Timeframe,NumberofBar,to_copy,nHigh)<to_copy)return(RESET); if(CopyLow(NULL,Timeframe,NumberofBar,to_copy,nLow)<to_copy)return(RESET); //---- double C=nClose[0]; double H=nHigh[0]; double L=nLow[0]; double R=(H-L); //---- C=(H+L+C)/3; double D=C+R*Step; double B=C-R*Step; double E=C+R*2*Step; double A=C-R*2*Step; //---- double R2=R*Ratio2; double R1=R*Ratio1; double B1=C-R1; double A1=C-R2; //---- double D1=C+R1; double E1=C+R2; //---- double R3=R*Ratio3; double F=C+R*4*Step; double G=C-R*4*Step; double F1=C+R3; double G1=C-R3; //---- SetRectangle(0,FIB_RES3,0,nTime[0]-SecondLeftTail,F,time[0]+SecondRightTail,F1,Color_Res3,true,FIB_RES3); SetRectangle(0,FIB_RES2,0,nTime[0]-SecondLeftTail,E,time[0]+SecondRightTail,E1,Color_Res2,true,FIB_RES2); SetRectangle(0,FIB_RES1,0,nTime[0]-SecondLeftTail,D,time[0]+SecondRightTail,D1,Color_Res1,true,FIB_RES1); SetRectangle(0,FIB_SUP1,0,nTime[0]-SecondLeftTail,B,time[0]+SecondRightTail,B1,Color_Sup1,true,FIB_SUP1); SetRectangle(0,FIB_SUP2,0,nTime[0]-SecondLeftTail,A,time[0]+SecondRightTail,A1,Color_Sup2,true,FIB_SUP2); SetRectangle(0,FIB_SUP3,0,nTime[0]-SecondLeftTail,G,time[0]+SecondRightTail,G1,Color_Sup3,true,FIB_SUP3); //---- ChartRedraw(0); return(rates_total); } //+------------------------------------------------------------------+ // ENUM_TIMEFRAMES timeFrameGet(int period) { int _shift=(period<0?MathAbs(period):0); if(_shift>0 || period==tf_cu) period=_Period; int i; for(i=0;i<ArraySize(_tfsPer);i++) if(period==_tfsPer[i]) break; return(_tfsPer[(int)MathMin(i+_shift,ArraySize(_tfsPer)-1)]); } // //---
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
Fib_SR_6:
Indicador Fib_SR con dos zonas adicionales de soporte y resistencia.
Autor: Nikolay Kositsin