Scan for Price Above/Below yesterdays High/Low

#2
_SECTION_BEGIN("Previous day high check");
SetChartBkColor(ParamColor("Outer panel color ",colorLightGrey)); // color of outer border
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g,Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +"{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", colorBlack, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

Session= TimeNum() >= 092500 AND TimeNum() <= 093000;

prevdayhigh[0] = 0;
prevdaylow[0] = 0;

prevdayhigh = TimeFrameGetPrice( "H", inDaily, -1 );
prevdaylow = TimeFrameGetPrice( "L", inDaily, -1 );

Buy = iif((close>prevdayhigh)&&Session,1,0);
Sell = iif((close < prevdaylow)&&Session,1,0);

//Buy = ExRem(Buy,Sell);
//Sell = ExRem(Sell,Buy);

PlotShapes(IIf(Buy, shapestar, shapeNone),colorGreen,0,L,Offset=-45 );
PlotShapes(IIf(Sell, shapestar, shapeNone),colorRed,0,H,Offset=-45);
_SECTION_END();
 
#3
_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
_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", colorBrightGreen ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("PreDay HLC");
function CDL( array )
{
doy = DayOfYear();
Lastdoy = doy == LastValue( doy );
Dayline = array * Lastdoy;

return IIf( Dayline, Dayline, Null );
}

//TIME FRAME CALCULATION
H1 = TimeFrameGetPrice( "H", inDaily, -1 ); // yesterdays high
L1 = TimeFrameGetPrice( "L", inDaily, -1 ); // low
C1 = TimeFrameGetPrice( "C", inDaily, -1 ); // close
O1 = TimeFrameGetPrice( "O", inDaily, -1 ); // close
DayO = TimeFrameGetPrice( "-1", inDaily ); // current day open

//PLOTS
Plot( cdl( H1 ), "", colorWhite, styleLine + styleDashed + styleNoRescale);
Plot( cdl( L1 ), "", colorWhite, styleLine + styleDashed + styleNoRescale);
_SECTION_END();

Buy = C > H1;
Sell = C<L1;
Filter =Buy OR Sell ;
SetOption("NoDefaultColumns", True );
AddTextColumn( Name(), "Symbol",1.0, colorDefault,colorDefault, 80);
AddColumn( DateTime(), "Date", formatDateTime, colorDefault,colorDefault, 70 );
AddColumn(C, "CMP", 1.2, colorDefault,colorDefault, 80);
AddTextColumn( WriteIf( Buy, "Previous Day High Break", "Previous Day Low Break"), "Trade", 1.0, colorDefault,colorDefault,50 );
 

Similar threads