@snbarma, please, make an effort to learn how to debug your formulas.
This thread provides links to learn how to use explorations, _TRACE() and the debugger to inspect the variables and arrays values used by your formulae.
PlotGrid() works as expected when you invoke it with a level value in the range of the main Plot() highest and lowest values.
If you pass it a zero value (hint) in a price chart then "No line is plotted" (as expected!)
In the above case, hpk sometime will have value, sometime it will hold NULL. If pk1==true, hpk will have value.
In plotshape(), we have a syntax to handle this.
Can we handle such case with PLOTGRID() function..
It should run with no error.
Obviously, in this example, there will be no red line to see.
So you can safely use the LastValue() function to convert any of your arrays to a numeric value to be used as the 1st argument (level).
@snbarma if you use True as the last parameter when you invoke PlotGrid (as in my previous example) you'll see the "level" (price) as a label in the right axis scale.
@snbarma, actually my previous image was misleading. I apologize.
The "label" when using PlotGrid() is displayed only as an extra number (note the 167 value position without decimals) in the right axis scale, using the same color of the other numbers of the scale.
(In this example, I invoked it with a 167.27 value).
When other (plot) labels are near/over it may not be visible.
So, if you prefer to see a full label (with the same color of the line) you can revert to using Plot instead of PlotGrid: