Plot( A, "", colorGreen, styleThick , styleStaircase );
Plot( AA, "", colorGreen, styleThick , styleStaircase );
Plot( B, "", colorRed, styleThick , styleStaircase );
Plot( BB, "", colorRed, styleThick , styleStaircase );
I have this code to plot lines on the chart. I want to have a Param to show x number of "previous" plotted lines eg: Plot only 7 previous A , AA and 7 previous B , BB lines
I would like to change the x number to any number to 7 or 10 depending on the time frame.
What do I have to include or how to write.
Hope this is what you are looking for:
x = Param( "No. of previous data points", 7, 7, 200, 1 );
Per = Param( "EMA Periods", 34, 8, 449, 1 );
bi = BarIndex();
currBar = SelectedValue( bi );
ExpoMA = EMA( C, Per );
for( i = currBar; i > currBar - x; i-- )
dispExpoMA[ i ] = ExpoMA[ i ];
Plot( IIf( IsNan( dispExpoMA ) OR dispExpoMA == 0, Null, dispExpoMA ), "EMA("+Per+")", ParamColor( "EMA Color", colorDarkBlue ), styleLine, Null, Null, 0, 4, 2 );
Plot( C, "Close", colorDefault, styleNoTitle | styleThick | styleCandle, Null, Null, 0, 5, 2 );
For me this used to be a problem also, until I read QuickAFL facts. There is an image towards the bottom of the page - it clears many
BarIndex vs BarCount related doubts.
Moreover, do play with the parameters of the code in the chart window. From here I think you will be able to incorporate Interval function and other timeframe aspects to suite your specific needs.
Thank you for he code @Lennon