top of page

Thinkscripts for TD Ameritrade Thinkorswim Platform

BUY/SELL Volume Bars
Screenshot 2023-07-16 at 7.24.55 PM.png

These green and red volume bars give you a visual representation of who is trading more aggressively, buyers or sellers. Since there is no such thing as more buyers than sellers for any given time period, these volume bars show the ratio of aggressive buyers (green) to aggressive sellers (red).

Aggressive Buyers (Green Volume)

These are market participants who are so bullish they are willing to pay the Ask Price (Market Order) instead of waiting for their order to be filled at the lower Bid Price (Limit Order). These orders show up green on the volume bar.

BID ASK.png
Aggressive Sellers (Red Volume)

These are market participants who are so bearish they are willing to sell at the Bid Price (Market Order) instead of waiting for their order to be executed at the higher Ask Price (Limit Order). These orders show up red on the volume bar.

BID ASK RED.png

Copy and paste this code into your Thinkscript editor:

# Indicator Name: Buy/Sell Volume Bars

# Description: Plot volume bars with corresponding buying and selling volume colors

 

#PreMarket Volume
input startTime = 0400;
input endTime = 0929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];

 

#Volume color coded by amount of volume on up-tick versus amount of volume on down-tick

declare lower;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);

# Selling Volume
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SV.SetDefaultColor(Color.LIGHT_RED);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(5);

# Buying Volume
# Plot BV = Buying;
# Note that Selling + Buying Volume = Volume.
plot BV =  volume;
BV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BV.SetDefaultColor(Color.GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);


#Create an average volume line based on last 50 bars

input length = 20;
plot Vol = volume;
plot VolAvg = Average(volume, length);
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

Previous Day HIGH/LOW/OPEN/CLOSE
Screenshot 2024-04-21 at 3.18.04 PM.png

A large part of my strategy is based around watching how price reacts to intra-day levels. The most important levels I watch every single day are the high, low and closing price from the previous day. For example: If price opens above previous day highs with strength, I might look to open a long position when we retest this level. Or if price cannot hold previous day lows I will short the market to the next critical level. Having these levels drawn out automatically with this Thinkscript ensures I never forget to add them. 

​

Copy and paste this code into your Thinkscript editor:

#

# Indicator Name: Previous Day High/Low/Close
# Description: Plot the previous day high, low, and close. Optional settings included to hide individual plot.

#


declare hide_on_daily;
input aggregationPeriod = AggregationPeriod.DAY;
input Hplot = yes;
input Lplot = yes;
input Cplot = yes;
plot prevHigh = if Hplot then high(period = aggregationPeriod)[1] else double.nan;
plot prevLow = if Lplot then low(period = aggregationPeriod)[1] else double.nan;
plot prevClose = if Cplot then close(period = aggregationPeriod)[1] else double.nan;
prevHigh.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
prevHigh.SetDefaultColor(GetColor(1));
prevLow.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
prevLow.SetDefaultColor(GetColor(0));
prevClose.SetPaintingStrategy(paintingStrategy.HORIZONTAL);
prevClose.SetDefaultColor(GetColor(9));

Pre-Market HIGH / LOW
Screenshot 2024-04-21 at 2.58.01 PM.png

This Thinkscript plots pre-market highs and lows calculated from 4:00 AM ET to 9:30 AM ET. These levels often signify key inflection points created in pre-market which can be used throughout the day as price magnets.  Additionally, these critical levels can act as high liquidity zones where buyers or sellers could take control of price and provide great entry points or levels to place your stop loss.

​

Copy and paste this code into your Thinkscript editor:

#
# Created by Darren Bowman (c) 04/21/2024
# Indicator Name: Pre-Market High/Low
# Description: Plot pre-market high and low calculated from 4:00 AM ET to 9:30 AM ET
#

input aggregationPeriod = AggregationPeriod.DAY;
input showOnlyLastPeriod = yes;

# bars after pm open to daily open
input startTime = 0400;
input endTime = 0929;

def PM_Time = (SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) > 0);


def PM_High = if !PM_Time[1] and PM_Time then high
  else if PM_Time and high > PM_High[1] then high
  else PM_High[1];

def PM_Low = if !PM_Time[1] and PM_Time then low
  else if PM_Time and low < PM_Low[1] then low
  else PM_Low[1];

# Plot only today's pre-market levels
input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;

plot pH = PM_High;
pH.SetLineWeight(3);
pH.SetStyle(Curve.SHORT_DASH);
pH.SetDefaultColor(Color.MAGENTA);
pH.SetPaintingStrategy(PaintingStrategy.LINE);

plot PL = PM_Low;
pL.SetLineWeight(3);
pL.SetStyle(Curve.SHORT_DASH);
pL.SetDefaultColor(Color.MAGENTA);
pL.SetPaintingStrategy(PaintingStrategy.LINE);

EMA Clouds 5, 20 and 50
Screenshot 2024-04-21 at 4.45.39 PM.png

This Thinkscript plots an EMA Cloud between the 5EMA and the 20EMA. The color changes when the slower moving average crosses the faster moving average. I also have included the 50EMA to this Thinkscript as well.

I use the cloud and the 50EMA to let me know what the current trend of the market is. Since I trade a lot of continuation plays, I want to check before I enter a trade if I am fighting the trend of the market. This is a quick tool which prevents me from taking counter trend setups and reduces my losing trades. 

As you use it more you will see how the 20 and the 50EMA act as support and resistance is a strong trending market. These touches to the moving averages coupled with critical levels very often give me great opportunities to re-enter or add to a position and capture a further move.

​

Copy and paste this code into your Thinkscript editor:

#
# Created by Darren Bowman (c) 04/21/2024
# Indicator Name: EMA Clouds
# Description: Plot dynamic EMA cloud around then 9EMA and # 20EMA. Plot 50EMA as support and resistance
#

# Plot dymanic EMA Cloud
input fastMALength = 5;
input fastMAType = AverageType.Exponential;
input slowMALength = 20;
input slowMAType = AverageType.Exponential;
input price = close;

plot fastMA = MovingAverage(fastMAType, price, fastMALength);
plot slowMA = MovingAverage(slowMAType, price, slowMALength);

fastMA.setDefaultColor(Color.Green);
slowMA.setDefaultColor(Color.Yellow);

AddCloud(fastMA, slowMA, Color.Light_Green, Color.Light_Red);

# 50EMA Plot Support / Resistance
input SRlength = 50;
input SRtype = AverageType.Exponential;
plot SMA50 = MovingAverage(SRtype, price, SRlength);
SMA50.SetLineWeight(2);
SMA50.SetDefaultColor(Color.RED);

bottom of page