Anthony Crudele's Beacon Indicator for ThinkorSwim

sheldonxp

New member
VIP
Anybody knows what it is? He said he made it himself, it's available for download for free but only for TradeStation. I don't have TS so can't open it to see what it is.

https://www.anthonycrudele.com/indicators/

Code:
//@version=4
study("Beacon - Anthony Crudele's Indicator", overlay=true)

//==INPUTS AND VARIABLES==//
bb_length = input(type=input.integer, title="Bollinger Band Length", defval=20)
bb_stddev = input(type=input.integer, title="Bollinger Band Std Dev", defval=3)
var float bb_resistance = 0.0
var float bb_support = 0.0
var float bb_peak_minor = 0.0
var float bb_valley_minor = 0.0
var float bb_peak_major = 0.0
var float bb_valley_major = 0.0
var float line_70 = 0.0
var float line_50 = 0.0
var float line_30 = 0.0
var new_peak = false
var new_valley = false

//==CALCULATE BOLLINGER BAND VALUES==//
[bb_middle, bb_upper, bb_lower] = bb(close,bb_length,bb_stddev)

//==CALCULATE PEAKS & VALLEYS...SET AS RESISTANCE & SUPPORT==//
//==MINOR PEAK==//
if bb_upper[1]>bb_upper[2] and bb_upper<bb_upper[1]
    bb_peak_minor := bb_upper[1]

//==MINOR VALLEY==//
if bb_lower[1]<bb_lower[2] and bb_lower>bb_lower[1]
    bb_valley_minor := bb_lower[1]
    
//A MINOR PEAK BECOMES A MAJOR PEAK IF:
//   1. IT IS HIGHER THAN THE PREVIOUS MAJOR PEAK
//   2. A NEW MAJOR VALLEY JUST FORMED

if bb_peak_minor>bb_peak_major[1]
    new_peak:=true
    
if bb_valley_minor<bb_valley_major[1]
    new_valley:=true

//==MAJOR PEAK==//
if bb_peak_minor>bb_peak_major[1] or new_valley==true
    bb_peak_major := bb_peak_minor

//==MAJOR VALLEY==//
if bb_valley_minor<bb_valley_major[1] or new_peak==true
    bb_valley_major := bb_valley_minor
    
new_peak:=false
new_valley:=false

line_70 := bb_valley_major+(bb_peak_major-bb_valley_major)*0.7
line_50 := bb_peak_major-(bb_peak_major-bb_valley_major)/2
line_30 := bb_valley_major+(bb_peak_major-bb_valley_major)*0.3

//==PLOTS==//
plot(bb_peak_major, offset=-1, style=plot.style_circles, title="Resistance Level" , color=color.red, linewidth=2)
plot(bb_valley_major, offset=-1, style=plot.style_circles, color=color.blue, title="Support Level", linewidth=2)
plot(line_70, style=plot.style_circles, color=color.red, title="70 Line", offset=-1, linewidth=2)
plot(line_50, style=plot.style_circles, color=color.yellow, title="50 Line", offset=-1, linewidth=2)
plot(line_30, style=plot.style_circles, color=color.blue, title="30 Line", offset=-1, linewidth=2)
 

BenTen

Administrative
Staff member
Staff
VIP
"It is a support and resistance indicator that constantly updates based on the volatility" [suggestion]

"This indicator draws a ray when price makes a higher high or a lower low and the stochastic oscillator doesn’t confirm the move in price." [suggestion]

"Divergence refers to when price makes a higher high or a lower low and the MACD divergence indicator fails to confirm the market price action." [suggestion]
 

silas7467

New member
I only recreated exactly what I saw on his latest develop your edge video on Friday the 18th, so if there are any discrepancies let me know so I can sort them out. There are also a couple other indicators in his indicator package for tradestation, but I don't know what they are. Any ideas? Anyway, here's a chart
http://tos.mx/LeuzihH
 

vro3

Member
I only recreated exactly what I saw on his latest develop your edge video on Friday the 18th, so if there are any discrepancies let me know so I can sort them out. There are also a couple other indicators in his indicator package for tradestation, but I don't know what they are. Any ideas? Anyway, here's a chart
http://tos.mx/LeuzihH
i just pulled it up. looks awesome! can you explain a little bit what I'm looking at? I mean, I can guess - but - would love your info!
 

silas7467

New member
i just pulled it up. looks awesome! can you explain a little bit what I'm looking at? I mean, I can guess - but - would love your info!
It's a 3 standard deviation bollinger set off a 20 simple moving average (which isn't shown). It's designed to show volatility expansion and contraction. Obviously when the market is expanding the bollingers become wide. Once the market begins to contract, and the bollingers roll in toward each other, a level is set at the highest high of the upper band and the lowest low of the lower band. There is a mid line and a 30% and 70% line as well. So long as the current bollinger upper and lower bands stay within the most recent extremes, we are to understand that the market is in a contraction (sideways) state, and the 30% and 70% lines will act as support and resistance.
The key is to use any number of methods to determine the trend, and use the 30 and 70 lines (and possibly the mid, depending on the strength of the trend) to trade in determined trend direction.
Sometimes, there are news events which cause huge volatility expansion and a very wide bollinger range. Many times when that happens, the market will remain between the 30 and 70 lines for longer periods of time, and can be used effectively as the edges of your trading range.
Sorry for the late response. Hope this helps
 

