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
Correcto, está calculado. Se encuentra el número de la célula. De esta celda (serie temporal) se toma el valor del máximo o del mínimo de la barra. Se considera que el máximo se ha encontrado en esta barra. Este valor se coloca en la memoria intermedia del indicador con el número encontrado. El máximo del indicador debe corresponder al máximo de la barra. En mi código, el máximo también se toma del array (timeseries) con el mismo número encontrado y se compara con el valor de val. Se comprueba si estamos haciendo lo correcto: ponemos en el buffer con este número el valor de val. También debe ser igual al máximo de la barra. La comparación de los números tomados del mismo lugar es bastante correcta.
Me parece que la comparación ...==val, es peligrosa porque es el número de celda el que puede cambiar de tic a tic. Especialmente en marcos temporales pequeños donde hay muchos mínimos y máximos muy parecidos. Sin embargo, deberíamos pensarlo bien, tal vez nos referimos a momentos diferentes.
//+------------------------------------------------------------------+ //| CZigZag.mq4 | //| Copyright © 2006, Candid | //| likh@yandex.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, Candid" #property link "likh@yandex.ru" #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Blue //---- indicator parameters extern int ExtDepth=12; extern int ExtDeviation=5; //extern int ExtBackstep=3; int shift; double res; int i; int fBar; double CurMax,CurMin; int CurMaxPos,CurMinPos; int CurMaxBar,CurMinBar; double hPoint; double mhPoint; double EDev; int MaxDist,MinDist; bool FirstRun; bool AfterMax,AfterMin; //---- indicator buffers double ZigZag[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_SECTION); //---- indicator buffers mapping SetIndexBuffer(0,ZigZag); SetIndexEmptyValue(0,0.0); //---- indicator short name IndicatorShortName("CZigZag("+ExtDepth+","+ExtDeviation+")"); FirstRun = true; //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if (FirstRun) { hPoint = 0.5*Point; mhPoint = -hPoint; // EDev = ExtDeviation*Point; EDev = (ExtDeviation+0.5)*Point; AfterMax = true; AfterMin = true; fBar = Bars-1; CurMax = High[fBar]; CurMaxBar = 1; CurMin = Low[fBar]; CurMinBar = 1; MaxDist = 0; MinDist = 0; FirstRun = false; } //---- fBar = Bars-counted_bars-1; if (fBar > Bars-2) fBar = Bars-2; for(shift=fBar; shift>=0; shift--) { if (AfterMax) { // res = Low[shift]-CurMin-hPoint; res = Low[shift]-CurMin; // if (res < 0) { if (res < mhPoint) { ZigZag[Bars-CurMinBar] = 0; CurMin = Low[shift]; CurMinBar = Bars-shift; ZigZag[Bars-CurMinBar] = CurMin; } else { // if (res < 0) // if (res > 0 ) { if (res > hPoint ) { MaxDist = Bars-CurMaxBar-shift+1; MinDist = Bars-CurMinBar-shift+1; if ((MaxDist>ExtDepth && MinDist>ExtDepth) || res > EDev) { AfterMax = false; AfterMin = true; CurMaxBar = CurMinBar+1; CurMaxPos = Bars-CurMaxBar; CurMax = High[CurMaxPos]; for (i=CurMaxPos-1;i>=shift;i--) { if (High[i] > CurMax+hPoint) { CurMaxBar = Bars-i; CurMax = High[i]; } } // for (i=CurMaxPos-1;i>=shift;i--) ZigZag[Bars-CurMaxBar] = CurMax; } // if ((MaxDist>ExtDepth && MinDist>ExtDepth) || res > EDev) } // if (res > 0 ) } // else if (res < 0) } // if (AfterMax) if (AfterMin) { // res = CurMax-High[shift]-hPoint; res = CurMax-High[shift]; // if (res < 0) { if (res < mhPoint) { ZigZag[Bars-CurMaxBar] = 0; CurMax = High[shift]; CurMaxBar = Bars-shift; ZigZag[Bars-CurMaxBar] = CurMax; } else { // if (res < 0) // if (res > 0 ) { if (res > hPoint ) { MaxDist = Bars-CurMaxBar-shift+1; MinDist = Bars-CurMinBar-shift+1; if ((MaxDist>ExtDepth && MinDist>ExtDepth) || res > EDev) { AfterMin = false; AfterMax = true; CurMinBar = CurMaxBar+1; CurMinPos = Bars-CurMinBar; CurMin = Low[CurMinPos]; for (i=CurMinPos-1;i>=shift;i--) { if (Low[i] < CurMin-hPoint) { CurMinBar = Bars-i; CurMin = Low[i]; } } // for (i=CurMinPos-1;i>=shift;i--) ZigZag[Bars-CurMinBar] = CurMin; } // if ((MaxDist>ExtDepth && MinDist>ExtDepth) || res > EDev) } // if (res > 0 ) } // else if (res < 0) } // if (AfterMin) } // for(shift=fBar; shift>=0; shift--) //---- return(0); } //+------------------------------------------------------------------+Tenga en cuenta que, aunque los nombres de los parámetros se mantienen, funcionan de forma diferente.
//+------------------------------------------------------------------+ //| DT_ZZ.mq4 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, klot." #property link "klot@mail.ru" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Aqua #property indicator_color2 Blue #property indicator_color3 Red //---- indicator parameters extern int ExtDepth=12; //---- indicator buffers double zzL[]; double zzH[]; double zz[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { // IndicatorBuffers(3); //---- drawing settings SetIndexStyle(2,DRAW_ARROW); SetIndexStyle(1,DRAW_ARROW); SetIndexStyle(0,DRAW_SECTION); SetIndexArrow(2,159); SetIndexArrow(1,159); //---- indicator buffers mapping SetIndexBuffer(0,zz); SetIndexBuffer(1,zzH); SetIndexBuffer(2,zzL); SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); SetIndexEmptyValue(2,0.0); //---- indicator short name IndicatorShortName("DT_ZZ("+ExtDepth+")"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int i,shift,pos,lasthighpos,lastlowpos,curhighpos,curlowpos; double curlow,curhigh,lasthigh,lastlow; double min, max; ArrayInitialize(zz,0.0); ArrayInitialize(zzL,0.0); ArrayInitialize(zzH,0.0); lasthighpos=Bars; lastlowpos=Bars; lastlow=Low[Bars];lasthigh=High[Bars]; for(shift=Bars-ExtDepth; shift>=0; shift--) { curlowpos=Lowest(NULL,0,MODE_LOW,ExtDepth,shift); curlow=Low[curlowpos]; curhighpos=Highest(NULL,0,MODE_HIGH,ExtDepth,shift); curhigh=High[curhighpos]; //------------------------------------------------ if( curlow>=lastlow ) { lastlow=curlow; } else { //идем вниз if( lasthighpos>curlowpos ) { zzL[curlowpos]=curlow; ///* min=100000; pos=lasthighpos; for(i=lasthighpos; i>=curlowpos; i--) { if (zzL[i]==0.0) continue; if (zzL[i]<min) { min=zzL[i]; pos=i; } zz[i]=0.0; } zz[pos]=min; //*/ } lastlowpos=curlowpos; lastlow=curlow; } //--- high if( curhigh<=lasthigh ) { lasthigh=curhigh;} else { // идем вверх if( lastlowpos>curhighpos ) { zzH[curhighpos]=curhigh; ///* max=-100000; pos=lastlowpos; for(i=lastlowpos; i>=curhighpos; i--) { if (zzH[i]==0.0) continue; if (zzH[i]>max) { max=zzH[i]; pos=i; } zz[i]=0.0; } zz[pos]=max; //*/ } lasthighpos=curhighpos; lasthigh=curhigh; } //---------------------------------------------------------------------- } return(0); } //+------------------------------------------------------------------+Tenga en cuenta que aunque los nombres de los parámetros son los mismos, funcionan de forma diferente.
Candidato. Le echaré un vistazo. La primera vez que lo instalé, tuve la siguiente observación.
Hay varias barras consecutivas con los mismos máximos. Su variante del zigzag dibuja la ruptura (arriba) en la última barra. Es decir, la barra más cercana a cero. Lo ideal es que la ruptura se dibuje en la primera barra, que es la más alejada de la barra cero. El primer vértice que aparece es significativo. Lo mismo ocurre con mtnemums. Puedo citar varias fuentes (de la literatura), donde se requiere hacerlo.
Sí, me he dado cuenta :) sólo una idea :) . Ahora estoy usando mi ZZ en todo el lugar (código en el post anterior) Funciona más estable con otros datos TF.
En la primera instalación, surgió inmediatamente la siguiente observación.
Hay varias barras consecutivas con los mismos máximos. Su opción de zigzag dibuja una ruptura (superior) en la última barra.
Klot, interesante opción.
Si sus variantes en zigzag muestran resultados interesantes, ¿puedo aplicarlas en mi desarrollo?