Saturday, December 31, 2011

ThinkScript Included: Range Bar Projector

I am starting to look into range bars and was just re-listening to Ken Woods range bar talk in the TOS archive. The second time through I picked-up on something he mentions in passing - range bar projectors. That's a simple enough thing for me to "TOS" off so here's the results of this Saturday morning's fun:

/TF with sdi_rbproj and sidelines.

Since range bars are fixed in their price size you can predict where the forming bar might close: either low + size or high - size.

My preference is to plot lines in the right expansion area for this but I realize that some people might not use the right-expansion capability so I have provided a way to realize the projection right at the forming bar as well:

/TF with sdi_rbproj without sidelines

Here's the code:

#############################
# sdi_rbproj
#hint: RangeBarPROJector projects where the forming range-bar will close to the up and downside. Revision 1.0
http://www.smallDogInvestor.com
# author: allen everhart
# date: 12/31/2011
# 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.

input sideline = yes;
#hint sideline: Yes, plots the projections as lines in the right-expansion area, No plots the projections as up/down arrows on top/bottom of the forming bar.

def barSizes = high-low;
def bs=highestAll(barSizes);

rec rbHi =
  if isnaN(close) && sideline then rbHi[1]
  else if !isNaN(close) && isNan(close[-1]) then low+bs 
  else double.NaN;

rec rbLo =
  if isnaN(close) && sideline then rbLo[1]
  else if !isNaN(close) && isNan(close[-1]) then high-bs
  else double.NaN;

plot phi = rbHi;
plot plo = rbLo;
phi.setPaintingStrategy(
  if sideline then PaintingStrategy.LINE
  else PaintingStrategy.ARROW_DOWN
);
plo.setPaintingStrategy(
  if sideline then PaintingStrategy.LINE
  else PaintingStrategy.ARROW_UP
);
phi.setStyle(Curve.MEDIUM_DASH);
plo.setStyle(Curve.MEDIUM_DASH);
phi.setDefaultColor(color.MAGENTA);
plo.setDefaultColor(color.MAGENTA);

###########################################

6 comments:

  1. Watching this work live, I am seeing an issue. The projections are not updating with changes to the high/low of the forming bar. Consider these projections to be "suggestions" of where the bar might close.

    Best.
    -Allen

    ReplyDelete
  2. Each time you detach your chart ThinkDesktop will recalculate the projections. So if you think the projection is out-of-date then detach (the double square icon in the upper right) a new chart copy.

    ReplyDelete
  3. were u able to get the projection to work and update itself without having to detach it, if so how? thanks

    ReplyDelete
    Replies
    1. Alas, no. There does not seem be a way to trigger a study recalculation before the forming bar completes. Triggering a recalc every 5-10 seconds would be a reasonable solution but I don't see any facility for acheiving that. TOS programmers will likely create a rb projector since Woody is agitating for it.

      Delete
  4. Currency specifications for home theater projectors. When you decide to buy a projector on website, compare values for resolution, brightness, contrast ratio and weight, and any optional features. In a projector resolution is the number of pixels that the device produces. projector price in bangladesh

    ReplyDelete
  5. We have the best projectors and cheapest price. We have all kinds of projectors. 3D Projector , HD Projector, LED Projector, Multimedia Projector and Mini Projector. Check out our projector price in bangladesh

    ReplyDelete