Custom indicator doesn't show data for all bars. New comment 0Tom 2021.05.19 17:14 On my indicator that I am making data is only displayed for the most recent 50% or so (it varies) bars and then after that it does not display anymore data. Here's a picture showing what I mean https://imgur.com/a/NquoQLo . property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 #property show_inputs extern int period ; double cnv_tb[ ] ; double nv[ ] ; double cnv[ ] ; double cnv_ma[ ] ; int OnInit() { SetIndexBuffer( 0 , cnv_ma ) ; return( INIT_SUCCEEDED ) ; } int OnCalculate(const int rates_total , const int prev_calculated , const datetime &time[ ] , const double &open[ ] , const double &high[ ] , const double &low[ ] , const double &close[ ] , const long &tick_volume[ ] , const long &volume[ ] , const int &spread[ ] ) { int bars = rates_total ; ArrayResize( nv , bars ) ; ArrayResize( cnv , bars ) ; ArrayResize( cnv_ma , bars ) ; double close0 ; double close1 ; double volume0 ; nv[ bars - 1 ] = 0 ; for( int i = 0 ; i < bars - 1 ; i++ ) { close0 = iClose( NULL , NULL , i ) ; close1 = iClose( NULL , NULL , i + 1 ) ; volume0 = iVolume( NULL , NULL , i ) ; if ( close0 - close1 > 0 ) { nv[ i ] = volume0 ; } else { if( close0 - close1 < 0 ) { nv[ i ] = - volume0 ; } else { nv[ i ] = 0 ; } } } cnv[ bars - 1 ] = nv [ bars - 1 ] ; for( i = bars - 2 ; i >= 0 ; i-- ) { cnv[ i ] = cnv[ i + 1 ] + nv[ i ] ; } for ( i = 0 ; i < bars - period + 1 ; i++ ) { for( int j = i ; j < i + period ; j++ ) { cnv_ma[ i ] += cnv[ i + j ] ; } cnv_tb[ i ] = cnv[ i ] - cnv_ma[ i ] ; } return( rates_total ) ; } New MetaTrader 4 Client Terminal build 402 Stochastic Indicator with text Stochastic Oscillator, the beginning New comment
On my indicator that I am making data is only displayed for the most recent 50% or so (it varies) bars and then after that it does not display anymore data. Here's a picture showing what I mean https://imgur.com/a/NquoQLo .