Thursday, January 12, 2012

ThinkScript Included: Display Duration Of Range Bars With sdi_barmin

I've been experimenting with the new TOS range bars. With the slow grind to the upside today I found myself expending more neuronal energy calculating how much time a given range bar took to complete than I cared to. So this was the inspiration for a new companion study for range bars: sdi_barmin

SPY with Range Bars and sdi_barmin.

The lower study shows the duration in minutes of each completed range bar. Unfortunately it is not possible to show time accumulating in the forming bar with the current ThinkScript facilities (there is no access to the now-time from ThinkScript.)

Here's the ThinkScript:

#############################
# sdi_barmin
#hint: Plots the number of minutes a range bar took to complete Revision 1.0
http://www.smallDogInvestor.com
# author: allen everhart
# date: 1/12/2012
# Copyleft! This is free software. That means you are free
# to use or modify it for your own usage but not for resale.
# Help me get the word out about my blog by keeping this header
# in place.

declare lower;
def dif = secondsFromTime(0)[-1] - secondsFromTime(0) ;
def duration =
  if dif >= 0 then dif/60 else (dif+(24*3600))/60
;
plot dur =  if !isnaN(close[-1]) then duration else double.NaN;

dur.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
dur.setLineWeight(5);
#######################################

No comments:

Post a Comment