#lines_multiples_of_baselevel
#https://usethinkscript.com/threads/alert-when-the-price-of-option-is-at-4x-5x-7x-9x-11x-times-the-premium-collected.21722/
#Alert when the price of option is at 4x, 5x, 7x, 9x, 11x times the premium collected
def na = double.nan;
def bn = barnumber();
input premium_price = 0.8;
def prem = if premium_price > 0 then 1 else 0;
input factor1 = 4.0;
input factor2 = 5.0;
input factor3 = 7.0;
input factor4 = 9.0;
input factor5 = 11.0;
input hiprice = high;
def line1 = if bn == 1 then 0
else if line1[1] > 0 then line1[1]
else if isnan(close) then (premium_price * factor1)
else if (hiprice > (premium_price * factor1)) then (premium_price * factor1)
else line1[1];
def line2 = if bn == 1 then 0
else if line2[1] > 0 then line2[1]
else if isnan(close) then (premium_price * factor2)
else if (hiprice > (premium_price * factor2)) then (premium_price * factor2)
else line2[1];
def line3 = if bn == 1 then 0
else if line3[1] > 0 then line3[1]
else if isnan(close) then (premium_price * factor3)
else if (hiprice > (premium_price * factor3)) then (premium_price * factor3)
else line3[1];
def line4 = if bn == 1 then 0
else if line4[1] > 0 then line4[1]
else if isnan(close) then (premium_price * factor4)
else if (hiprice > (premium_price * factor4)) then (premium_price * factor4)
else line4[1];
def line5 = if bn == 1 then 0
else if line5[1] > 0 then line5[1]
else if isnan(close) then (premium_price * factor5)
else if (hiprice > (premium_price * factor5)) then (premium_price * factor5)
else line5[1];
plot lvl0 = if prem then premium_price else na;
lvl0.SetDefaultColor(Color.yellow);
#lvl0.setlineweight(0);
#lvl0.hidebubble();
plot lvl1 = if prem and line1 > 0 then line1 else na;
lvl1.SetDefaultColor(Color.cyan);
#lvl1.setlineweight(0);
#lvl1.hidebubble();
plot lvl2 = if prem and line2 > 0 then line2 else na;
lvl2.SetDefaultColor(Color.cyan);
#lvl2.hidebubble();
plot lvl3 = if prem and line3 > 0 then line3 else na;
lvl3.SetDefaultColor(Color.cyan);
#lvl3.hidebubble();
plot lvl4 = if prem and line4 > 0 then line4 else na;
lvl4.SetDefaultColor(Color.cyan);
#lvl4.hidebubble();
plot lvl5 = if prem and line5 > 0 then line5 else na;
lvl5.SetDefaultColor(Color.cyan);
#lvl5.hidebubble();
input alerts_on = yes;
alert(alerts_on and (line1 > 0 and line1[1] == 0), "Level 1 " + line1, alert.BAR, sound.DING);
alert(alerts_on and (line2 > 0 and line2[1] == 0), "Level 2 " + line2, alert.BAR, sound.DING);
alert(alerts_on and (line3 > 0 and line3[1] == 0), "Level 3 " + line3, alert.BAR, sound.DING);
alert(alerts_on and (line4 > 0 and line4[1] == 0), "Level 4 " + line4, alert.BAR, sound.DING);
alert(alerts_on and (line5 > 0 and line5[1] == 0), "Level 5 " + line5, alert.BAR, sound.DING);
#