How to stop extension of value of an array beyond EOD


I am attaching a code below which is working fine ..Except extension of old values of an array beyond EOD.

I want to remove those unwanted extensions .

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
DN = DateNum();
bi = BarIndex();

ND = dn != Ref( dn, -1 ); // First bar of new day
ED = Day() != Ref(Day(),1); // Last bar of the day
ENDTIME = ValueWhen(ED,TimeNum()); 
NDH = HighestSince(ND,H);
NDL = LowestSince(ND,L);

FBARH = ValueWhen(ND,H);  // First bar High 
FBARL = ValueWhen(ND,L);  // First bar Low 

CLOSEKB = Cross(Close,FBARH); 
CLOSEKS = Cross(FBARL,Close);

CLOSEKB = ExRem(CLOSEKB,ED); // Consider only 1st accurance  after new day 
CLOSEKS = ExRem(CLOSEKS,ED); // Consider only 1st accurance  after new day

BUYH = ValueWhen(CLOSEKB,H); // Marking high of the candle which closed above first bar High
SELLL= ValueWhen(CLOSEKS,L); // Marking low of the candle which closed below first bar Low 

ibendtimeb = ValueWhen(CLOSEKB,TimeNum()); // Starting point for plotting BuyH
ibendtimes = ValueWhen(CLOSEKS,TimeNum());

BUYHF = IIf(TimeNum() > ibendtimeb AND TimeNum() < ENDTIME AND NDH > FBARH ,BUYH,Null);
SELLLF= IIf(TimeNum() > ibendtimes AND TimeNum() < ENDTIME AND NDL < FBARL ,SELLL,Null);

Plot(IIf(BUYHF ,BUYHF ,Null),"BUY ABOVE THIS ",colorGreen,1);
Plot(IIf(SELLF,SELLLF ,Null),"SELL BELOW THIS",colorRed,1);

type or paste code here

extended values

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.