Hello,
I've searched for a long time and written many trials trying to solve my own problem. The closest I've found is a post about foreign synchronising the arrays but that doesn't solve what I'm trying to do.
Say I have multiple stocks of unequal bars (timeframes). Foreign synchronises them but whenever I perform any math on them the result is always the length of the shortest bars (timeline). I don't want this to happen I want the proceeding bars of the shorter timeframes considered as zero.
I have tried Nz but as far as I can see it only fixes up holes within a timeframe not add bars to make smaller ones equal to the chart price timeline.
I am considering copying each one into a matrix a padding earlier bars but hopefully there is an easier way?
Here is the core of my code cna assume declarations etc are done.
Any help appreciated.
Kinds regards
for( i = 0; ( symbol = StrExtract( tickerlist, i ) ) != ""; i++ )
{ fc = Foreign(symbol,"C",1);
//fc = Nz( fc ); // Null to zero function
if(NullCount(fc) < chosen_date_bar)
{ chosen_start_bar = chosen_date_bar;}
if(NullCount(fc) >= chosen_date_bar)
{ chosen_start_bar = NullCount(fc);}
relP = 100 * ( fc - fc[chosen_start_bar] ) / fc[chosen_start_bar];
relPsum += relP;
plot_colour = colorLightOrange + ( ( 2 * i ) % 15 );
plot_width = 1;
PlotTextSetFont( symbol,label_font , label_fontsize, LastValue( BarIndex() ) + 1, LastValue( relP ), GetChartBkColor(), plot_colour, -label_fontsize/2 );
Plot( IIf( bar_out_of_range, relP, Null), symbol, plot_colour, styleLine, Null, Null, 0, 1, plot_width );
}
relPav = relPsum / (i-1);
PlotTextSetFont( "relPav",label_font , label_fontsize, LastValue( BarIndex() ) + 1, LastValue( relPav ), GetChartBkColor(), plot_colour, -label_fontsize/2 );
Plot( IIf( bar_out_of_range, relPav, Null), "relPav", colorwhite, styleLine, Null, Null, 0, 1, 10*Plot_width );