```
# checkfor2_crossings_00
def na = double.nan;
input avg1_len = 6;
input avg1_type = AverageType.simple;
def line1 = MovingAverage(avg1_type, close, avg1_len);
input avg2_len = 90;
input avg2_type = AverageType.simple;
def line2 = MovingAverage(avg2_type, close, avg2_len);
input avg3_len = 24;
input avg3_type = AverageType.simple;
def line3 = MovingAverage(avg3_type, close, avg3_len);
input show_averages = yes;
plot z1 = if show_averages then line1 else na;
plot z2 = if show_averages then line2 else na;
plot z3 = if show_averages then line3 else na;
z1.setdefaultcolor(getcolor(6));
z2.setdefaultcolor(getcolor(5));
z3.setdefaultcolor(getcolor(3));
addlabel(show_averages , "Line1 " + avg1_len, getcolor(6));
addlabel(show_averages , "Line2 " + avg2_len, getcolor(5));
addlabel(show_averages , "Line3 " + avg3_len, getcolor(3));
input show_bubbles_just_true_rules = yes;
input xbars = 1;
def rule1 = Line1 crosses below line3 and line1 crosses line2;
def rule2 = Line1 crosses above line3 and line1 crosses line2;
def t1 = if !show_bubbles_just_true_rules then 1 else ( rule1 or rule2);
addchartbubble(t1, high*1.006, rule1 + " R1\n" + rule2 + " R2", color.yellow, yes);
# what i think you will need
# check if a 2nd line was crossed within x bars.
def rule1b = Line1 crosses below line3
and (( line1 crosses line2 within xbars bars)
or ( line3 crosses line2 within xbars bars));
def rule2b =
Line1 crosses above line3
and (( line1 crosses line2 within xbars bars )
or ( line3 crosses line2 within xbars bars ));
def t2 = if !show_bubbles_just_true_rules then 1 else ( rule1b or rule2b);
addchartbubble(t2, low*0.994, rule1b + " R1\n" + rule2b + " R2\n" + "within" + "\n" + xbars + " bars", color.magenta, no);
#
```