AFL Exploration: Previous Day High Low Breakout

#1
Hi Members,

Below is the AFL plotting lines on previous day High Low values.

I am trying to create an Exploration, scanning all the stocks that close above previous day high and below previous days low.

Please help. Thanks all.

//*********************************************
_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();
 

amitrandive

Well-Known Member
#2
Hi Members,

Below is the AFL plotting lines on previous day High Low values.

I am trying to create an Exploration, scanning all the stocks that close above previous day high and below previous days low.

Please help. Thanks all.

//*********************************************
_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 | Pine + styleDashed + styleNoRescale);
_SECTION_END();
Please use Code(#) for pasting codes.

Code with exploration.
:thumb:
Code:
_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 );
 
#3
@above all this thank u very much for this wonderful post...
I have a query ..which will be an intresting add -on to the above exploration.

Can u experts help to code - an exploration afl to find out - the previous swing high gets cut...in hourly chart.
the requirement is simple.. the previous swing high is a good resistance.. is it possible to know - to develop an afl code- for exlortion purpose to know when this gets cut..?

can u ...?

Thanks again... :) have a great day .. :)
 
#4
========================================================
Buy = C > H1;
Sell = C < L1;

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

Filter = Buy OR Sell ;

AddTextColumn( Name(), "Symbol", 1.0, colorDefault, colorDefault, 80 );
AddColumn( DateTime(), "Date", formatDateTime, colorDefault, colorDefault, 70 );
AddColumn(V, "Volome", 1, IIf(V > Ref(V,-1), colorGreen, colorRed),-1);
AddColumn(((V/EMA(Ref(V,-1),10)))*100, "VolSpike %", 1.2, IIf(V> EMA(Ref(V,-1),10), colorBlue, colorRed),-1);
AddColumn(C, "Close", 1.2, IIf(C > Ref(C,-1), colorGreen, colorRed),-1);
AddTextColumn( WriteIf( Buy, "Previous Day High Break", "Previous Day Low Break" ), "Trade", 1.0, colorDefault, colorDefault, 50 );
========================================================

Just add this exploration code on the above AFL & keep running it every hour/15min against all quotes for recent 1 bar to see result as follows:

1621191362403.png
 

Attachments

Last edited: