Trade Volume Delta Indicator for ThinkorSwim

anty

New member
I found this Trade Delta indicator that works on timeframes less than 1 day.

Code:
#fl_trade_delta_timeSTUDY.ts

#

#Fil

#Creation date: 8/28/2015

#Edit Log (Date/Editor):

#

#

#

#hint: Plots the <b>ESTIMATED</b> running trade delta (uptick/downtick) per bar on <b>TIME</b> chart

#hint i_reset_aggregations_daily: Toggles whether to reset the trade delta aggregation at the start of each day

#hint i_min_lot_threshold: The threshold for "LARGE" lot bars (a seperate aggregation)



#INPUTS

input i_reset_aggregations_daily = YES;

input i_min_lot_threshold = 50;



#VARIABLES AND LOGIC

def v_reset_aggregations = if GetYYYYMMDD() <> GetYYYYMMDD()[1] then 1 else 0;

def v_trades = tick_count();



def v_uptick = if close > open then v_trades else 0;

def v_downtick = if close < open then -v_trades else 0;

def v_uptick_large = if v_trades >= i_min_lot_threshold and close > open then v_trades else 0;

def v_downtick_large = if v_trades >= i_min_lot_threshold and close < open then -v_trades else 0;



def v_trade_delta = CompoundValue(1, if (i_reset_aggregations_daily and v_reset_aggregations) then v_uptick + v_downtick else v_uptick + v_downtick + v_trade_delta[1], 0);

def v_trade_delta_large = CompoundValue(1, if (i_reset_aggregations_daily and v_reset_aggregations) then v_uptick_large + v_downtick_large else v_uptick_large + v_downtick_large + v_trade_delta_large[1], 0);



#PLOTS

plot p_zero = 0;

plot p_uptick = v_uptick;

plot p_downtick = v_downtick;

plot p_trade_delta = v_trade_delta;

plot p_uptick_large = v_uptick_large;

plot p_downtick_large = v_downtick_large;

plot p_trade_delta_large = v_trade_delta_large;



#PLOT STYLES AND SETTINGS

p_zero.SetDefaultColor(Color.GRAY);

p_uptick.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);

p_uptick.SetDefaultColor(Color.GREEN);

p_downtick.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);

p_downtick.SetDefaultColor(Color.RED);

p_trade_delta.SetPaintingStrategy(PaintingStrategy.LINE);

p_trade_delta.AssignValueColor(if v_trade_delta > 0 then Color.GREEN else if v_trade_delta < 0 then Color.RED else Color.GRAY);

p_uptick_large.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);

p_uptick_large.SetDefaultColor(Color.CYAN);

p_downtick_large.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);

p_downtick_large.SetDefaultColor(Color.MAGENTA);

p_trade_delta_large.SetPaintingStrategy(PaintingStrategy.LINE);

p_trade_delta_large.AssignValueColor(if v_trade_delta_large > 0 then Color.CYAN else if v_trade_delta_large < 0 then Color.MAGENTA else Color.GRAY);

# End Code

Putting that study with the Cumulative Volume Delta indicator is pretty neat. How would I be able to combine these two indicators so that they share the same zero line?

Code:
# Cumulative Volume Delta

#

# The length of the accumulation is user controlled. The cumulative bar

# is the sum of the deltas for the past 10 bars. Change that length to

# 252 (a year in days) then plot something like AAPL. Very interesting.

# LongShort

# 5.7.2019



declare lower;



input length = 10;



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);

def Delt = buying - selling;



plot Delta = Delt;

Delta.AssignValueColor(if Delta > 0 then Color.GREEN else Color.RED);

Delta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

Delta.hide();



plot zero = 0;

zero.setDefaultColor(Color.BLUE);



plot CumulativeVolumeDelta = sum(Delta,length);

CumulativeVolumeDelta.AssignValueColor(if CumulativeVolumeDelta > 0 then Color.GREEN else Color.RED);

CumulativeVolumeDelta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);



# End Code

Could someone combine these so that they share the same zero line?
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I am testing several volume based indicators. Can someone be so kind to combine the following oscillator with several default TOS scripts for me?

The Buy Sell Pressure v2 oscillator would be combined and normalized with the following TOS scripts, with options to turn them on or off preferably. Also, can Buy Sell Pressure v2 be made to work with tick charts?

I would like to see the Chaikin Money Flow, Chaikin Oscillator, Volume Flow Indicator, and Ease of Movement combined with it with options to turn them on or off.

Tomsk already normalized the two Chaikin's for me here https://usethinkscript.com/threads/trade-volume-delta-indicator-for-thinkorswim.524/ at post 16 with Cumulative delta but I like to trade intraday, and it didn't work for intraday timeframes.

Any other useful volume-based scripts would be welcome to add and test, if the coder had any ideas of their own.

Here are the studies I would like combined with the prior linked study up above.
Code:
# Archive Name: Buy Sell Pressure v2 Mobius

