Saturday, June 22, 2013

thinkscript included: percent change from open on watchlist

my daytrader friends asked me to write this custom column thinkscript:
################################
# sdi_pctChgFromOpen: plots the percentage change from the opening price in a way that is appropriate for a watchlist custom column.
#hint: plots the percentage change from the opening price in a way that is appropriate for a watchlist custom column. rev: 1.0 http://www.smallDogInvestor.com 
# author: allen everhart
# date: 22june2013
# 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.
plot x=round(100*((close/open)-1),1);
x.assignValueColor( if x < 0 then color.RED else color.Dark_GREEN);

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

here's what this custom column looks like on a watchlist:
percent change from open custom column

here's how to install a custom column:
  1. right click on the heading of the watchlist and select Customize
  2. scroll down the Available Items list and double left-click on the scroll icon of any Custom column
  3. in the Custom Quote Formula dialogue, select the ThinkScript Editor tab
  4. in the editor textbox replace SimpleMovingAvg() with a cut-n-paste of the thinkscript above. 
  5. in the Column Name entry box select a reasonable column name such as "%ochg" (not too many characters)
  6. click ok
  7. select the "%ochg" column from the Available Items list and click the Add Item button
  8. click ok
Best.
-Allen

8 comments:

  1. Hey, thanks so much for this code it really help my trading. Is there a way you tell me how to edit the default values, for example instead of -1.1 it says -1.10, like the percentage change from yesterdays close? That would be really helpful.
    Thanks in advance.

    ReplyDelete
    Replies
    1. if you want two decimal places then change the expression that reads: "round(100*((close/open)-1),1)" to "round(100*((close/open)-1),2)", where that final '1' is changed to a '2'.

      Delete
  2. This is great! Thanks! Is there anyway to use this as a scan criteria as well? (eg, a custom "% change from open" scan criteria as opposed to the already built-in "% change (from close)" critera?)

    ReplyDelete
    Replies
    1. Yes. Install the script (http://www.smalldoginvestor.com/2011/06/how-to-get-one-of-my-studies.html) and you can access it from the 'custom' selection of 'add study filter'

      Delete
  3. Do you have a script similar to Investors.com percent daily volume above 50 day moving average? I found one that alerts me/displays triangles for average daily volume above 50% daily average volume. Similar to an CANSLIM breakout model trigger.
    #hint type: Type of the volume moving average: simple or exponential
    input type = { default SMP } ;
    #hint length: Number of bars to use for volume moving average.
    input length = 50 ;
    #hint hotPct: Percent over volume moving average to trigger decorations.
    input hotPct = 50.0 ;

    def ma =
    if type == type.SMP then
    simpleMovingAvg(Volume, length)
    else
    movAvgExponential(vOlume, length)
    ;

    plot hv =
    if 100 * ((volume / ma) - 1) >= hotPct then
    ma
    else
    double.NaN
    ;

    hv.SetDefaultColor( color.CYAN);
    hv.SetLineWeight(1) ;
    hv.setPaintingStrategy( PaintingStrategy.LINE_VS_TRIANGLES);

    ReplyDelete
    Replies
    1. I don't know to laugh or cry - you have quoted back to me here an early version of my sdi_hivol (http://www.smalldoginvestor.com/2011/08/sdihivol-decorate-volume-moving-average.html)with all the comments stripped out. I guess that was to be expected.

      To answer your question - I have on my watchlist a custom column I call 'vpc' - Volume Percent Change. This the calculation that Bill O'Neal describes somewhere. The code is trivial and I never released it. But since you asked here 'tis: round(100*volume/average(data=volume, length=50),0)

      Delete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Hi, Allen,

    I installed the column as detailed above and it works fine. Your guidance most useful and greatly appreciated, thanks so much and have a good day.

    ReplyDelete