i am trying to write the code when price cross previous day high go long and scale in when in subsequent day price also fulfill the same criteria of crossing the previous day high. When price cross previous day low exit all. Chart display showing all the signal but backtest only considering first entry, subsequent is not ignored in back test. cant find the mistake i have made. please help. thank you.

```
_SECTION_BEGIN("Breakout_Day H/L & Pivot");
psz =Param("PositionSize",75,1,500000);
pick = Param("TICK",1,1,100,.05);
tick = .05*pick;
SetPositionSize( psz, spsShares );
isEndofDay = Nz(TimeFrameExpand(1,inDaily,expandPoint));
newday = Day() != Ref(Day(),-1);
PDC= TimeFrameGetPrice("C",inDaily,-1);
PDH = TimeFrameGetPrice("H",inDaily,-1);
PDL = TimeFrameGetPrice("L",inDaily,-1);
PIVOT = (PDC+PDH+PDL)/3;
R1= 2*PIVOT - PDL;
S1 = 2*PIVOT - PDH;
R2 = PIVOT +(PDH-PDL);
S2 = PIVOT -(PDH-PDL);
R3 = PDH + (2*(PIVOT-PDL));
S3 = PDL - (2*(PDH-PIVOT));
BUYLEVEL= (Max(PDH,R1)+tick);
SELLLEVEL = (Min(PDL,S1)-tick);
Buy1 = Cross(H,BUYLEVEL);
Sell1 = Cross(SELLLEVEL,L);
buy2 = newday AND buy1;
InitialBuy = buy1 ;
InitialBuy = ExRem(InitialBuy,isEndofDay);
SubsequentBuy = buy2;
SubsequentBuy = ExRem(SubsequentBuy,isEndofDay);
Buy = IIf(InitialBuy,1,
IIf(SubsequentBuy, sigScaleIn,0));
Sell = sell1;
Sell = ExRem(Sell,Buy);
BuyPrice = buylevel;
SellPrice = SELLLEVEL;
Plot(R1,"R1",ParamColor("R1", colorAqua));
Plot(S1,"S1",ParamColor("S1",colorAqua));
Plot(PDH,"Previous Day High",ParamColor("pDayHigh", colorGreen));
Plot(PDL,"Previous Day Low",ParamColor("pDayLow", colorRed));
PlotShapes(InitialBuy*shapeSquare,colorGreen,0,L,-20);
PlotShapes(InitialBuy*shapeSquare,colorGreen,0,L,-30);
PlotShapes(InitialBuy*shapeUpArrow,colorWhite,0,L,-25);
PlotShapes(SubsequentBuy*shapeUpArrow,colorWhite,0,L,-25);
PlotShapes(Sell*shapeDownArrow,colorPink,0,H,-25);
_SECTION_END();
```