# Archive Section: Volume

# Suggested Tos Name: BuySellPressure_v2_Mobius

# Archive Date: 5.06.2018

# Archive Notes: Includes label added by AI







# Buy Sell Pressure

# Mobius

# Mobius at MyTrade

# V01.01.2011



declare lower;



input detrend = 9;

input inertiaS = 26;

input smoothing = 5;



rec BuyV  = if close > close[detrend] then volume else 1;

rec SellV = if close < close[detrend] then -volume else 1;

def BP = (BuyV / (BuyV + SellV));

def SP = (SellV / (SellV + BuyV));





plot Data = Average(Inertia(BP - SP, inertiaS), smoothing);

Data.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

Data.SetLineWeight(3);

Data.DefineColor("Positive and Up", Color.DARK_GREEN);

Data.DefineColor("Positive and Down", Color.LIGHT_RED);

Data.DefineColor("Negative and Down", Color.DARK_RED);

Data.DefineColor("Negative and Up", Color.LIGHT_GREEN);

Data.AssignValueColor(if Data >= 0 then if Data > Data[1] then Data.Color("Positive and Up") else Data.Color("Positive and Down") else if Data < Data[1] then Data.Color("Negative and Down") else Data.Color("Negative and Up"));





plot zeroLine = 0;



# End Code





# AI - got code for label from other Mobius study



def c = close(priceType = "Last");

def A = close(priceType = "Ask");

def B = close(priceType = "Bid");

def v = if IsNaN(volume) then v[1] else volume;

def BSPUp;

def BSPDn;



BSPUp = if close >= A

    then v

    else BSPUp[1];



BSPDn = if close <= B

    then -v

    else BSPDn[1];



def BSP = ((v - BSPDn) / (BSPUp - BSPDn)) * 100;

AddLabel(1, "1-Bar Buy/Sell Pressure = " + BSP,

    if BSP > 100 then Color.LIGHT_GREEN

    else if BSP < 100then Color.RED

    else Color.CYAN);



Here is the volume flow indicator...

Code:
# TD Ameritrade IP Company, Inc. (c) 2007-2018
#

declare lower;

input length = 130;
input maxVolumeCutOff = 2.5;

assert(maxVolumeCutOff > 0, "'max volume cut off' must be positive: " + maxVolumeCutOff);

def cutOff = 0.2 * stdev(log(hlc3) - log(hlc3[1]), 30) * close;
def hlcChange = hlc3 - hlc3[1];
def avgVolume = Average(volume, 50)[1];
def minVolume = Min(volume, avgVolume * maxVolumeCutOff);
def dirVolume = if hlcChange > cutOff
    then minVolume
    else if hlcChange < -cutOff
        then -minVolume
        else 0;

plot VFI = ExpAverage(sum(dirVolume, length) / avgVolume, 3);
plot ZeroLine = 0;

VFI.setDefaultColor(getColor(8));
ZeroLine.setDefaultColor(getColor(8));


Here is ease of movement...
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
#

declare lower;

input colorNormLength = 14;
input smLength = 14;

def mfi = if volume > 0 then (high - low) / volume * 100 else 0;
def mul = 50 * mfi * ((high + low) - (high[1] + low[1]));

plot EOM = Average(mul, smLength);
plot ZeroLine = 0;

EOM.DefineColor("Highest", Color.YELLOW);
EOM.DefineColor("Lowest", Color.LIGHT_RED);
EOM.AssignNormGradientColor(colorNormLength, EOM.color("Lowest"), EOM.color("Highest"));
ZeroLine.SetDefaultColor(GetColor(8));
I have just downloaded the indicator you contributed in Dec 2019.. and I have a question and would like your recommendation on settings for intraday use: See below
https://usethinkscript.com/threads/trade-volume-delta-indicator-for-thinkorswim.524/

# Cumulative Volume Delta with Chaikin Money Flow + Chaikin Osc

# tomsk

# 1.6.2020



# Cumulative Volume Delta
Again, Congratulations on your work and the work of everyone on this site: ThinkorSwim was not designed with High speed tick capacity: However, I am looking for more tape readings similar to this.
**It looks very clean especially for high volume index studies like SPY, IWM, QQQ. and slightly less os for lower volume due to lack of information:
congratulations on your coding work.( I think you are creative and talented and I appreciate your mindfulness . I am a statistician and self trained technical analyst. With lower volume there is less information:


In order to facilitate a higher frequency calculation what are your initial recommendations for example
a 3 minute 1 day chart on a normal stock:
The default settings on this indicator are ( when I downloaded to the ThinkorSwim desktop) were as follows:
CV dlengh is 10; cm Flength21; color norm length is 14, fast length is 2 and slow length is 10

I am open to all suggestions to improve the reportage on this combined indicator:
I especially am fond of the combination of Chaikins' work with intraday reportage on Tick Delta Volume.
With appreciation to all.
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
326 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top