Price Spikes Indicators For ThinkOrSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Here you go:

Code:
# SigmaSpikes(R) per Adam H. Grimes
# Assembled by BenTen at UseThinkScript.com
# Converted from https://www.tradingview.com/script/s8Wz3GbK-SigmaSpikes-R-per-Adam-H-Grimes/

declare lower;

input length = 20;
def change = close/close[1] - 1;
def stdev = stdev(change, length);
def sigma = change / stdev[1];
plot UpperTreshold = 2;
plot LowerTreshold = -2;
plot ZeroLine = 0;
plot r = sigma;
r.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
 

madeinnyc

Member
Sometime ago my trading partner wrote a variation of the code above. It was used primarily for options trading:

Code:
#Standard Deviation Spike Indicator by Corvus Xander

declare lower;
input length = 20;
def closeLog = Log(close[1]/ close[2]);
def SDev = stdev(closeLog, length)*Sqrt(length / (length - 1));
def m= SDev * close[1];
plot spike = (close[0]- close[1]) / m;
spike.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
spike.AssignValueColor(if close > close[1] then Color.UPTICK else if close < close[1] then Color.DOWNTICK else GetColor(1));
 

codydog

Active member
@Lone Wolf - not sure exactly what you're trying to do, but perhaps consider using zscore - lots of scripts around that and online resources explaining what it is and how it works
 

madeinnyc

Member
@Lone Wolf - The three codes are closely related. If u plot all three u will notice subtle differences. Mine was designed to measure changes in option prices as standard deviations.
 

Pensar

Well-known member
VIP
Lifetime
@Lone Wolf Try this. You can adjust the Upper/Lower Thresholds like @BenTen mentioned. It will only show the bars that extend past the threshold levels.

Code:
# SigmaSpikes(R) per Adam H. Grimes
# Assembled by BenTen at UseThinkScript.com
# Converted from https://www.tradingview.com/script/s8Wz3GbK-SigmaSpikes-R-per-Adam-H-Grimes/
# simple modification by Pensar to only show spikes above/below threshold levels

declare lower;

input length = 20;
def change = close/close[1] - 1;
def stdev = stdev(change, length);
def sigma = change / stdev[1];
plot UpperTreshold = 3;
plot LowerTreshold = -3;
plot ZeroLine = 0;
plot r = if sigma > UpperTreshold
         or sigma < LowerTreshold
         then sigma
         else double.nan;
r.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
NextSignal's Price Volatility Oscillator For ThinkOrSwim
Study based upon the work of Jeff Augen (Price Volatility), Ryan Harlin (.TS translation) and Stephen Harlin
# 86% Positive Predictive Value when buying volatility troughs and selling volatility peaks
Displays spikes that could signal tops and bottoms. Like all oscillators works well in trending markets
Li7uOy4.png

shared link: https://tos.mx/lUw8dud Click here for --> Easiest way to load shared links
Ruby:
# Copyright Stephen Harlin, 2011
# Created Oct 2009
# Information Signal Translation
# Study based upon the work of Jeff Augen (Price Volatility), Ryan Harlin (.TS translation) and myself
# 86% Positive Predictive Value when buying volatility troughs and selling volatility peaks

declare lower;

# Calculate price volatility (Jeff Augen) and display as both a histogram and a running cumulative

def length = 20;
def cumlength = 13;
def closeLog = log(close[1] / close[2]);
def SDev = stdev(closeLog, length) * Sqrt(length / (length - 1));
def x = SDev * close[1];
def spike = (close[0] - close[1]) / x;

def y = if spike > 0 then spike else 0;
def up = sum(y, cumlength);
def z = if spike <= 0 then spike else 0;
def dn = sum(AbsValue(z), cumlength);

# Back-testing found rare instances of spikes greater than 3/-3 and had no advantage over limit of 3 Std Devs

