How not to plot connecting stair lines

Hi,
please see attached image: I don't want to plot line part circled in red, that connects stairs steps.

Code is as follow:

PreviousHigh = TimeFrameGetPrice( "H", inDaily, -1 ); 

Plot( PreviousHigh, "PreviousHigh", colorGreen, styleDashed|StyleNoRescale   );

stairs
What's the proper way to achieve this?

One way of writing it would be:

NewDay = Day() != Ref( Day(), -1 );

PreviousHigh = TimeFrameGetPrice( "H", inDaily, -1 );
PreviousHigh = IIf( NewDay, Null, PreviousHigh );

Plot( PreviousHigh, "PreviousHigh", colorGreen, styleNoTitle );
Plot( PreviousHigh, "PreviousHigh", colorGreen, styleLine, Null, Null, -1 );
1 Like

Thanks, I got the logic.
This works but only on some days... I think after a weekend only.

I think it's because

NewDay = Day() != Ref( Day(), -1 );

Doesn't consider start of day as how it is set in session (contrarily to TimeFrameGetPrice that respects sessions as set in db) but is considering a new day as first minute after 0000 and not first one after night session start which is at in my case (Index Futures ETH) at 1800 on previous day (a day in this case starts at 1800 previous day, and ends at 1700 next day).

Will try to figure this out and report.

Another way would be:

bi = BarIndex();
DayFirstBi = TimeFrameExpand( TimeFrameCompress( bi, inDaily, compressOpen ), inDaily, expandFirst );
//Just FYI
//DayLastBi = TimeFrameExpand( TimeFrameCompress( bi, inDaily, compressLast ), inDaily, expandFirst );

PreviousHigh = TimeFrameGetPrice( "H", inDaily, -1 );
PreviousHigh = IIf( bi == DayFirstBi, Null, PreviousHigh );

Plot( PreviousHigh, "PreviousHigh", colorGreen, styleNoTitle );
Plot( PreviousHigh, "PreviousHigh", colorGreen, styleLine, Null, Null, -1 );
1 Like

Excellent... will need some time to get used to these unusual timecompression features.

Nothing is unusual, everything in AmiBroker is for a purpose. It is very flexible and gives user all the freedom to express. Would urge you to thoroughly read and experiment with the examples shown here - Multiple Time Frame support in AFL.

thanks for link.
I meant "unusual" when coming from another platform.
It sure is a practical way to work with time series.

You might also want to look at PlotShapes(), which doesn't try to plot continuous lines.

There are many ways to skin a cat. Probably shortest way to achieve what you want is this (3 lines plus 1 line for standard candlestick chart):

ph = TimeFrameGetPrice( "H", inDaily, -1 );

dph = IIf( ph != Ref( ph , -1 ), Null, ph ); // replace discontinuity with Null
Plot( dph , "PreviousHigh", colorGreen );

Plot( C, "Price", colorDefault, styleCandle );`

Generally Plot() by nature draws connected lines. Any discontinuities should be marked with Null if you want a "hole" in chart.

4 Likes