Plotting lines with breaks

I am trying to plot pivot points which have three resistance and support levels including their corresponding middle points. This will be on intraday charts. Since pivot points uses previous day daily prices for its calculations, there are break in values for every other day.

My AFL code connects the lines for different days when viewing intraday chart.

image

I want a line break for a new day.

Here is my AFL:

// Initial time frame is 15 minutes or other intraday value

TimeFrameSet(inDaily);
p = (High + Low + Close) / 3;
r1 = (2 * p) - Low;
s1 = (2 * p) - High;
r2 = p + (r1 - s1);
s2 = p - (r1 - s1);
r3 = r1 + (High - Low);
s3 = s1 - (High - Low);

r_m1 = p + (r1 - p) / 2;
r_m2 = r1 + (r2 - r1) / 2;
r_m3 = r2 + (r3 - r2) / 2;

s_m1 = s1 + (p - s1) / 2;
s_m2 = s2 + (s1 - s2) / 2;
s_m3 = s3 + (s2 - s3) / 2;
TimeFrameRestore();


p = TimeFrameExpand(p, inDaily);
r1 = TimeFrameExpand(r1, inDaily);
s1 = TimeFrameExpand(s1, inDaily);
r2 = TimeFrameExpand(r2, inDaily);
s2 = TimeFrameExpand(s2, inDaily);
r3 = TimeFrameExpand(r3, inDaily);
s3 = TimeFrameExpand(s3, inDaily);
r_m1 = TimeFrameExpand(r_m1, inDaily);
r_m2 = TimeFrameExpand(r_m2, inDaily);
r_m3 = TimeFrameExpand(r_m3, inDaily);
s_m1 = TimeFrameExpand(s_m1, inDaily);
s_m2 = TimeFrameExpand(s_m2, inDaily);
s_m3 = TimeFrameExpand(s_m3, inDaily);


Plot(p, "Pivot", colorDarkBlue, styleNoLabel | styleNoTitle);
Plot(r1, "R1", colorRed, styleNoLabel | styleNoTitle);
Plot(r2, "R2", colorRed, styleNoLabel | styleNoTitle);
Plot(r3, "R3", colorRed, styleNoLabel | styleNoTitle);
Plot(s1, "S1", colorGreen, styleNoLabel | styleNoTitle);
Plot(s2, "S3", colorGreen, styleNoLabel | styleNoTitle);
Plot(s3, "S3", colorGreen, styleNoLabel | styleNoTitle);
Plot(r_m1, "RM1", colorYellow, styleDots | styleNoLabel | styleNoTitle);
Plot(r_m2, "RM2", colorYellow, styleDots | styleNoLabel | styleNoTitle);
Plot(r_m3, "RM3", colorYellow, styleDots | styleNoLabel | styleNoTitle);
Plot(s_m1, "SM1", colorYellow, styleDots | styleNoLabel | styleNoTitle);
Plot(s_m2, "SM3", colorYellow, styleDots | styleNoLabel | styleNoTitle);
Plot(s_m3, "SM3", colorYellow, styleDots | styleNoLabel | styleNoTitle);

try PlotOHLC() instead of Plot()

Tried it, same results as before.

SetTradeDelays(0, 0, 0, 0);
SetOption("InitialEquity", 200000);
SetOption("ActivateStopsImmediately", True);
SetOption("AllowSameBarExit", False);
TickSize = 0.05;


TimeFrameSet(inDaily);
p = (High + Low + Close) / 3;
r1 = (2 * p) - Low;
s1 = (2 * p) - High;
r2 = p + (r1 - s1);
s2 = p - (r1 - s1);
r3 = r1 + (High - Low);
s3 = s1 - (High - Low);

r_m1 = p + (r1 - p) / 2;
r_m2 = r1 + (r2 - r1) / 2;
r_m3 = r2 + (r3 - r2) / 2;

s_m1 = s1 + (p - s1) / 2;
s_m2 = s2 + (s1 - s2) / 2;
s_m3 = s3 + (s2 - s3) / 2;
TimeFrameRestore();


p = TimeFrameExpand(p, inDaily);
r1 = TimeFrameExpand(r1, inDaily);
s1 = TimeFrameExpand(s1, inDaily);
r2 = TimeFrameExpand(r2, inDaily);
s2 = TimeFrameExpand(s2, inDaily);
r3 = TimeFrameExpand(r3, inDaily);
s3 = TimeFrameExpand(s3, inDaily);
r_m1 = TimeFrameExpand(r_m1, inDaily);
r_m2 = TimeFrameExpand(r_m2, inDaily);
r_m3 = TimeFrameExpand(r_m3, inDaily);
s_m1 = TimeFrameExpand(s_m1, inDaily);
s_m2 = TimeFrameExpand(s_m2, inDaily);
s_m3 = TimeFrameExpand(s_m3, inDaily);


