Error Strategy Tester New comment Inaki Munarriz Herrador 2015.09.22 23:52 Hi everyone!Can anyone tell me why this indicator that estimates the average price doesn't work in the Strategy Tester? Is there an error in the code?Muchas gracias!!!#property strict #property indicator_chart_window #property indicator_buffers 1 //Input parámetros input color Color=clrRed; input int periodos=100; double recta_media[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer( 0, recta_media ); SetIndexStyle( 0, DRAW_LINE, DRAW_LINE, STYLE_SOLID, Color ); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ int start() { int i,j,n,Counted_bars,anteriores=1; double media_precio; double precio[]; ArrayResize(precio, Bars); ArrayInitialize(precio, 0.0); ArraySetAsSeries(precio, true); Counted_bars = IndicatorCounted(); i = Bars - Counted_bars -1; j = i - periodos; while (i>=0){ precio[i]=Close[i]; if (i<=(j+1)) { media_precio=0; //Calculo la media del precio for (n=(i+periodos-1);n>=i;n--) { media_precio += (precio[n]/periodos); } recta_media[i]=media_precio; //dibujar una recta lineal de la media if (anteriores==1) { for (n=(Bars - Counted_bars -1);n>=(j+2);n--) { recta_media[n]=media_precio; } } anteriores=0; } i--; RefreshRates(); } return (0); } MAXBARS in Strategy Tester how to backtest timebased EA Error: array out of range Alain Verleyen 2015.09.23 07:54 #1 Forum on trading, automated trading systems and testing trading strategiesHello, Please use the SRC button when you post code. Thank you. This time, I edited it for you. New comment
Hi everyone!
Can anyone tell me why this indicator that estimates the average price doesn't work in the Strategy Tester? Is there an error in the code?
Muchas gracias!!!