Média móvel exponencial baseado em valores não padrão
- Indicadores: ZeroLagEMA
- Média Móvel no OBJ_CHART
- Indicadores: Shifted Moving Average
Olá angronio,
Por favor dê uma olhada nesse código: https://www.mql5.com/pt/code/viewcode/481/143733/smoothalgorithms.mqh
Especificamente, dê uma olhada no enumerador "Applied_Price_", onde vários exemplos de preços "não tradicionais" são utilizados.
Segue um trecho do código para que você possa entender como funciona:
//---- declaration and initialization of the enumeration of price constants types enum Applied_price_ //Type of constant { PRICE_CLOSE_ = 1, // 1 PRICE_OPEN_, // 2 PRICE_HIGH_, // 3 PRICE_LOW_, // 4 PRICE_MEDIAN_, // 5 PRICE_TYPICAL_, // 6 PRICE_WEIGHTED_, // 7 PRICE_SIMPLE, // 8 PRICE_QUARTER_, // 9 PRICE_TRENDFOLLOW0_, // 10 PRICE_TRENDFOLLOW1_ // 11 }; */ //+------------------------------------------------------------------+ //| PriceSeries() function | //+------------------------------------------------------------------+ double PriceSeries(uint applied_price, // Price constant uint bar, // Index of shift relative to the current bar for a specified number of periods back or forward). const double &Open[], const double &Low[], const double &High[], const double &Close[] ) { //----+ switch(applied_price) { //---- Price constants from the ENUM_APPLIED_PRICE enumeration case PRICE_CLOSE: return(Close[bar]); case PRICE_OPEN: return(Open [bar]); case PRICE_HIGH: return(High [bar]); case PRICE_LOW: return(Low[bar]); case PRICE_MEDIAN: return((High[bar]+Low[bar])/2.0); case PRICE_TYPICAL: return((Close[bar]+High[bar]+Low[bar])/3.0); case PRICE_WEIGHTED: return((2*Close[bar]+High[bar]+Low[bar])/4.0); //----+ case 8: return((Open[bar] + Close[bar])/2.0); case 9: return((Open[bar] + Close[bar] + High[bar] + Low[bar])/4.0); //---- case 10: { if(Close[bar]>Open[bar]) return(High[bar]); else { if(Close[bar]<Open[bar]) return(Low[bar]); else return(Close[bar]); } } //---- case 11: { if(Close[bar]>Open[bar])return((High[bar]+Close[bar])/2.0); else { if(Close[bar]<Open[bar]) return((Low[bar]+Close[bar])/2.0); else return(Close[bar]); } } //---- case 12: { double res=High[bar]+Low[bar]+Close[bar]; if(Close[bar]<Open[bar]) res=(res+Low[bar])/2; if(Close[bar]>Open[bar]) res=(res+High[bar])/2; if(Close[bar]==Open[bar]) res=(res+Close[bar])/2; return(((res-Low[bar])+(res-High[bar]))/2); } //---- default: return(Close[bar]); }
Abraços,
Malacarne
- www.mql5.com
Olá angronio,
Por favor dê uma olhada nesse código: https://www.mql5.com/pt/code/viewcode/481/143733/smoothalgorithms.mqh
Especificamente, dê uma olhada no enumerador "Applied_Price_", onde vários exemplos de preços "não tradicionais" são utilizados.
Segue um trecho do código para que você possa entender como funciona:
Abraços,
Malacarne