Hi ! I am so sorry if this is simple or previously answered, I have tried so many combinations and searched google and these forums but can't find any solution.
With the below code I am trying to buy when price cross previous day high and resistance 1 of standard pivot. Problem started when there is a buy signal at the early hour of the day and sell signal later on that same day It is working fine with intraday data. But when I am back testing the code with daily data the exit is delayed buy next exit signal.
_SECTION_BEGIN("Breakout_Day H/L & Pivot");
tick = Param("TICK",.05,1,100,.05);
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);
Buy = Cross(H,BUYLEVEL);
Sell = Cross(SELLLEVEL,L);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = Sell;
Cover = Buy;
Short = ExRem(Short,Cover);
Cover = ExRem(Cover, Short);
BuyPrice = BUYLEVEL;
SellPrice = SELLLEVEL;
ShortPrice = SELLLEVEL;
CoverPrice = BUYLEVEL;
Plot(R1,"R1",ParamColor("R1", colorAqua));
Plot(S1,"S1",ParamColor("S1",colorAqua));
Plot(R2,"R2",ParamColor("R2", colorPink),styleDashed);
Plot(S2,"S2",ParamColor("S2", colorPink),styleDashed);
Plot(R3,"R3",ParamColor("R3", colorGold),styleDashed);
Plot(S3,"S3",ParamColor("S3", colorGold),styleDashed);
Plot(PIVOT,"PIVOT",ParamColor("PIVOT", colorBlue));
Plot(PDH,"Previous Day High",ParamColor("pDayHigh", colorGreen));
Plot(PDL,"Previous Day Low",ParamColor("pDayLow", colorRed));
PlotShapes(Buy*shapeSquare,colorGreen,0,L,-20);
PlotShapes(Buy*shapeSquare,colorGreen,0,L,-30);
PlotShapes(Buy*shapeUpArrow,colorWhite,0,L,-25);
PlotShapes(Short*shapeSquare,colorRed,0,H,20);
PlotShapes(Short*shapeSquare,colorRed,0,H,30);
PlotShapes(Short*shapeDownArrow,colorWhite,0,H,-25);
_SECTION_END();