As a Squeeze and a TREND LINE

Jesus Bueno

New member
Greetings and happy day.
I am writing to see if it is possible to program an indicator that looks like Jonh Carter's TTM SQUEEZE and represents the two lines that you see in the image.
The yellow line represents a trend (DATA in the indicator #BlaiMarifeli1) and the red line represents an average (DATA4 in the indicator #BlaiMarifeli1).
In this squeeze, the zero level should always be the DATA4 or average. And the vertical bars above and below should be the difference between the DATA and DATA4. Ideally, the bars would be above with 2 blue bars and below with red and yellow bars for good visualization.
In summary, we can say that it would be the same indicator but with the appearance of a squeeze and without the part of drawing lines and clouds.
Is it possible?
 

Attachments

  • 17 18_09_37-SPY, SPY - Active Trader - 76352645SCHW Main@thinkorswim [build 1981].jpg
    17 18_09_37-SPY, SPY - Active Trader - 76352645SCHW Main@thinkorswim [build 1981].jpg
    310.4 KB · Views: 50
  • #BlaiMarifeli1.docx
    13.4 KB · Views: 22
Last edited by a moderator:
17 18_09_37-SPY, SPY - Active Trader - 76352645SCHW Main@thinkorswim [build 1981].jpg


As you can see in the upper part of the image I have an indicator (BlaiMarifeli1) of which I only want to see the red line which is an AVERAGE and a yellow line which is a TREND.
Below is an example of the TTM Squeeze by John Carter.
I would like to have a BlaiMarifeli2 like the TTM Squeeze where the line of value 0 is the red line of BlaiMarifeli1. And the bars represent the difference above and below the red line.
Is it possible to do it?
Thank you for your time

Ruby:
#Objetivo poner flechas al cruce de medias

script calc_stoch
{
    input src = close;
    input length = 0;
    input smoothFastD = 0;

    def ll = Lowest(low, length);
    def hh = Highest(high, length);
    def k = 100 * (src - ll) / (hh - ll);
    plot line = Average(k, smoothFastD);
}
script pine_rma
{
    input x = close;
    input y = 14;

    rec sum = (x + (y - 1) * If(IsNaN(sum[1]), 0, sum[1])) / y;
    plot line = sum;
}
script pine_rsi
{
    input x = close;
    input y = close;

    def u = Max(x - x[1], 0); # upward change
    def d = Max(x[1] - x, 0); # downward change
    def rs = pine_rma(u, y) / pine_rma(d, y);
    def res = 100 - 100 / (1 + rs);
    plot line = res;

}
input live_candle = yes;
input lengthEMA = 255;
input m = 15;
input mult = 2.0;


def tprice = (open + high + low + close) / 4;
def source = (high + low + close) / 3;

#Pececillos
rec pvi = If(volume > volume[1], pvi[1] + ((close - close[1]) / close[1]), pvi[1]);
def pvim = ExpAverage(pvi, m);
def pvimax = Highest(pvim, 90);
def pvimin = Lowest(pvim, 90);
def oscp = (pvi - pvim) * 100 / (pvimax - pvimin);
#Tiburones
rec nvi = If(volume < volume[1], nvi[1] + ((close - close[1]) / close[1]), nvi[1]);
def nvim = ExpAverage(nvi, m);
def nvimax = Highest(nvim, 90);
def nvimin = Lowest(nvim, 90);
def azul = (nvi - nvim) * 100 / (nvimax - nvimin);
#Money Flow Index
def t1 = volume * If((source - source[1]) <= 0, 0, source);
def upper_s = Sum(t1, 14);
def t2 = volume * If((source - source[1]) >= 0, 0, source);
def lower_s = Sum(t2, 14);
def xmf = 100 - 100 / (1 + upper_s / lower_s);
#Bollinger

def basis = Average(tprice, 25);
def dev = mult * StDev(tprice, 25);
def upper = basis + dev;
def lower = basis - dev;
def OB1 = (upper + lower) / 2.0;
def OB2 = upper - lower;
def BollOsc = ((tprice - OB1) / OB2 ) * 100;
def xrsi = pine_rsi(tprice, 14);



def bandacero = 0;

def stoc = calc_stoch(tprice, 21, 3);
def marron = (xrsi + xmf + BollOsc + (stoc / 3)) / 2;
def verde = marron + oscp;
def media = ExpAverage(marron, m);
def p1;
def p2;
def p3;
def p4;

If IsNan(Close[-1]) && live_candle == no
{
    p1=Double.nan;
    p2=Double.nan;
    p3=Double.nan;
    p4=Double.nan;
}
else
{
   p1 = marron;
   p2 = verde;
   p3 = media;
   p4 = azul;
}


 
plot Data = p1;
plot Data2 = p2;
plot Data3 = p4;
plot Data4 = p3;

plot Data5 = bandacero;

Data.SetDefaultColor(CreateColor (100, 100, 0));
Data.SetLineWeight(2);
Data2.SetDefaultColor(CreateColor (0, 102, 0));
Data2.SetLineWeight(2);
Data3.SetDefaultColor(CreateColor (0, 0, 252));
Data3.SetLineWeight(1);
Data4.SetDefaultColor(CreateColor (255, 0, 0));
Data4.SetLineWeight(2);
Data5.SetDefaultColor(CreateColor (128, 128, 128));
Data5.SetLineWeight(1);

plot Cloud1Color =0;
Cloud1Color.DefineColor("Color", CreateColor(102, 255, 102));
Cloud1Color.Hide();
plot Cloud2Color =0;
plot Cloud3Color =0;
Cloud3Color.DefineColor("Color", CreateColor(0, 255, 255));
Cloud3Color.Hide();
#input trr =  CreateColor(102, 255, 102);
#
#AddCloud(0, Data3, Cloud3Color.Color("Color"), Cloud3Color.Color("Color"));
#AddCloud(0, Data, Cloud2Color.Color("Color"), Cloud2Color.Color("Color"));
#AddCloud(0, Data2,  Cloud1Color.Color("Color"), Cloud1Color.Color("Color"));
 
Last edited by a moderator:

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
413 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