#//MaybeThatGuy
#indicator("Price Percentage Breakout by Time Period", shorttitle = "P%BTP", overlay=true)
# converted by Sam4Cok@Samer800 - 06/2023
#//inputs
input BarColor = yes;
input lookback = 20; # "Lookback Period"
input createLabel = no;#(false, "Create Alerts")
#//calculate percentage change
def bullish = (close>=open);
def bearish = (close<open);
def bullishprice;# = false
def bearishprice;# = false
def percentchange = AbsValue(close - open) / open * 100;
def highpercent = highest(percentchange, lookback);
def truepercent = (close - open) / open * 100;
if percentchange >= highpercent and bullish {
bullishprice = yes;
bearishprice = no;
} else
if percentchange >= highpercent and bearish {
bearishprice = yes;
bullishprice = no;
} else {
bullishprice = no;
bearishprice = no;
}
#// Plot volume indication
AssignPriceColor(if !BarColor then Color.CURRENT else
if bullishprice then Color.CYAN else
if bearishprice then Color.MAGENTA else Color.CURRENT);
#//create alert
def bullAler = createLabel and bullishprice and !bullishprice[1];
def bearAler = createLabel and bearishprice and !bearishprice[1];
AddChartBubble(bullAler, low, "Bullish", Color.GREEN, no);
AddChartBubble(bearAler, high, "Bearish", Color.RED, yes);
#-- END of CODE