Showing posts with label Custom Quotes. Show all posts
Showing posts with label Custom Quotes. Show all posts

Monday, November 4, 2013

thinkScript: Custom Quote - Strength or Weakness Indicator

Updated 11/04/13

Use this custom quote to highlight stocks showing strength or weakness. '2wk %' will turn green when a stock has a 10% gain in 2 weeks, and turn red for a 10% loss.

Here's how it looks if you use the default black background:

and here's how it looks with the metal background:

Instructions for using this code can be found here: TOS Tip: Custom Quotes


####begin custom quote: 2wk %
#
# Displays the greater up or down price change over the last 2 weeks. 10% or greater = Green. -10% or less = Red.
#
# by John Latrobe
# revised 11/04/13
#
# length is # of trading days. 10 = 2 weeks.
def length = 10;
def price = FundamentalType.CLOSE;
def pricePercentUP = 10.0;
def pricePercentDOWN = -10.0;
#
def priceday = Fundamental(price, period = aggregationPeriod.DAY);
def high = Highest(priceday[1], length);
def low = Lowest(priceday[1], length);
def PcntChHigh = 100 * (priceday/high -1);
def PcntChLow = 100 * (priceday/low -1);
#
plot PercentChg = if(AbsValue(PcntChHigh) >= AbsValue(PcntChLow), Round(PcntChHigh, 2), Round(PcntChlow, 2));
AssignBackgroundColor(if PercentChg >= pricePercentUP then Color.DARK_GREEN else if PercentChg <= pricePercentDOWN then Color.DARK_RED else Color.CURRENT);
PercentChg.AssignValueColor(color.WHITE);
#
#####end quote.

thinkScript: Custom Quote - Daily/Weekly/Monthly Gain or Loss

Updated 11/04/13

Instructions for using this code can be found here: TOS Tip: Custom Quotes

Daily Price change 1 trading day ago:

#####begin custom quote: -Day 1
#
# Shows gain or loss 1 trading day ago for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[1] - priceday[2];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.WHITE);
#
#####end custom quote.

Daily Price change 2 trading days ago:

#####begin custom quote: -Day 2
#
# Shows gain or loss 2 trading days ago for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[2] - priceday[3];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.WHITE);
#
#####end custom quote.

Daily Price change 3 trading days ago:

#####begin custom quote: -Day 3
#
# Shows gain or loss 3 trading days ago for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[3] - priceday[4];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.WHITE);
#
#####end custom quote.

Daily Price change 4 trading days ago:

#####begin custom quote: -Day 4
#
# Shows gain or loss 4 trading days ago for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[4] - priceday[5];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.WHITE);
#
#####end custom quote.

Daily Price change 5 trading days (1 week) ago:

#####begin custom quote: -Day 5
#
# Shows gain or loss 5 trading days ago for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[5] - priceday[6];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.WHITE);
#
#####end custom quote.

Weekly Price change for past week (last 5 trading days):

#####begin custom quote: -Wk 1
#
# Shows gain or loss last 5 trading days for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[1] - priceday[6];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.YELLOW);
#
#####end custom quote.

Weekly Price change 2 weeks ago (trading days -10 thru -6):

#####begin custom quote: -Wk 2
#
# Shows gain or loss for week ending 6 trading days ago (days -10 thru -6) for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[6] - priceday[11];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.YELLOW);
#
#####end custom quote.

Weekly Price change 3 weeks ago (trading days -15 thru -11):

#####begin custom quote: -Wk 3
#
# Shows gain or loss for week ending 11 trading days ago (days -15 thru -11) for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[11] - priceday[16];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.YELLOW);
#
#####end custom quote.

Weekly Price change 4 weeks ago (trading days -20 thru -16):

#####begin custom quote: -Wk 4
#
# Shows gain or loss for week ending 16 trading days ago (days -20 thru -16) for an equity or index.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[16] - priceday[21];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.YELLOW);
#
#####end custom quote.

Monthly Price change for past month (last 21 trading days):

#####begin custom quote: -Mo 1
#
# Shows gain or loss for past month (trading days -21 thru -1) for an equity or index.
# -Mo 2 would use trading days -42 thru -22, etc.
# GREEN = Gain, RED = Loss.
# Use to customize a column in MarketWatch Quotes or Stock Hacker Scans.
# Paste this code into 1 of the 19 custom fields.
#
# by John Latrobe
# revised 11/04/13
#
DEF price = FundamentalType.CLOSE;
DEF priceday = Fundamental(price, Period = AggregationPeriod.DAY);
#
PLOT pricechg = priceday[1] - priceday[22];
AssignBackgroundColor(if pricechg > 0 then Color.DARK_GREEN else if pricechg < 0 then Color.DARK_RED else Color.CURRENT);
pricechg.AssignValueColor(Color.WHITE);
#
#####end custom quote.

Monday, October 14, 2013

TOS Tip: Custom Quotes

Thinkorswim allows 19 custom quotes for use as customized columns. They can be used on the Trade tab, Stock Hacker Scans, and Market Watch Quotes.


In order to use the Custom Quotes you must first be on one of the screens that support them. Right-click on any column heading and select Customize.


Type 'custom' in the search box that says 'Lookup a column...' This will filter out all but your custom columns, even ones that you rename.


Click the scroll icon for the custom column you want to edit. Click on the thinkScript Editor tab and delete any code that exists. Copy the desired code and paste it on line 1. Fill in the Column name to match.


After customizing each column they must be added to the current display set. You'll probably have to remove some of the existing columns to make room. Make sure that you save the Workspace so that your customizations are easily recalled.