Repaints Volume Spikes [TFO] For ThinkOrSwim

Repaints
check the below

CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0
#// © tradeforopp
#indicator("Volume Spikes [TFO]", "Volume Spikes [TFO]", overlay=true)
# - Converted by Sam4Cok@Samer800    - 11/2023 - Request from UseThinkScript.com memeber
#// Variables and constants

input VolumeMultiplier = 1.5;         # "Volume Multiplier"
input VolumeSmaLength = 100;          # "Volume SMA Length"
input only_valid_hl = yes;            # "Only Use Valid Highs & Lows"
input only_hammers_shooters = yes;    # "Only Use Hammers & Shooters")
input UseSameCloseVolumeSpikes = no;  # "Only Use Same-Close Volume Spikes"
input startTime = 0000;               # "Session Time"
input EndTime = 2359;                 # "0000-0000", "Session Time"

def na = Double.NaN;
def t = SecondsFromTime(startTime) >=0 and SecondsTillTime(EndTime) >=0;


#// Candle calculations

def valid_high1 = if only_valid_hl then high[1] > high[2] and high[1] > high[0] else yes;
def valid_low1 = if only_valid_hl then low[1] < low[2] and low[1] < low[0] else yes;

def distance_hl = high - low;
def valid_hammer = open > low + distance_hl / 2 and close > low + distance_hl / 2;
def valid_shooter = open < low + distance_hl / 2 and close < low + distance_hl / 2;

def valid_high; def valid_low;
if only_hammers_shooters {
    valid_high = valid_high1 and valid_shooter[1];
    valid_low = valid_low1 and valid_hammer[1];
    } else
if UseSameCloseVolumeSpikes {
    valid_high = valid_high1 and close[1] < open[1];
    valid_low = valid_low1 and close[1] > open[1];
    } else {
    valid_high = valid_high1;
    valid_low = valid_low1;
}

#// Volume check
#// Is volume sufficiently greater than its MA?
def vol_check = volume > Average(volume, VolumeSmaLength) * VolumeMultiplier and t;
def result_bearish = valid_high and vol_check[1];
def result_bullish = valid_low and vol_check[1];

plot SpikeDn = if result_bearish[-1] then high else na;
plot SpikeUp = if result_bullish[-1] then low else na;

SpikeDn.SetLineWeight(2);
SpikeUp.SetLineWeight(2);
SpikeDn.SetPaintingStrategy(PaintingStrategy.SQUARES);
SpikeUp.SetPaintingStrategy(PaintingStrategy.SQUARES);
SpikeDn.SetDefaultColor(Color.MAGENTA);
SpikeUp.SetDefaultColor(Color.CYAN);

#-- END of CODE
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
422 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