Skip to content

Instantly share code, notes, and snippets.

@marketcalls
Last active August 9, 2016 07:03
Show Gist options
  • Save marketcalls/adbdc737e49f259d0b9cde3234a333ce to your computer and use it in GitHub Desktop.
Save marketcalls/adbdc737e49f259d0b9cde3234a333ce to your computer and use it in GitHub Desktop.
Prior Day OHLC - Amibroker AFL Code
//Coded by Rajandran R
//Website www.marketcalls.in
_SECTION_BEGIN("Prior Day OHLC");
PDH_Color = ParamColor("PDH Color", colorgreen);
PDH_Style = ParamStyle("PDH Style", styleThick);
PDL_Color = ParamColor("PDL Color", colorRed);
PDL_Style = ParamStyle("PDL Style", styleThick);
PDO_Color = ParamColor("PDO Color", colororange);
PDO_Style = ParamStyle("PDO Style", styledots);
PDC_Color = ParamColor("PDC Color", colorbrown);
PDC_Style = ParamStyle("PDC Style", styledots);
PDH = TimeFrameGetPrice( "H", inDaily, -1 );
PDH = IIf(PDH!=Ref(PDH,-1),Null,PDH);
PDH_index = ValueWhen(PDH!=Ref(PDH,-1),BarIndex());
PDL = TimeFrameGetPrice( "L", inDaily, -1 );
PDL = IIf(PDL!=Ref(PDL,-1),Null,PDL);
PDL_index = ValueWhen(PDL!=Ref(PDL,-1),BarIndex());
PDO = TimeFrameGetPrice( "O", inDaily, -1 );
PDO = IIf(PDO!=Ref(PDO,-1),Null,PDO);
PDO_index = ValueWhen(PDO!=Ref(PDO,-1),BarIndex());
PDC = TimeFrameGetPrice( "C", inDaily, -1 );
PDC = IIf(PDC!=Ref(PDC,-1),Null,PDC);
PDC_index = ValueWhen(PDC!=Ref(PDC,-1),BarIndex());
Plot(PDH,"PDH",PDH_Color,PDH_Style);
Plot(PDL,"PDL",PDL_Color,PDL_Style);
Plot(PDO,"PDO",PDO_Color,PDO_Style);
Plot(PDC,"PDC",PDC_Color,PDC_Style);
PlotText("Previous Day High",LastValue(PDH_index)+1,LastValue(TimeFrameGetPrice( "H", inDaily, -1 ),True)*1.0001,PDH_Color);
PlotText("Previous Day Low",LastValue(PDL_index)+1,LastValue(TimeFrameGetPrice( "L", inDaily, -1 ),True)*1.0001,PDL_Color);
PlotText("Previous Day Open",LastValue(PDO_index)+1,LastValue(TimeFrameGetPrice( "O", inDaily, -1 ),True)*1.0001,PDO_Color);
PlotText("Previous Day Close",LastValue(PDC_index)+1,LastValue(TimeFrameGetPrice( "C", inDaily, -1 ),True)*1.0001,PDC_Color);
_SECTION_END();
_SECTION_BEGIN("Price");
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment