
-----------------------------------
CaptainKirk
Tue Jun 22, 2010 6:01 am


-----------------------------------
Here is a Great Script to do this.  Enjoy.

input showOnlyToday = YES;
input percent_above = 0.2;
input show_bars_divisable_by = 2;
input location = {default above, below};
input show_range_bubbles = NO;
input show_odd_bars_above = NO;
input maxbarnum = 81;
input Risk_Ticks_Add = 2;

def ticks_below = if TickSize()== 0.25 then 6 Else 10; #points_below/ticksize();
#def ticks_below = 5;

def  Delta = Risk_Ticks_Add*ticksize();
# if TickSize()== 0.25 then Risk_ticks_Add else 

def yyyyMmDd = getYyyyMmDd();
def session_duration_bars = (regularTradingEnd(yyyyMmDd) - regularTradingStart(yyyyMmDd)) / getAggregationPeriod();
# the above is useless because we cant use it!

#def T = lowest(low[ - session_duration_bars], session_duration_bars);

def  lookback = if !IsNan(low[-81]) Then lowest(low[-81],81) Else 
                if !IsNan(low[-80]) Then lowest(low[-80],80) Else 
                if !IsNan(low[-26]) Then lowest(low[-26],26) Else 
                                         lowest(low[-79],79);
              
def percent;
def price;
def direction;

switch(location){
case above:
    direction = yes;
    price = high;
    percent = 1 + percent_above/100;


case below:
    direction = no;
    price = low;
    percent = 1 - percent_above/100;
}


def day = getDay();
def lastDay = getLastDay();
def isToday = day == lastday;
def firstBar = if (day[1] != day, day - 1, 0);
def shouldPlot = if(showOnlyToday and isToday, 1, if(!showOnlyToday, 1, 0));


rec count = if shouldPlot then if firstbar then 1 else count[1]+1 else 0;
rec lowval = if firstbar then lookback else lowval[1];
## lowest(low[-79],80) 
#plot llow = lowval;
def barDivByTwo = count/show_bars_divisable_by == round(count/show_bars_divisable_by, 0);
def barDivByFour = count/(2*show_bars_divisable_by) == round(count/(2*show_bars_divisable_by), 0);

def blankBar = isNaN(close[-1]);

addchartbubble(barDivByTwo and !blankbar and shouldPlot and (count<maxbarnum),lowval, 
concat(count, ""), 
#concat(tickSize(), ""),
color.blue, direction);

addchartbubble(Show_Range_Bubbles and barDivByTwo and !blankbar and shouldPlot and (count<maxbarnum),lowval-(ticks_below*tickSize()), concat("", ((High-Low)+Delta)/TickSize()), color.red, direction);

##addchartbubble(Show_Range_Bubbles and barDivByTwo and barDivByFour and !blankbar and shouldPlot and (count<maxbarnum),lowval-(2*ticks_below*tickValue()), concat("", ((High-Low)+Delta)/TickSize()), color.red, direction);
