Afl squishes candlesticks - help please

Hi all,
I am trying to draw previous day high and low on my chart, but it squishes the candlesticks. How do I fix this? Thanks for your help.

_SECTION_BEGIN(" !PDHPDLPDC");

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, -0 );
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());

upbarcolor=ParamColor(“UPbar Color”, colorPaleGreen);
wickcolor=ParamColor(“wick Color”, colorLightGrey);
PDH_Color = ParamColor(“PDH Color”, colorDarkGrey);
PDH_Style = ParamStyle(“PDH Style”, styleThick,styleNoRescale);

PDL_Color = ParamColor(“PDL Color”, colorDarkGrey);
PDL_Style = ParamStyle(“PDL Style”, styleThick,styleNoRescale);

PDO_Color = ParamColor(“PDO Color”, colorLightBlue);
PDO_Style = ParamStyle(“PDO Style”, styleLine,styleNoRescale);

PDC_Color = ParamColor(“PDC Color”, colorRose);
PDC_Style = ParamStyle(“PDC Style”, styleLine,styleNoRescale);
downbarcolor=ParamColor(“Downbar Color”, colorRose);

showpdhlc=ParamToggle(“show pdhlc”,“No|Yes”);
if(showpdhlc)
{
Plot(PDH,“PDH”,colorBlue,PDH_Style);
Plot(PDL,“PDL”,colorRed,PDL_Style);
Plot(PDO,“PDO”,PDO_Color,PDO_Style);
Plot(PDC,“PDC”,colorDarkRed,PDC_Style);

}

//

_SECTION_END();

Sorry I didnt put the 3 dots, :frowning: unable to edit now.

Please use code tags. The code format changes and produces errors if not following advice given here How to use this site It is not any fun.

As for your code... for example you are using comma before styleNoRescale

Instead use

styleThick | styleNoRescale

That being said since you seem to want to mark bars why not rather using PlotShapes?

Here just marking equal previous daily bar low.

_SECTION_BEGIN( " !PDHPDLPDC" );
PDL_Color = ParamColor( "PDL Color", colorDarkGrey );
showpdhlc = ParamToggle( "show pdhlc", "No|Yes", 1 );

PDL = TimeFrameGetPrice( "L", inDaily, -1 );
PDLcond = PDL==Ref(PDL,-1);

Plot( C, "Price", colorDefault, styleBar );

if( showpdhlc )
{
	PlotShapes( PDLcond * shapeSmallCircle, colorRed, layer = 0, y = L, dist = 0 );
}
_SECTION_END();

11

1 Like

Thanks , what I am looking for is to draw lines on the intraday chart marking the previous day OHLC. Your above above code is placing a dot on every bar for me

My code draws lines like below, but as you can see, the candles get squished.

@sroy I don't look at intraday or even at charts much, so this may not be helpful. But isn't charting the previous day's high and low just a couple of simple lines?

PrevDayH = TimeFrameGetPrice( "H", inDaily, -1 );
PrevDayL = TimeFrameGetPrice( "L", inDaily, -1 );

Plot( PrevDayH, "PrevDayH", colorBlue, styleLine );
Plot( PrevDayL, "PrevDayL", colorRed, styleLine );

Producing a chart like this,
image

1 Like

Thanks for the code, it connects the lines from different days which I don’t want to happen and also is still squishing the candlesticks

I have already told you that you were applying adding styleNoRescale in incorrect way. That is the one and only sole reason for your plotting.

You have to replace comma by

styleLine | styleNoRescale

Then in editor you click Apply button but not Save button (since AFL is applied on chart already). Apply button saves and applies/updates AFL. And in addition in Parameters window you click Reset all. Then activate “Show pdhlc”.

Solved.

2 Likes

@sroy try @fxshrat 's suggestion. But I think you changed what you are looking for, as you wrote you do not want lines from different days? Is that really what you want or is it just to avoid the "squishing"?

I took a stab at charting the lines just on the "last day" but I would experiment with it first as there are probably better ways to do this.

// only Plots previous H/L on last day 

dy = Day();
LastDay = dy == LastValue( Day() );

PrevDayH = IIf( LastDay, TimeFrameGetPrice( "H", inDaily, -1 ), Null );
PrevDayL = IIf( LastDay, TimeFrameGetPrice( "L", inDaily, -1 ), Null );

image

2 Likes

fxshrat,
I tried that edit before posting earlier, but had not applied. It works perfectly now, thanks a ton for your patience and help.