Hola, es el primer mensaje que escribo en el foro. He estado buscando hilos sobre indicators/experts en MQL5 y no he encontrado uno para eso solo...
Llevo un par de meses aprendiendo a ratos MQL5 y la verdad es que me cuesta bastante al no haber programado nunca. Os queria hacer un par de preguntas:
1.- Alguien ha participado algun año en el "Automated Trading Championship 2012" que organiza "MetaQuotes Software Corp."?
2.- Os dejo un indicador que he modificado. Se trata del indicador "Fractals" que se encuentra en Metatrader. Con los cambios realizados, se pueden escoger tres inputs (barras a la izq. y derecha, y shift). El resultado es soporte/resistencia.
Os dejo el codigo y si veis algun error/problema o que no es optimo os agradecere que me lo digais:
//+------------------------------------------------------------------+
//| FractalsMod.mq5 |
//| Copyright 2012, Brezis |
//+------------------------------------------------------------------+
#property copyright "2012, Brezis"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2
#property indicator_type1 DRAW_ARROW
#property indicator_type2 DRAW_ARROW
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_label1 "Fractal Up"
#property indicator_label2 "Fractal Down"
//+------------------------------------------------------------------+
//| Inputs |
//+------------------------------------------------------------------+
input int leftbars = 10;
input int rightbars = 10;
input int shift = 10;
//---- indicator buffers
double ExtUpperBuffer[];
double ExtLowerBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//---- indicator buffers mapping
SetIndexBuffer(0,ExtUpperBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ExtLowerBuffer,INDICATOR_DATA);
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//---- sets first bar from what index will be drawn
PlotIndexSetInteger(0,PLOT_ARROW,115);
PlotIndexSetInteger(1,PLOT_ARROW,115);
//---- sets drawing line empty value--
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- initialization done
}
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, // size of the price[] array
const int prev_calculated, // bars handled on a previous call
const datetime &Time[], // Time
const double &Open[], // Open
const double &High[], // High
const double &Low[], // Low
const double &Close[], // Close
const long &TickVolume[], // Tick Volume
const long &Volume[], // Real Volume
const int &Spread[]) // Spread
{
int i, j;
int limit;
int countup=0;
int countdown=0;
//---
//I need leftbars+rightbars+1 to calculate the indicator
if(rates_total<leftbars+rightbars+1)
return(0);
//---
//
if(prev_calculated<leftbars+rightbars+1)
{
limit=leftbars;
//--- clean up arrays
ArrayInitialize(ExtUpperBuffer,0);
ArrayInitialize(ExtLowerBuffer,0);
}
else
{
limit=rates_total-(leftbars+rightbars+1);
}
// We calculate the indicator
for(i=limit;i<=rates_total-leftbars-1;i++)
{
for (j=1;j<=leftbars;j++)
{
if(High>High[i+j]) countup=countup+1;
if(Low<Low[i+j]) countdown=countdown+1;
}
for(j=1;j<=rightbars;j++)
{
if(High>High[i-j]) countup=countup+1;
if(Low<Low[i-j]) countdown=countdown+1;
}
if (countup==leftbars+rightbars) ExtUpperBuffer[i+shift]=High;
else ExtUpperBuffer[i+shift]=ExtUpperBuffer[i+shift-1];
if (countdown==leftbars+rightbars) ExtLowerBuffer[i+shift]=Low;
else ExtLowerBuffer[i+shift]=ExtLowerBuffer[i+shift-1];
countup=0;
countdown=0;
}
//--- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
Indicadores y sistemas en MQL5
Todo sobre el trading en los mercados financieros: funcionamiento, dudas, noticias, etc.
Ir a
- Los Mercados
- ↳ Acciones Españolas
- ↳ Acciones Extranjeras
- ↳ Futuros y Opciones
- ↳ Forex
- ↳ Criptomonedas
- ↳ Renta Fija
- Las Técnicas
- ↳ Trading en General
- ↳ Sistemas de Trading
- ↳ Diarios de Trading
- ↳ Análisis Económico y Fundamental
- ↳ Psicología y Trading
- Plataformas de Trading
- ↳ Metatrader 4
- ↳ Expert Advisors
- ↳ Indicadores
- ↳ Scripts
- ↳ Metatrader 5
- ↳ Expert Advisors
- ↳ Indicadores
- ↳ Scripts
- ↳ Ninja Trader
- ↳ Estrategias
- ↳ Indicadores
- ↳ TradeStation
- ↳ Estrategias
- ↳ Indicadores
- ↳ PaintBars
- ↳ ShowMes
- ↳ Funciones
- ↳ MultiCharts
- ↳ Estrategias
- ↳ Indicadores
- ↳ Pine Script
- ↳ Expert Advisor Studio
- ↳ Python
- ↳ R
- ↳ ProRealTime
- ↳ Sistemas
- ↳ Indicadores
- ↳ Screeners
- ↳ Visual Chart
- ↳ Sistemas
- ↳ Indicadores
- ↳ Estudios
- ↳ AmiBroker
- ↳ Sistemas
- ↳ Indicadores
- ↳ Exploradores
- ↳ Comentarios
- ↳ Funciones
- ↳ Metastock
- ↳ Sistemas
- ↳ Indicadores
- ↳ Exploradores
- ↳ Asesores Expertos
- ↳ cTrader
- ↳ cBots
- ↳ Indicadores
- ↳ JForex
- ↳ Software
- Recursos para Traders
- ↳ Brokers
- ↳ Fiscalidad
- ↳ Data Feeds e Históricos
- ↳ Libros y Revistas de Trading
- ↳ Tutoriales
- ↳ Artículos Interesantes
- ↳ Páginas Web
- ↳ Cursos y Servicios
- ↳ Vídeos y Webinars
- Comunidad X-Trader.net
- ↳ Novedades de la Web
- ↳ Site Feedback
- ↳ Eventos
- ↳ 10 Años de X-Trader.net
- ↳ 20 Años de X-Trader.net
- ↳ Clasificados