Skip to content

Instantly share code, notes, and snippets.

@marketcalls
Last active October 2, 2020 17:32
Show Gist options
  • Save marketcalls/f47771a4bae4cfe53475 to your computer and use it in GitHub Desktop.
Save marketcalls/f47771a4bae4cfe53475 to your computer and use it in GitHub Desktop.
Inside Day Breakout - Trading Strategy - Amibroker AFL Code
//Inside Day breakout strtergy
//Inside Day :-It occurs when the price is trade between the range of yesterdays High Low .i.e todays High is less than yesterdays High AND todays Low is greter than yesterdays Low
//Inside Day breakout :when the Inside Day occurs (on the daily timeframe ) AND price corosses yesterdays High then Buy Signal is generated .Exactly opposite for Shorts .i.e price crosses yesterdays Low AND Inside Day on daily timeframe
//Exit :- at then end of the day or certain % stop loss and target . It can be set in % using backtesting setting
_SECTION_BEGIN("HI LO");
in = Inside();
//on_off_Gap = ParamToggle("Gap ","Off|On",1);
YDayH = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
YDayL = TimeFrameGetPrice("L", inDaily, -1); // low
YDayC = TimeFrameGetPrice("C", inDaily, -1); // close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
////////////////////////////////////////////////////////////////////////////////////////////////////////
Y2DayH = TimeFrameGetPrice("H", inDaily, -2); // day before yesterdays high
Y2DayL = TimeFrameGetPrice("L", inDaily, -2); // day before low
Y2DayC = TimeFrameGetPrice("C", inDaily, -2); // day before close
////////////////////////////////////////////////////////////////////////////////////////////////////////
YHLCO = ParamToggle("Yesterday HI LO CL OP","Show|Hide",0);
if(YHLCO==1)
{
Plot(DayH, "",colorRed,styleDots);
Plot(DayL, "",colorGreen,styleDots);
Plot(DayO, "",colorYellow,styleDots);
}
NewDay = Day()!= Ref(Day(), -1);
EndDay = (Day()!= Ref(Day(), 1));
InsideDay1=YDayH<Y2DayH AND YDayH>Y2DayL AND YDayL>Y2DayL AND YDayL<Y2DayH ;
InsideDay=Ref(InsideDay1,1);
Buy=InsideDay AND H>YDayH ;
Short=InsideDay AND L<YDayL;
SetPositionSize(2,spsShares);
Buy=ExRem(Buy,endday);
Short=ExRem(Short,endday);
Sell= Endday;
Cover= Endday;
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
BuyPrice=ValueWhen(Buy,YDayH);
ShortPrice=ValueWhen(Short,YDayL);
SellPrice=ValueWhen(Sell,C);
CoverPrice=ValueWhen(Cover,C);
//Magfied Market Price
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",940,1,1200,1);
Ver=Param("Vertical Position",12,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorBlack );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+45 );
_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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
Sell1=Cover1=False;
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Sell, shapeStar, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Cover, shapeStar, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
@ampshrini
Copy link

scanner not showing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment