Thursday, June 18, 2015

thinkscript included: sdi_afterhours - display pre- and post-market price levels on a daily chart

previously, one needed to switch from a day time-aggregation to an intraday in order to see after-hours pricing. now, with this new chart study, sdi_afterhours, one can see after-hours pricing on a chart with day time-aggregation. here's a picture of this:
spy with after-hours pricing
the blue level shows where after-hours trading has moved price. this includes pre-market pricing. when the pre- or post-market session ends the after-hours price hides.

caveat: the stock must have options trading on it for afterhours to display. 

here's the code:


################################
# sdi_afterhours
input threshold=.10;
#hint: Displays after-hours pricing rev: 1.0.0 from  http://www.smallDogInvestor.com 
def isLastBar= isnan(close) && !isnan(close[1]);
# author: allen everhart
# date: 18june2015
def pc=probabilityOfExpiringCone();
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale or reprinting. 
# Help me get the word out about my blog by keeping notices of origin in place.
#hint threshold: the minimum price change to display. rev: 1.0.0 from http://www.smallDogInvestor.com
def change=pc[1]-close[1];
#from http://www.smallDogInvestor.com
plot ah=if isLastBar && close[1]!=pc[1] && absvalue(change)>threshold then pc[1] else double.NaN;
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale or reprinting. 
# Help me get the word out about my blog by keeping notices of origin in place.
ah.setPaintingStrategy(paintingStrategy.HORIZONTAL);
ah.setdefaultColor(color.BLUE);

addChartBubble(isLastBar && absvalue(change)>threshold,ah,concat(if change>0 then "+" else "",asText(change)), color = ah.takeValueColor(), change>0 );

No comments:

Post a Comment