Ti stai perdendo delle opportunità di trading:
- App di trading gratuite
- Oltre 8.000 segnali per il copy trading
- Notizie economiche per esplorare i mercati finanziari
Registrazione
Accedi
Accetti la politica del sito e le condizioni d’uso
Se non hai un account, registrati
Corretto, è calcolato. Si trova il numero di cella. Da questa cella (serie temporale) si prende il valore del massimo o del minimo della barra. Si ritiene che il massimo sia stato trovato su questa barra. Questo valore viene poi messo nel buffer dell'indicatore con il numero trovato. Il massimo dell'indicatore dovrebbe corrispondere al massimo sulla barra. Nel mio codice, il massimo è anche preso dall'array (serie temporale) con lo stesso numero trovato e confrontato con il valore di val. Si controlla se stiamo facendo la cosa giusta: mettiamo il numero val nel buffer con questo numero. Dovrebbe anche essere uguale al massimo della barra. Il confronto di numeri presi dallo stesso posto è abbastanza corretto.
Mi sembra che il confronto ...==val, sia pericoloso perché è il numero della cella che può cambiare da una spunta all'altra. Soprattutto a piccoli timeframe dove ci sono molti bassi e alti strettamente abbinati. Tuttavia, dovremmo pensarci bene, forse intendiamo momenti diversi.
//+------------------------------------------------------------------+ //| 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); } //+------------------------------------------------------------------+Notate che anche se i nomi dei parametri sono mantenuti, funzionano in modo diverso.
//+------------------------------------------------------------------+ //| 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); } //+------------------------------------------------------------------+Tenete presente che anche se i nomi dei parametri sono gli stessi, funzionano in modo diverso.
Candido. Gli darò un'occhiata. La prima volta che l'ho installato, ho avuto la seguente osservazione.
Ci sono diverse barre consecutive con gli stessi massimi. La tua variante dello zigzag disegna la rottura (in alto) sull'ultima barra. Cioè la barra più vicina allo zero. Idealmente, la rottura dovrebbe essere disegnata sulla prima barra, che è più lontana dalla barra zero. Il primo vertice che appare è significativo. È lo stesso con mtnemums. Posso citare diverse fonti (dalla letteratura), dove è richiesto di farlo.
Sì, ho notato :) solo un'idea :) . Ora sto usando il mio ZZ dappertutto (codice nel post sopra) Funziona più stabile con altri dati TF.
Alla prima installazione, è emersa immediatamente la seguente osservazione.
Ci sono diverse barre consecutive con gli stessi massimi. La tua opzione zigzag disegna una rottura (in alto) sull'ultima barra.
Klot, opzione interessante.
Se le vostre varianti di zigzag mostrano risultati interessanti, posso applicarle nel mio sviluppo?