A

#### anty

##### New member

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?