I am trying to fetch value from bars that are towards the right of the chart. That means if I am in bar number 10 then I want to fetch the value in bar number 11 and onwards. For example I want to fetch the low of the bar that has high equal to 199.7. I use valueWhen with the third parameter set to 0. It works in most places but fails in others. The code is as below. I have attached the data file of SBI here https://easyupload.io/ezyua0. You can try it in 1 minute timeframe. I have checked in exploration also. for the first instance it is returning null. You can see the trace in pic below. The bar with the yellow dot has high equal to 199.7. It was expected that valueWhen returns low of that bar but instead it returned null. Why?
But later in the chart it starts working. see the picture below.
But later in the chart it starts working. see the picture below.
Code:
_TRACE("!CLEAR!");
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}} ", O, H, L, C, SelectedValue( ROC( C, 1 ))) );
PlotOHLC( O, H, L, C, "Traded", colorRed, styleBar , Null, Null, 0, 1, 1);
_SECTION_END();
h1=199.7;
cond=H==h1;
val2=ValueWhen(cond, L, 0);
_TRACE("val2="+val2);
PlotShapes( IIF( cond, shapeSmallCircle, shapeNone), coloryellow, 0, L-ATR(5)); //
Filter=1;
AddColumn(ValueWhen(cond, L, 0), "ValueWhen(H=="+h1+", L, 0)");
Last edited: