Friday, August 26, 2011

sdi_open - display open price level of cash market

The sdi_open study displays the open price level of the "cash market" on an intraday chart.  For those of you who do not trade products like futures and currency spots, this distinction may seem a little odd. Futures and spots typically have an official opening time in the early evening hours, US Eastern time, which is not usually a time that creates a price level that you want to watch intraday. Rather, you are more interested in the print created when the US or European stock (or cash) markets open. In any case, sdi_open allows you to specify the open time that is of interest to you, in your locality, but it defaults to 9:30, the open of the US cash market, Eastern US time. As with many of these intraday price level studies that I write, sdi_open can be configured to show the level in the right-extension area by enabling the sideline parameter. Also, the sdi_open level will hide when the aggregation period of the chart is set to DAY or larger. Here is the image and code:

SPX with sdi_open price for 9:30 bar.
# sdi_open
#hint: Shows the opening price as a dotted price level on an intraday chart. rev:1.0.1
#rev 1.0.1 8sep2011 refactored sidebar to sideline
# source:
# author: allen everhart
# date: 27Aug2011
# 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 openTime: Time of the cash market open in your locality. Format:HHMM.
input openTime = 0930 ;
#hint sideline: Yes to show open price level in right extension area. No to show open price level overlaying main chart. 
input sideline = no;

def elapseSecs = secondsFromTime(openTime);
def aggSecs = getAggregationPeriod()/1000;

rec openPrice =
  if elapseSecs<0 && -elapseSecs < aggsecs  then
  else if elapseSecs == 0 then
#plot es = elapseSecs ;

def agHide =  if getAggregationPeriod() >= aggregationPeriod.DAY then

plot op =
  if sideline && !IsNaN(close) then
  else if !sideline && isnaN(close) then
  else if openprice == 0 then
    openPrice ;


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.