Concretum Bands For ThinkOrSwim

ShinJ

New member
Author states:
The Concretum Bands indicator recreates the Upper and Lower Bound of the Noise Area described in the paper "Beat the Market: An Effective Intraday Momentum Strategy for S&P500 ETF (SPY)" published by Concretum founder Zarattini, along with Barbon and Aziz, in May 2024.


How to use
A trader may use this indicator to identify intraday moves that exceed the average move over the most recent period. A break outside the bands could be used as a signal of significant demand/supply imbalance.

YQeWeCX.png


https://www.tradingview.com/v/CUpWCZhe/

mod note:
script converted. see below
 
Last edited by a moderator:

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

https://www.tradingview.com/v/CUpWCZhe/

Code:
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © foreignHead16013

//@version=5
indicator("Concretum Bands",overlay = true,max_bars_back = 5000,max_lines_count = 500)

k=input.int(10,"Length")
vm=input.float(1,"Volatility Multiplier")
ncol=input.color(color.rgb(255, 235, 59, 70),"NoiseArea color")
ucol=input.color(color.rgb(1, 1, 1, 70),"Upperbound color")
lcol=input.color(color.rgb(1, 1, 1, 70),"Lowerbound color")
extend=input.int(30,"Extend Plotting",maxval=250,inline = "one")
useext=input.bool(true,"",inline="one")
if useext==false
    extend:=0
var n=0 // n is number of bars in the current timeframe
var bool first=true


if first
    n:=n+1

if session.islastbar and first
    first:=false

var bool skipper=true
var skipper_counter=0
if skipper
    skipper_counter:=skipper_counter+1

if skipper_counter==k*n+1
    skipper:=false
//----------------------------------------------
var candle_counter=0
var float upperbound=0
var float lowerbound=0
var float firstconstant=0
var float secondconstant=0

candle_counter:=candle_counter+1
if session.isfirstbar
    candle_counter:=0
    firstconstant:=open>close[1]?open:close[1]
    secondconstant:=open<close[1]?open:close[1]
    upperbound:=open
    lowerbound:=open
if skipper==false and candle_counter!=0
    //                       num             deno                        -1
    j=1
    sigma=0.0
    while j<=k
        move=math.abs(       (  close[n*j]/open[j*n+candle_counter] )   -1          )
        sigma:=sigma+move
        j:=j+1
    sigma:=sigma/k
    upperbound:=firstconstant*(1+vm*sigma)
    lowerbound:=secondconstant*(1-vm*sigma)

u=plot(upperbound,color=ucol)
l=plot(lowerbound,color =lcol)
fill(u,l,color=ncol)

// plotting forward
prevuy=upperbound
prevlt=lowerbound

if skipper==false  and  barstate.isrealtime
   
    lm=1
    while lm<=(n-candle_counter)
        j=1
        sigma=0.0
        while j<=k
            move=math.abs(       (  close[(n*j)-lm]/open[j*n+candle_counter] )   -1          )
            sigma:=sigma+move
            j:=j+1
           
        sigma:=sigma/k
        extu=firstconstant*(1+vm*sigma)
        extl=secondconstant*(1-vm*sigma)
        //log.info(str.tostring(extu)+" ----- "+str.tostring(extl))
        line.new(bar_index+lm-1,prevuy,bar_index+lm,extu,color = ucol)
        line.new(bar_index+lm-1,prevlt,bar_index+lm,extl,color= lcol)
        prevuy:=extu
        prevlt:=extl
        lm:=lm+1
        if lm>extend
            break
check the below:

CSS:
#// Indicator for TOS
#// © foreignHead16013
#indicator("Concretum Bands",overlay = true,max_bars_back = 5000,max_lines_count = 500)
# Converted by Sam4Cok@Samer800 - 07/2024

input showMidline = yes;
input Length = 10;
input VolatilityMultiplier = 1.0; #,"Volatility Multiplier")

def na = Double.NaN;
def last = isNaN(close);
def periodIndx = getYyyyMmDd();
def islastbar = compoundValue(1, periodIndx - periodIndx[1], yes);

def start = if BarNumber() < 2 then 0 else
            if islastbar then start[1] + 1 else start[1];
def n = if start == 1 then n[1] + 1 else n[1];

def candle_counter = if islastbar then 0 else candle_counter[1] + 1;
def firstconstant  = if islastbar then Max(open, close[1]) else firstconstant[1];
def secondconstant = if islastbar then Min(open, close[1]) else secondconstant[1];
def midconstant = if islastbar then (firstconstant + secondconstant) / 2 else midconstant[1];

def sigma; def upperbound; def lowerbound; def midUpper; def midLower;
def counter;
if candle_counter!=0 {
    sigma = fold j = 0 to Length with p while counter[1] <= Length + 1 do
            p + AbsValue((GetValue(close, n*(j+1))/GetValue(open, (j+1)*n + candle_counter))-1);
    counter = if counter[1] > Length then 0 else counter[1] + 1;
    upperbound = firstconstant *(1 + VolatilityMultiplier * sigma / Length);
    lowerbound = secondconstant*(1 - VolatilityMultiplier * sigma / Length);
    midUpper = midconstant * (1 + VolatilityMultiplier * sigma / Length);
    midLower = midconstant * (1 - VolatilityMultiplier * sigma / Length);
} else if islastbar {
    counter = 0;
    sigma = 0;
    upperbound = open;
    lowerbound = open;
    midUpper = open;
    midLower = open;
} else {
    counter = counter[1];
    sigma = sigma[1];
    upperbound = upperbound[1];
    lowerbound = lowerbound[1];
    midUpper = midUpper[1];
    midLower = midLower[1];
}

def Upper = if last then na else if start>1 and upperbound then upperbound else na;
def lower = if last then na else if start>1 and lowerbound then lowerbound else na;
def midUp = if last then na else if start>1 and midUpper then midUpper else na;
def midLo = if last then na else if start>1 and midLower then midLower else na;
plot midLine = if showMidline and !islastbar and start>1 then (Upper + Lower) / 2 else na;

midLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
midLine.SetDefaultColor(Color.GRAY);
AddCloud(Upper, lower, Color.DARK_GRAY);
AddCloud(Upper, midUp, Color.DARK_ORANGE);
AddCloud(midLo, lower, Color.DARK_ORANGE);

#-- END of CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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