plot spikeLimit = if spike > 3 then 3 else if spike < -3 then -3 else spike;
spikeLimit.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
spikeLimit.SetLineWeight(3);
spikeLimit.AssignValueColor(if spike > 3.0 then color.Green else if spike > 0 then CreateColor(51,75,255) else if spike < -3 then color.red else if spike < 0 then CreateColor(32,49,57) else Color.Dark_Orange);

# Plots the price volatility oscillator

plot spikeOsc = (up - dn)/3;
spikeOsc.AssignValueColor(if spikeOsc > 0 then color.Dark_green else if spikeOsc < 0 then color.red else Color.GRAY);
 
Last edited:

songwangfb

New member
could you share how to use this indicator? based on code it seems like it is calculating if the price spiked above certain standard deviations? Thanks!
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
could you share how to use this indicator? based on code it seems like it is calculating if the price spiked above certain standard deviations? Thanks!
Yes, Spike Oscillators look for price spikes above certain thresholds to signal possible reversals.

The script author, Stephen Harlin is such an awesome chartist. So I decided to add this to our indicators.

We can't ask the author because as amazing a mathematician that he is, he is an even more amazing doctor and is devoting himself to saving lives during this horrible period of our lives.

Recommend you put it on your chart. Nothing beats personal experience ;) The only way you will know what works best for you is to play with the settings and see how the indicator line up w/ your strategy and with your other indicators. To determine if this indicator brings value, analyze it over different timeframes, across history and with multiple instruments.

To give-back to the community, come on back and tell us your findings(y)
 
Last edited:

danjoh

Member
VIP
@MerryDay I believe this indicator is showing the spikes (hi/lows with velocity) of IV. However, there's doesn't not seem to be much correlation with std. HV and IV indicators. Is this explained by the momentum or velocity of the single candle showing the spike? In other words, the aggressiveness of buyers and sellers for that candles period.
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
@MerryDay I believe this indicator is showing the spikes (hi/lows with velocity) of IV. However, there's doesn't not seem to be much correlation with std. HV and IV indicators. Is this explained by the momentum or velocity of the single candle showing the spike? In other words, the aggressiveness of buyers and sellers for that candles period.
The spikes do not come with an explanation. They are above / below the standard deviation for whatever reason.
For members trading on price action, this is a great tool for the toolbox. When combined w/ volume, you get a heads-up when there is eminent change a-coming.

Spikes that are greater than whatever threshold you set for your particular timeframe are an indication that you should take notice.
 
Last edited:

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
Here is another Spike Indicator.
It is for VIP members.
This is similar to the free indicators in this thread.

This Specialized Spike Indicator tracks the status of your active trades.
Customized to provide a heads-up as to what is going to happen next on a bar-by-bar basis with my stock trades. It keeps me from jumping out too early and from staying in too late.

Standard Deviation Reader For ThinkOrSwim
https://usethinkscript.com/threads/standard-deviation-reader-for-thinkorswim.10454/

This indicator does not repaint
RBFFFAY.png

@danjoh
 
Last edited:

henry1224

Active member
VIP
NextSignal's Price Volatility Oscillator For ThinkOrSwim

Displays spikes that could signal tops and bottoms. Like all oscillators works well in trending markets
Li7uOy4.png

shared link: https://tos.mx/lUw8dud Click here for --> Easiest way to load shared links
Ruby:
# Copyright Stephen Harlin, 2011
# Created Oct 2009
# Information Signal Translation
# Study based upon the work of Jeff Augen (Price Volatility), Ryan Harlin (.TS translation) and myself
# 86% Positive Predictive Value when buying volatility troughs and selling volatility peaks

declare lower;

# Calculate price volatility (Jeff Augen) and display as both a histogram and a running cumulative

def length = 20;
def cumlength = 13;
def closeLog = log(close[1] / close[2]);
def SDev = stdev(closeLog, length) * Sqrt(length / (length - 1));
def x = SDev * close[1];
def spike = (close[0] - close[1]) / x;