rad14733

Well-known member
VIP
@silas7467 Could you please post the actual script code instead of just a shared link... Members shouldn't have to install a study or indicator just to see the code... Also, posting a few pics of it would be helpful...
 

vro3

Member
@silas7467 VERY helpful! Thank you so much! ill keep my eye on this as well. I love things like this

@rad14733 Code below:

Code:
input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -3.0;
input Num_Dev_up = 3.0;
input averageType = AverageType.Simple;

def sDev = stdev(data = price[-displace], length = length);

plot MidLine = MovingAverage(averageType, data = price[-displace], length = length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;

LowerBand.SetDefaultColor(color.YELLOW);
MidLine.SetDefaultColor(GetColor(1));
MidLine.hide();
UpperBand.SetDefaultColor(color.YELLOW);

### Definition of highs and lows of bollinger bands ###
def hibol = upperband>upperband[1] and upperband > upperband[-1];
def lobol = lowerband<lowerband[1] and lowerband < lowerband[-1];

### Recursion lines for highs and lows ###
rec hii = if !hii[1] then upperband else if hibol then upperband else hii[1];
rec loo = if !loo[1] then lowerband else if lobol then lowerband else loo[1];

#############################################################

def state = {default init, undefined, uptrend, downtrend};
def maxPriceH;
def minPriceL;
def newMax;
def newMin;
def prevMaxH = GetValue(maxPriceH, 1);
def prevMinL = GetValue(minPriceL, 1);
def priceH = hii;
def priceL = loo;

if GetValue(state, 1) == GetValue(state.init, 0) {
#    maxPriceH = priceH;
#    minPriceL = priceL;
    maxPriceH = priceH;
    minPriceL = priceL;
    newMax = yes;
    newMin = yes;
    state = state.undefined;
} else if GetValue(state, 1) == GetValue(state.undefined, 0) {
    if priceH > prevMaxH {
        state = state.uptrend;
        maxPriceH = priceH;
        minPriceL = priceL;
        newMax = yes;
        newMin = yes;
    } else if priceL < prevMinL {
        state = state.downtrend;
        maxPriceH = priceH;
        minPriceL = priceL;
        newMax = yes;
        newMin = yes;
    } else {
        state = state.undefined;
        maxPriceH = prevMaxH;
        minPriceL = prevMinL;
        newMax = no;
        newMin = no;
    }
} else if GetValue(state, 1) == GetValue(state.uptrend, 0) {
    if priceL < prevMinL {
        state = state.downtrend;
        maxPriceH = priceH;
        minPriceL = priceL;
        newMax = yes;
        newMin = yes;
    } else {
        state = state.undefined;
        if (priceH > prevMaxH) {
            maxPriceH = priceH;
            newMax = yes;
        } else {
            maxPriceH = prevMaxH;
            newMax = no;
        }
        minPriceL = prevMinL;
        newMin = no;
    }
} else {
    if priceH > prevMaxH {
        state = state.uptrend;
        maxPriceH = priceH;
        minPriceL = priceL;
        newMax = yes;
        newMin = yes;
    } else {
        state = state.undefined;
        maxPriceH = prevmaxh;
        newMax = no;
        if (priceL < prevMinL) {
            minPriceL = priceL;
            newMin = yes;
        } else {
            minPriceL = prevMinL;
            newMin = no;
        }
    }
}

def min = if newmin then loo else 0;
def max = if newmax then hii else 0;

input lowValue = .3;
input highValue = .7;

plot upper = if maxPriceH != maxpriceH[1] or minpricel != minpricel[1] or isnan(close[1]) then double.NaN else maxpriceH;
plot downer = if minPriceL != minpriceL[1] or maxPriceH != maxpriceH[1] or isnan(close[1]) then double.NaN else minPriceL;

plot thirty = (upper-downer)*lowvalue+downer;
plot seventy = (upper-downer)*highvalue+downer;
plot mid = (upper-downer)*.5+downer;

upper.setdefaultcolor(color.MAGENTA);
downer.setdefaultcolor(color.CYAN);
thirty.setdefaultcolor(color.CYAN);
seventy.setdefaultcolor(color.MAGENTA);
mid.setdefaultcolor(color.DARK_ORANGE);

upper.setpaintingstrategy(paintingstrategy.HORIZONTAL);
downer.setpaintingstrategy(paintingstrategy.HORiZONTAL);
thirty.setpaintingstrategy(paintingstrategy.HORIZONTAL);
seventy.setpaintingstrategy(paintingstrategy.HORIZONTAL);
mid.setpaintingstrategy(paintingstrategy.HORIZONTAL);

defineglobalcolor("top",color.DARK_GRAY);
defineglobalcolor("bottom",color.DARK_GRAY);
input cloud = no;
addcloud(if cloud then upper else double.NaN,seventy,globalcolor("top"));
addcloud(if cloud then thirty else double.NaN,downer,globalcolor("bottom"));
 
Top