PlotOHLC(p, p, p, p, "Pivot", colorDarkBlue, styleLine | styleNoLabel | styleNoTitle);
PlotOHLC(r1, r1, r1, r1, "R1", colorRed, styleLine | styleNoLabel | styleNoTitle);
PlotOHLC(r2, r2, r2, r2, "R2", colorRed, styleLine | styleNoLabel | styleNoTitle);
PlotOHLC(r3, r3, r3, r3, "R3", colorRed, styleLine | styleNoLabel | styleNoTitle);
PlotOHLC(s1, s1, s1, s1, "S1", colorGreen, styleLine | styleNoLabel | styleNoTitle);
PlotOHLC(s2, s2, s2, s2, "S3", colorGreen, styleLine | styleNoLabel | styleNoTitle);
PlotOHLC(s3, s3, s3, s3, "S3", colorGreen, styleLine | styleNoLabel | styleNoTitle);
PlotOHLC(r_m1, r_m1, r_m1, r_m1, "RM1", colorOrange, styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(r_m2, r_m2, r_m2, r_m2, "RM2", colorOrange, styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(r_m3, r_m3, r_m3, r_m3, "RM3", colorOrange, styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(s_m1, s_m1, s_m1, s_m1, "SM1", colorLime, styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(s_m2, s_m2, s_m2, s_m2, "SM3", colorLime, styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(s_m3, s_m3, s_m3, s_m3, "SM3", colorLime, styleDashed  | styleNoLabel | styleNoTitle);


Buy = C > r1 OR C > r2 OR C > r3 OR C > r_m1 OR C > r_m2 OR C > r_m3;
Short = C < s1 OR C < s2 OR C < s3 OR C < s_m1 OR C < s_m2 OR C < r_m3;

Buy = ExRem(Buy, Short);
Short = ExRem(Short, Buy);

for (i = 0; i < BarCount; i++) {
	
}


but why are you using styleLine ?

you should use styleCandle here

1 Like

It is better now. Although it makes all the lines dotted but I wanted only the mid lines dotted. This is doable, though.

As I understand, if I want the lines my way, I will have to use low-level graphics functions?

Thanks anyways though.

For reference, here is my code:

SetTradeDelays(0, 0, 0, 0);
SetOption("InitialEquity", 200000);
SetOption("ActivateStopsImmediately", True);
SetOption("AllowSameBarExit", False);
TickSize = 0.05;


TimeFrameSet(inDaily);
p = (High + Low + Close) / 3;
r1 = (2 * p) - Low;
s1 = (2 * p) - High;
r2 = p + (r1 - s1);
s2 = p - (r1 - s1);
r3 = r1 + (High - Low);
s3 = s1 - (High - Low);

r_m1 = p + (r1 - p) / 2;
r_m2 = r1 + (r2 - r1) / 2;
r_m3 = r2 + (r3 - r2) / 2;

s_m1 = s1 + (p - s1) / 2;
s_m2 = s2 + (s1 - s2) / 2;
s_m3 = s3 + (s2 - s3) / 2;
TimeFrameRestore();


p = TimeFrameExpand(p, inDaily);
r1 = TimeFrameExpand(r1, inDaily);
s1 = TimeFrameExpand(s1, inDaily);
r2 = TimeFrameExpand(r2, inDaily);
s2 = TimeFrameExpand(s2, inDaily);
r3 = TimeFrameExpand(r3, inDaily);
s3 = TimeFrameExpand(s3, inDaily);
r_m1 = TimeFrameExpand(r_m1, inDaily);
r_m2 = TimeFrameExpand(r_m2, inDaily);
r_m3 = TimeFrameExpand(r_m3, inDaily);
s_m1 = TimeFrameExpand(s_m1, inDaily);
s_m2 = TimeFrameExpand(s_m2, inDaily);
s_m3 = TimeFrameExpand(s_m3, inDaily);


PlotOHLC(p, p, p, p, "Pivot", colorDarkBlue, styleCandle | styleNoLabel | styleNoTitle);
PlotOHLC(r1, r1, r1, r1, "R1", colorRed, styleCandle | styleNoLabel | styleNoTitle);
PlotOHLC(r2, r2, r2, r2, "R2", colorRed, styleCandle | styleNoLabel | styleNoTitle);
PlotOHLC(r3, r3, r3, r3, "R3", colorRed, styleCandle | styleNoLabel | styleNoTitle);
PlotOHLC(s1, s1, s1, s1, "S1", colorGreen, styleCandle | styleNoLabel | styleNoTitle);
PlotOHLC(s2, s2, s2, s2, "S3", colorGreen, styleCandle | styleNoLabel | styleNoTitle);
PlotOHLC(s3, s3, s3, s3, "S3", colorGreen, styleCandle | styleNoLabel | styleNoTitle);
PlotOHLC(r_m1, r_m1, r_m1, r_m1, "RM1", colorYellow, styleCandle | styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(r_m2, r_m2, r_m2, r_m2, "RM2", colorYellow, styleCandle | styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(r_m3, r_m3, r_m3, r_m3, "RM3", colorYellow, styleCandle | styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(s_m1, s_m1, s_m1, s_m1, "SM1", colorYellow, styleCandle | styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(s_m2, s_m2, s_m2, s_m2, "SM3", colorYellow, styleCandle | styleDashed  | styleNoLabel | styleNoTitle);
PlotOHLC(s_m3, s_m3, s_m3, s_m3, "SM3", colorYellow, styleCandle | styleDashed  | styleNoLabel | styleNoTitle);

image

This thread will be closed until poster @xterminator verifies license.

To post on forum you have to purchase AmiBroker license
Only users with "License verified" badge are allowed to post.
So before posting, make sure you verify your license as explained here:

2 Likes