Thursday, September 8, 2011

sdi_yesterrange - overlay yesterday's price range on today's intraday chart

The high and low of the previous day are often reversal levels. The trading action tends to be choppy when price action stays inside of yesterdays range; outside the tendancy is toward's trending. sdi_yesterrange helps the intraday trader stay vigilent about yesterday's high and low by displaying a clouded range representing yesterdays price action on the intraday chart as shown below:


SPY with sdi_yesterrange.
By enabling the sideline parameter the range cloud can be thrown off to the right-extension area where it won't crowd your chart drawings. Also, the range cloud will automatically hide when you increase your aggregation period to DAY or larger.

Here's the code:
#########################
# sdi_yesterRange -
#hint: Display yesterdays range as a clouded area. rev: 1.0.0
# source: smallDogInvestor.blogspot.com
# author: allen everhart
# date: Sep 8, 2011
# copylefts reserved. 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 upper;
#hint sideline: Set to Yes to display the range cloud in right extension area; No to display range cloud overlaying main chart.
input sideline = no ;

def _ph = high(period="DAY")[1];
plot ph =
  if isNaN(close) && !sideline then
    double.NaN
  else if !isnan(close) && sideline then
    double.NaN
  else
    _ph
;
def _pl = low(period="DAY")[1];
plot pl =
  if isNaN(close) && !sideline then
    double.NaN   
  else if !isNaN(close)&& sideline then
    double.NaN
  else
    _pl
;
addCloud(ph,pl,color.RED);
ph.setdefaultColor(color.RED);
pl.setdefaultColor(color.RED);
ph.setStyle(curve.lonG_DASH);
pl.setstyle(curve.LONG_DASH);

def agHide =  if getAggregationPeriod() >= aggregationPeriod.DAY then
    yes
 else
   no
;
ph.sethiding(aghide);
pl.sethiding(aghide);
#########################################

No comments:

Post a Comment