# stochfast_midrng_00
input bars_back = 20;
input over_bought = 80;
input over_sold = 20;
def stch_fast_k = reference StochasticFast(over_bought, over_sold).FastK;
def stch_fast_d = reference StochasticFast(over_bought, over_sold).Fastd;
def above_ob = if (stch_fast_k > over_bought) then 1 else 0;
def ispastx_above_ob = if sum(above_ob[1], bars_back) > 0 then 1 else 0;
def below_os = if (stch_fast_k < over_sold) then 1 else 0;
def ispastx_below_os = if sum(below_os[1], bars_back) > 0 then 1 else 0;
def isbetween_obos = if (ispastx_above_ob == 0 and ispastx_below_os == 0) then 1 else 0;
def obcross = if (stch_fast_k crosses over_bought) then 1 else 0;
addlabel(1, "StochasticFast - K " + stch_fast_k, color.yellow);
addlabel(1, ( if ispastx_above_ob then "True" else "False") + " ,fastK was above OB, in past " + bars_back + " bars" , color.yellow);
addlabel(1, ( if ispastx_below_os then "True" else "False") + " ,fastK was below OS, in past " + bars_back + " bars" , color.yellow);
addlabel(1, ( if isbetween_obos then "True" else "False") + " ,fastK stayed between OB and OS, in past " + bars_back + " bars" , color.yellow);
addlabel(1, "StochasticFast - K " + stch_fast_k, color.yellow);
# crossed OB and past x bars were in the middle rng
def cond1 = if (isbetween_obos and obcross) then 1 else 0;
addlabel(cond1, "crossed OB and past x bars were in the middle rng", color.green);
#