#~~~~~~~~~~~~~~~~~~~~~~~~ begin bubble signals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input show_bubbles = yes;
input Buy_Sell_Bubble_Data = {default current, historical};
def short;
def long;
switch (Buy_Sell_Bubble_Data)
{
case historical:
short = hh;
long = ll;
case current:
short = hh_;
long = ll_;
}
def SOCB1 = Round((Max(PrevL, short - (hR * R_Mult))) / ts, 0) * ts;
def LOCA1 = Round((Min(PrevH, long + (lR * R_Mult))) / ts, 0) * ts;
def SE = close[1] > SOCB1 and close <= SOCB1;
def LE = close[1] < LOCA1 and close >= LOCA1;
def exitbuy = l < long[1];
def exitsell = h > short[1];
def holdLE = if LE and !LE[1] then 1 else if !exitbuy then holdLE[1] else 0;
def holdSE = if SE and !SE[1] then 1 else if !exitsell then holdSE[1] else 0;
def enter_long = !holdLE[1] and holdLE;
def enter_short = !holdSE[1] and holdSE;
def exit_long = holdLE[1] and !holdLE;
def exit_short = holdSE[1] and !holdSE;
AddChartBubble(if show_bubbles then enter_long else nan, low, "Enter Long", Color.GREEN, 0);
AddChartBubble(if show_bubbles then enter_short else nan, high, "Enter Short", Color.RED, 1);
AddChartBubble(if show_bubbles then exit_long else nan, high, "Exit Long", Color.GREEN, 1);
AddChartBubble(if show_bubbles then exit_short else nan, low, "Exit Short", Color.RED, 0);
#~~~~~~~~~~~~~~~~~~~~~~~~~~ end bubble signals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~