def y = if spike > 0 then spike else 0;
def up = sum(y, cumlength);
def z = if spike <= 0 then spike else 0;
def dn = sum(AbsValue(z), cumlength);

# Back-testing found rare instances of spikes greater than 3/-3 and had no advantage over limit of 3 Std Devs

plot spikeLimit = if spike > 3 then 3 else if spike < -3 then -3 else spike;
spikeLimit.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
spikeLimit.SetLineWeight(3);
spikeLimit.AssignValueColor(if spike > 3.0 then color.Green else if spike > 0 then CreateColor(51,75,255) else if spike < -3 then color.red else if spike < 0 then CreateColor(32,49,57) else Color.Dark_Orange);

# Plots the price volatility oscillator

plot spikeOsc = (up - dn)/3;
spikeOsc.AssignValueColor(if spikeOsc > 0 then color.Dark_green else if spikeOsc < 0 then color.red else Color.GRAY);
Here is a modified binary version with multi lengths and the ability tp paint bars
Code:
# Copyright Stephen Harlin, 2011
# Created Oct 2009
# Information Signal Translation
# Study based upon the work of Jeff Augen (Price Volatility), Ryan Harlin (.TS translation) and myself
# 86% Positive Predictive Value when buying volatility troughs and selling volatility peaks
# Calculate price volatility (Jeff Augen) and display as both a histogram and a running cumulative
# Back-testing found rare instances of spikes greater than 3/-3 and had no advantage over limit of 3 Std Devs
#Converted to a Binary dot system, Added paintbars by changing the APC input to whichever line you designate by Henry Z Kaczmarczyk
declare lower;
input length1 = 5;
input length2 = 8;
input length3 = 13;
input length4 = 21;
input length5 = 34;
input length6 = 55;
input length7 = 89;
input length8 = 144;
input length9 = 233;
Input cumlength1 = 3;
Input cumlength2 = 5;
Input cumlength3 = 8;
Input cumlength4 = 13;
Input cumlength5 = 21;
Input cumlength6 = 34;
Input cumlength7 = 55;
Input cumlength8 = 89;
Input cumlength9 = 144;
Input APC = 0;
Input dotsize = 3;
def closeLog = log(close[1] / close[2]);
def SDev1 = stdev(closeLog, length1) * Sqrt(length1 / (length1 - 1));
def SDev2 = stdev(closeLog, length2) * Sqrt(length2 / (length2 - 1));
def SDev3 = stdev(closeLog, length3) * Sqrt(length3 / (length3 - 1));
def SDev4 = stdev(closeLog, length4) * Sqrt(length4 / (length4 - 1));
def SDev5 = stdev(closeLog, length5) * Sqrt(length5 / (length5 - 1));
def SDev6 = stdev(closeLog, length6) * Sqrt(length6 / (length6 - 1));
def SDev7 = stdev(closeLog, length7) * Sqrt(length7 / (length7 - 1));
def SDev8 = stdev(closeLog, length8) * Sqrt(length8 / (length8 - 1));
def SDev9 = stdev(closeLog, length9) * Sqrt(length9 / (length9 - 1));
def x1 = SDev1 * close[1];
def x2 = SDev2 * close[1];
def x3 = SDev3 * close[1];
def x4 = SDev4 * close[1];
def x5 = SDev5 * close[1];
def x6 = SDev6 * close[1];
def x7 = SDev7 * close[1];
def x8 = SDev8 * close[1];
def x9 = SDev9 * close[1];
def spike1 = (close[0] - close[1]) / x1;
def spike2 = (close[0] - close[1]) / x2;
def spike3 = (close[0] - close[1]) / x3;
def spike4 = (close[0] - close[1]) / x4;
def spike5 = (close[0] - close[1]) / x5;
def spike6 = (close[0] - close[1]) / x6;
def spike7 = (close[0] - close[1]) / x7;
def spike8 = (close[0] - close[1]) / x8;
def spike9 = (close[0] - close[1]) / x9;
def y1 = if spike1 > 0 then spike1 else 0;
def y2 = if spike2 > 0 then spike2 else 0;
def y3 = if spike3 > 0 then spike3 else 0;
def y4 = if spike4 > 0 then spike4 else 0;
def y5 = if spike5 > 0 then spike5 else 0;
def y6 = if spike6 > 0 then spike6 else 0;
def y7 = if spike7 > 0 then spike7 else 0;
def y8 = if spike8 > 0 then spike8 else 0;
def y9 = if spike9 > 0 then spike9 else 0;
def up1 = sum(y1, cumlength1);
def up2 = sum(y2, cumlength2);
def up3 = sum(y3, cumlength3);
def up4 = sum(y4, cumlength4);
def up5 = sum(y5, cumlength5);
def up6 = sum(y6, cumlength6);
def up7 = sum(y7, cumlength7);
def up8 = sum(y8, cumlength8);
def up9 = sum(y9, cumlength9);
def z1 = if spike1 <= 0 then spike1 else 0;
def z2 = if spike2 <= 0 then spike2 else 0;
def z3 = if spike3 <= 0 then spike3 else 0;
def z4 = if spike4 <= 0 then spike4 else 0;
def z5 = if spike5 <= 0 then spike5 else 0;
def z6 = if spike6 <= 0 then spike6 else 0;
def z7 = if spike7 <= 0 then spike7 else 0;
def z8 = if spike8 <= 0 then spike8 else 0;
def z9 = if spike9 <= 0 then spike9 else 0;
def dn1 = sum(AbsValue(z1), cumlength1);
def dn2 = sum(AbsValue(z2), cumlength2);
def dn3 = sum(AbsValue(z3), cumlength3);
def dn4 = sum(AbsValue(z4), cumlength4);
def dn5 = sum(AbsValue(z5), cumlength5);
def dn6 = sum(AbsValue(z6), cumlength6);
def dn7 = sum(AbsValue(z7), cumlength7);
def dn8 = sum(AbsValue(z8), cumlength8);
def dn9 = sum(AbsValue(z9), cumlength9);
def spikeLimit1 = if spike1 > 3 then 3 else if spike1 < -3 then -3 else spike1;
def spikeLimit2 = if spike2 > 3 then 3 else if spike2 < -3 then -3 else spike2;
def spikeLimit3 = if spike3 > 3 then 3 else if spike3 < -3 then -3 else spike3;
def spikeLimit4 = if spike4 > 3 then 3 else if spike4 < -3 then -3 else spike4;
def spikeLimit5 = if spike5 > 3 then 3 else if spike5 < -3 then -3 else spike5;
def spikeLimit6 = if spike6 > 3 then 3 else if spike6 < -3 then -3 else spike6;
def spikeLimit7 = if spike7 > 3 then 3 else if spike7 < -3 then -3 else spike7;
def spikeLimit8 = if spike8 > 3 then 3 else if spike8 < -3 then -3 else spike8;
def spikeLimit9 = if spike9 > 3 then 3 else if spike9 < -3 then -3 else spike9;
def spikeOsc1 = (up1 – dn1)/3;
def spikeOsc2 = (up2 – dn2)/3;
def spikeOsc3 = (up3 – dn3)/3;
def spikeOsc4 = (up4 – dn4)/3;
def spikeOsc5 = (up5 – dn5)/3;
def spikeOsc6 = (up6 – dn6)/3;
def spikeOsc7 = (up7 – dn7)/3;
def spikeOsc8 = (up8 – dn8)/3;
def spikeOsc9 = (up9 – dn9)/3;
plot A1_Dot = if IsNaN(close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A1_Dot.SetLineWeight(DotSize);
A1_Dot.AssignValueColor(if spike1 < -3 then color.magenta else if spike1 < 0 then Color.Plum else Color.Black);
plot A2_Dot = if IsNaN(close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A2_Dot.SetLineWeight(DotSize);
A2_Dot.AssignValueColor(if spikeOsc1 > 0 then color.green else if spikeOsc1 < 0 then color.red else Color.DARK_GRAY);
plot A3_Dot = if IsNaN(close) then Double.NaN else 3;
A3_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A3_Dot.SetLineWeight(DotSize);
A3_Dot.AssignValueColor(if spike1 > 3.0 then color.cyan else if spike1 > 0 then Color.Blue else Color.Black);

plot A4_Dot = if IsNaN(close) then Double.NaN else 4;
A4_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A4_Dot.SetLineWeight(DotSize);
A4_Dot.AssignValueColor(if spike2 < -3 then color.magenta else if spike2 < 0 then Color.Plum else Color.Black);
plot A5_Dot = if IsNaN(close) then Double.NaN else 5;
A5_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A5_Dot.SetLineWeight(DotSize);
A5_Dot.AssignValueColor(if spikeOsc2 > 0 then color.green else if spikeOsc2 < 0 then color.red else Color.DARK_GRAY);
plot A6_Dot = if IsNaN(close) then Double.NaN else 6;
A6_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A6_Dot.SetLineWeight(DotSize);
A6_Dot.AssignValueColor(if spike2 > 3.0 then color.cyan else if spike2 > 0 then Color.Blue else Color.Black);

plot A7_Dot = if IsNaN(close) then Double.NaN else 7;
A7_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A7_Dot.SetLineWeight(DotSize);
A7_Dot.AssignValueColor(if spike3 < -3 then color.magenta else if spike3 < 0 then Color.Plum else Color.Black);
plot A8_Dot = if IsNaN(close) then Double.NaN else 8;
A8_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A8_Dot.SetLineWeight(DotSize);
A8_Dot.AssignValueColor(if spikeOsc3 > 0 then color.green else if spikeOsc3 < 0 then color.red else Color.DARK_GRAY);
plot A9_Dot = if IsNaN(close) then Double.NaN else 9;
A9_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A9_Dot.SetLineWeight(DotSize);
A9_Dot.AssignValueColor(if spike3 > 3.0 then color.cyan else if spike3 > 0 then Color.Blue else Color.Black);

plot A10_Dot = if IsNaN(close) then Double.NaN else 10;
A10_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A10_Dot.SetLineWeight(DotSize);
A10_Dot.AssignValueColor(if spike4 < -3 then color.magenta else if spike4 < 0 then Color.Plum else Color.Black);
plot A11_Dot = if IsNaN(close) then Double.NaN else 11;
A11_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A11_Dot.SetLineWeight(DotSize);
A11_Dot.AssignValueColor(if spikeOsc4 > 0 then color.green else if spikeOsc4 < 0 then color.red else Color.DARK_GRAY);
plot A12_Dot = if IsNaN(close) then Double.NaN else 12;
A12_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A12_Dot.SetLineWeight(DotSize);
A12_Dot.AssignValueColor(if spike4 > 3.0 then color.cyan else if spike4 > 0 then Color.Blue else Color.Black);

plot A13_Dot = if IsNaN(close) then Double.NaN else 13;
A13_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A13_Dot.SetLineWeight(DotSize);
A13_Dot.AssignValueColor(if spike5 < -3 then color.magenta else if spike5 < 0 then Color.Plum else Color.Black);
plot A14_Dot = if IsNaN(close) then Double.NaN else 14;
A14_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A14_Dot.SetLineWeight(DotSize);
A14_Dot.AssignValueColor(if spikeOsc5 > 0 then color.green else if spikeOsc5 < 0 then color.red else Color.DARK_GRAY);
plot A15_Dot = if IsNaN(close) then Double.NaN else 15;
A15_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A15_Dot.SetLineWeight(DotSize);
A15_Dot.AssignValueColor(if spike5 > 3.0 then color.cyan else if spike5 > 0 then Color.Blue else Color.Black);

plot A16_Dot = if IsNaN(close) then Double.NaN else 16;
A16_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A16_Dot.SetLineWeight(DotSize);
A16_Dot.AssignValueColor(if spike6 < -3 then color.magenta else if spike6 < 0 then Color.Plum else Color.Black);
plot A17_Dot = if IsNaN(close) then Double.NaN else 17;
A17_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A17_Dot.SetLineWeight(DotSize);
A17_Dot.AssignValueColor(if spikeOsc6 > 0 then color.green else if spikeOsc6 < 0 then color.red else Color.DARK_GRAY);
plot A18_Dot = if IsNaN(close) then Double.NaN else 18;
A18_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A18_Dot.SetLineWeight(DotSize);
A18_Dot.AssignValueColor(if spike6 > 3.0 then color.cyan else if spike6 > 0 then Color.Blue else Color.Black);

plot A19_Dot = if IsNaN(close) then Double.NaN else 19;
A19_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A19_Dot.SetLineWeight(DotSize);
A19_Dot.AssignValueColor(if spike7 < -3 then color.magenta else if spike7 < 0 then Color.Plum else Color.Black);
plot A20_Dot = if IsNaN(close) then Double.NaN else 20;
A20_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A20_Dot.SetLineWeight(DotSize);
A20_Dot.AssignValueColor(if spikeOsc7 > 0 then color.green else if spikeOsc7 < 0 then color.red else Color.DARK_GRAY);
plot A21_Dot = if IsNaN(close) then Double.NaN else 21;
A21_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A21_Dot.SetLineWeight(DotSize);
A21_Dot.AssignValueColor(if spike7 > 3.0 then color.cyan else if spike7 > 0 then Color.Blue else Color.Black);

plot A22_Dot = if IsNaN(close) then Double.NaN else 22;
A22_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A22_Dot.SetLineWeight(DotSize);
A22_Dot.AssignValueColor(if spike8 < -3 then color.magenta else if spike8 < 0 then Color.Plum else Color.Black);
plot A23_Dot = if IsNaN(close) then Double.NaN else 23;
A23_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A23_Dot.SetLineWeight(DotSize);
A23_Dot.AssignValueColor(if spikeOsc8 > 0 then color.green else if spikeOsc8 < 0 then color.red else Color.DARK_GRAY);
plot A24_Dot = if IsNaN(close) then Double.NaN else 24;
A24_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A24_Dot.SetLineWeight(DotSize);
A24_Dot.AssignValueColor(if spike8 > 3.0 then color.cyan else if spike8 > 0 then Color.Blue else Color.Black);

plot A25_Dot = if IsNaN(close) then Double.NaN else 25;
A25_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A25_Dot.SetLineWeight(DotSize);
A25_Dot.AssignValueColor(if spike9 < -3 then color.magenta else if spike9 < 0 then Color.Plum else Color.Black);
plot A26_Dot = if IsNaN(close) then Double.NaN else 26;
A26_Dot.SetPaintingStrategy(PaintingStrategy.Squares);
A26_Dot.SetLineWeight(DotSize);
A26_Dot.AssignValueColor(if spikeOsc9 > 0 then color.green else if spikeOsc9 < 0 then color.red else Color.DARK_GRAY);
plot A27_Dot = if IsNaN(close) then Double.NaN else 27;
A27_Dot.SetPaintingStrategy(PaintingStrategy.Points);
A27_Dot.SetLineWeight(DotSize);
A27_Dot.AssignValueColor(if spike9 > 3.0 then color.cyan else if spike9 > 0 then Color.Blue else Color.Black);

AssignPriceColor( if APC ==1 and spike1 < -3 then color.magenta else if APC ==1 and spike1 < 0 then Color.Plum else If APC ==2 and spikeOsc1 > 0 then color.green else if APC ==2 and spikeOsc1 < 0 then color.red else if APC ==3 and  spike1 > 3.0 then color.cyan else if APC ==3 and spike1 > 0 then Color.Blue else
if APC ==4 and spike2 < -3 then color.magenta else if APC ==4 and spike2 < 0 then Color.Plum else If APC ==5 and spikeOsc2 > 0 then color.green else if APC ==5 and spikeOsc2 < 0 then color.red else if APC ==6 and  spike2 > 3.0 then color.cyan else if APC ==6 and spike2 > 0 then Color.Blue else
if APC ==7 and spike3 < -3 then color.magenta else if APC ==7 and spike3 < 0 then Color.Plum else If APC ==8 and spikeOsc3 > 0 then color.green else if APC ==8 and spikeOsc3 < 0 then color.red else if APC ==9 and  spike3 > 3.0 then color.cyan else if APC ==9 and spike3 > 0 then Color.Blue else
if APC ==10 and spike4 < -3 then color.magenta else if APC ==10 and spike4 < 0 then Color.Plum else If APC ==11 and spikeOsc4 > 0 then color.green else if APC ==11 and spikeOsc4 < 0 then color.red else if APC ==12 and  spike4 > 3.0 then color.cyan else if APC ==12 and spike4 > 0 then Color.Blue else
if APC ==13 and spike5 < -3 then color.magenta else if APC ==13 and spike5 < 0 then Color.Plum else If APC ==14 and spikeOsc5 > 0 then color.green else if APC ==14 and spikeOsc5 < 0 then color.red else if APC ==15 and  spike5 > 3.0 then color.cyan else if APC ==15 and spike5 > 0 then Color.Blue else
if APC ==16 and spike6 < -3 then color.magenta else if APC ==16 and spike6 < 0 then Color.Plum else If APC ==17 and spikeOsc6 > 0 then color.green else if APC ==17 and spikeOsc6 < 0 then color.red else if APC ==18 and  spike6 > 3.0 then color.cyan else if APC ==18 and spike6 > 0 then Color.Blue else
if APC ==19 and spike7 < -3 then color.magenta else if APC ==19 and spike7 < 0 then Color.Plum else If APC ==20 and spikeOsc7 > 0 then color.green else if APC ==20 and spikeOsc7 < 0 then color.red else if APC ==21 and  spike7 > 3.0 then color.cyan else if APC ==21 and spike7 > 0 then Color.Blue else
if APC ==22 and spike8 < -3 then color.magenta else if APC ==22 and spike8 < 0 then Color.Plum else If APC ==23 and spikeOsc8 > 0 then color.green else if APC ==23 and spikeOsc8 < 0 then color.red else if APC ==24 and  spike8 > 3.0 then color.cyan else if APC ==24 and spike8 > 0 then Color.Blue else
if APC ==25 and spike9 < -3 then color.magenta else if APC ==25 and spike9 < 0 then Color.Plum else If APC ==26 and spikeOsc9 > 0 then color.green else if APC ==26 and spikeOsc9 < 0 then color.red else if APC ==27 and  spike9 > 3.0 then color.cyan else if APC ==27 and spike9 > 0 then Color.Blue else Color.Current);
9ntcCDL.png
 
Last edited by a moderator:

timing

Member
Sometime ago my trading partner wrote a variation of the code above. It was used primarily for options trading:

Code:
#Standard Deviation Spike Indicator by Corvus Xander

declare lower;
input length = 20;
def closeLog = Log(close[1]/ close[2]);
def SDev = stdev(closeLog, length)*Sqrt(length / (length - 1));
def m= SDev * close[1];
plot spike = (close[0]- close[1]) / m;
spike.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
spike.AssignValueColor(if close > close[1] then Color.UPTICK else if close < close[1] then Color.DOWNTICK else GetColor(1));
@madeinnyc Would you please explain a little bit how you applied this indicator?
I put this on daily, hourly, 15-minite and 5-minute charts, then watch them. Basially it is said that indicator is green means price is up; indicator is red means price is down. But do not get too much information out of them. They changed up and down, green to red too frequently.
 
Last edited:

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.
Top