Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!

Advanced

Fun with ThinkScript

Posted by robert 
Re: Fun with ThinkScript
July 06, 2021 01:25PM
I have 4 conditions in a script for 2 bullish and 2 bearish patterns and need to be able to see if they are both occurring in the same bar. So, is there a way to add space either above or below 2 of the conditions so I can see if both arrows occur at the same bar? They could be overlapping and I would never know it.

plot above = cond2;
above.SetDefaultColor(Color.PINK);
above.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);...add maybe 10 'blank' pixels below it or the distance of 2 arows???

Thanks
Wick Reversal Indicator
July 09, 2021 02:15AM
Would someone please help me with this code? This is a TradingView Wick Reversal code and I would like to convert it into ThinkScript so I can use it in TOS.

Thank you in advance!


#System

#PARAM "Wick _ Multiplier", 2.5, .5, 20
#PARAM "Body_ Percentage" , .25, .1, 1\

If C > O
AND (O - L) >= ((C - O) * Wick_Multiplier)
AND (H - C) <= ((H - L) * Body_Percentage)
OR C < 0
AND (C - L) >= ((O - C) * Wick_Multiplier)
AND (H - C) <= ((H - L) * Body_Percentage)
OR C = O AND NOT C = H
AND (H - L) >= ((H - C) * Wick_Multiplier)
AND (H - C) <= ((H - L) * Body_Percentage)
OR O = H AND C = H
AND H - L >= AVG(H-L, 50) Then
Signal = LongSignal

ElseIf C < O
AND (H - O) >= ((O - C) * Wick_Multiplier)
AND (C - L) <= ((H - L) * Body_Percentage)
OR C > O
AND (H - C) >= ((C - O) * Wick_Multiplier)
AND (C - L) <= ((H - L) * Body_Percentage)
OR C = O AND NOT C = L
AND (H - L) >= ((C - L) * Wick_Multiplier)
AND (C - L) <= ((H - L) * Body_Percentage)
OR O = L AND C = L
AND H - L >= AVG(H-L, 50) Then
Signal = ShortSignal

EndIf
Re: Wick Reversal Indicator
July 09, 2021 08:31AM
For those of you coming here looking for Thinkscript help, you'd be much better served to head over to [usethinkscript.com] as it's MUCH more likely that you'll find an answer to your questions.

R
Hap
Re: Fun with Thinkscript
July 30, 2021 12:51PM
Hey Rigel , is there any way to add alerts at Williams Fractal even mobile alerts , or msg in the thinkorswim msg center ?
Thank you a lot

# Bill Williams Fractal Template
# Coded By: Rigel May 2018

#Define "n" as the number of periods and keep a minimum value of 2 for error handling.
input n=2;

# Williams Fractals are a 5 point lagging indicator that will draw 2 candles behind.
# The purpose of the indicator is to plot points of trend reversals.
# Often these are paired with trailing stop indicators such as Parabolic SAR, Volatility Stop, and SuperTrend.

# Down pointing fractals occur over candles when:
# High(n-2) < High(n)
# High(n-1) < High(n)
# High(n + 1) < High(n)
# High(n + 2) < High(n)
#dnFractal = (high[n-2] < high[n]) and (high[n-1] < high[n]) and (high[n+1] < high[n]) and (high[n+2] < high[n])

def isupfractal = if low < low[1] and low < low[2] and low < low[-1] and low < low[-2] then low else double.nan;
# Up pointing fractals occur under candles when:
# Low(n-2) > Low(n)
# Low(n-1) > Low(n)
# Low(n + 1) > Low(n)
# Low(n + 2) > Low(n)
#upFractal = (low[n-2] > low[n]) and (low[n-1] > low[n]) and (low[n+1] > low[n]) and (low[n+2] > low[n])
def isdownfractal = if high > high[1] and high > high[2] and high > high[-1] and high > high[-2] then high else double.nan;
# Plot the fractals as shapes on the chart.


plot upfractal = if( isupfractal, isupfractal+ (1 * tickSize()) , double.nan);
upfractal.SetPaintingStrategy(paintingStrategy.ARROW_UP);
plot downfractal = if( isdownfractal, isdownfractal - (1 * tickSize()), double.nan);
downfractal.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);
Hap
Re: Fun with Thinkscript
August 02, 2021 04:31AM
Hei there i was wondering could you add alets for the arrows
Code:
Alert(conditional statement, text alert, alert type, sound); ?
Re: Fun with ThinkScript
August 14, 2021 11:13AM
Hey guys, can I use this program to trade turnkey crypto exchange on Nexthash? Whit witch crypto exchanges are compatible. My Bitstamp account got suspended :/

Edited: I advise anyone who goes this route to research soft POS to learn how to easily and untraceable exchange bitcoin for dolars. For example, I use bitcoin SWC poker. I exchange winning for dollars.

SWC: [swcpoker.club]
POS: [elly.com]



Edited 1 time(s). Last edit at 08/20/2021 07:29AM by JamesBasej.
Re: Wick Reversal Indicator
August 14, 2021 11:14AM
Forgot to add a reply.
Need help coding logic for first two bars of day
September 19, 2021 05:42PM
My thinkscript is very limited and I have been trying to figure this out but can't seem to get it to work. I am trying to determine if the second five minute candle's close is higher or lower than the first candle's close. I am sure there is a much easier way and wanted to see if anyone could offer some coding help.
Re: Fun with ThinkScript
September 30, 2021 07:59PM
Hello,

I have been trying to code the following with no success:

The stock has already crossed a certain moving average at least once today has crossed it again. Pretty much checking that this isn't the first cross of the day.

I'm having a hard time with the logic and making sure that it only checks for RTH.

If anybody can help me with this, it'd be much appreciated.
Re: Fun with ThinkScript
October 30, 2021 03:34PM
RichieRick Wrote:
-------------------------------------------------------
> Believe it or not, I understood all of that :-)
> Thanks for you insight on this.
>
> I'm looking for a way to prevent the zigzag AW
> from displaying a line during the unconfirmed
> period. It will either give a red bubble or a
> green one, no white bubble.
> If for example it draws and line with a green
> bubble, and at some point in the future it takes
> back the line and attempts to redraw it, this
> time with a white bubble, the line will simply
> disappear until the "up" is confirmed again, and a
> new line with a new green bubble will appear. [elly.com]
> Thus signaling the end of the trend. Or likely
> near the end.
> I'm just looking for a way to suppress the white
> bubble, or shall we say the unconfirmed status
> from taking place, until the new up trend is done,
> and then it can redraw the line with a new green [swcpoker.club]
> bubble. This will leave me with only an up trend
> line and green bubble, or a down trend line with a
> red bubble.
>
> What you've done is superb. I however, am a
> tinkerer; what can I say:-)
>
> Then again... I may just give up on it since you
> already have it so close to, dare I say
> "perfection" :-)
>
> Again thanks for your insight. It was very
> helpful :-)

Totaly what he said. Really usefull keep this up
Re: Fun with ThinkScript
November 02, 2021 09:47PM
Trying to figure out how to modify this code to include a line from the low of the pivot candle as well. I would like to create a zone from the high AND the low of the same pivot candle and extend each line. Tried to figure it out, but didn't get very far


# +--------------------------------------------------+
# | Example showing how to hide a plot when the |
# | most recent close is not within a certain range. |
# | robert payne |
# | [rrpayne.blogspot.com] |
# +--------------------------------------------------+

# | define a peak and plot it
input magnitude = 5;

def peak = high > Highest(high[1], magnitude) and high >= Highest(high[-magnitude], magnitude);
def peakValue = if peak then high else peakValue[1];
plot peakLine = peakValue;
peakLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
peakLine.SetDefaultColor(Color.CYAN);

# | get the bar numbers for the most recent close
# | and the most recent peak
def lastBar = HighestAll(if IsNaN(close) then 0 else BarNumber());
def peakBar = if peak then BarNumber() else Double.NaN;

# | find the values of the most recent peak and the one before it
def lastPeakValue = GetValue(high, BarNumber() - HighestAll(peakBar));
def prevPeakValue = GetValue(peakValue[1], BarNumber() - HighestAll(peakBar));

# | find the value of the most recent close
def mostRecentClose = HighestAll(if BarNumber() == lastBar then close else 0);

# | define what is considered to be "in range" of the previous peak
input percent = 0.5;

def inRange = mostRecentClose > (prevPeakValue * (1 - percent / 100)) and mostRecentClose < (prevPeakValue * (1 + percent / 100));

# | extend the most recent peak
plot lastPeakExtension = if BarNumber() >= HighestAll(peakBar) then lastPeakValue else Double.NaN;
lastPeakExtension.SetDefaultColor(Color.CYAN);
# | extend the previous peak only if the most recent close value is "in range"
plot prevPeakExtension = if BarNumber() >= HighestAll(peakBar) - 1 then prevPeakValue else Double.NaN;
prevPeakExtension.SetDefaultColor(Color.Dark_Orange);
prevPeakExtension.SetHiding(!inRange);
Re: Fun with ThinkScript
November 04, 2021 10:35AM
what should I add to make it blue?

AddChart(
high = tema(high),
low = tema(low),
open = tema(open),
close = tema(close),
type = chartType.LINE );
Re: Fun with ThinkScript
November 24, 2021 11:40AM
Re: what should I add to make it blue?
January 08, 2022 06:27PM
Add this parameter

growColor = color.blue,
Re: Fun with ThinkScript
July 11, 2022 11:55AM
SARA Wrote:
-------------------------------------------------------
> what should I add to make it blue? https://nexthash.com/otc-trading-platform
>
> AddChart(
> high = tema(high),
> low = tema(low),
> open = tema(open),
> close = tema(close),
> type = chartType.LINE );

plot above = cond2;
above.SetDefaultColor(Color.PINK);
above.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);...add maybe 10 'blank' pixels below it or the distance of 2 arows???
I used this code when trading for become a cbd distributor



Edited 1 time(s). Last edit at 07/14/2022 04:08PM by JamesBasej.
Matrix Series for ThinkorSwim V1.0
August 08, 2022 01:41PM


#DESCRIPTION
#Please use the following AFL on your exisitng AMIBROKER Chart & get a edge in
#identifying Accumulation/Distribution zone of any market.
#Each levels can act like support & resistance
#( watch for +/- 200 levels & the dots when appear on the chart )
#Title of the Flower Chart will go RED if we are entering in a Distribution
#phase & Green for Accumulation.
#This is a modified RENKO chart & should be used with MPLITE & any Momentum
#indicator combination for best results.
#
#There’re 3 ways to use it. I usually get entry position when :
#1. Candle upward before / after cross the zero line
#2. Candle downward but real candle is sideways. This will be best when price is in oversold area.
#3. Candle downward and begin to change from big to small. It is usually followed by significant movement.
#When down candle with the red real candle is occur, it almost certainly bearish signal.
#FYI, I use it in daily chart.

declare lower;

#INPUTS
input Smoother = 5;
input SupResPeriod = 50;
input SupResPercentage = 100;
input PricePeriod = 16;
input ob = 200;
input os = -200;
input showColorBars = no; #COLOR BARS
input showDynamics = no; #Dynamic zones
input showOBOS = yes; #Show OB/OS

#LOGIC
def nn = Smoother;
def ys1 = (high + low + close * 2) / 4;
def rk3 = ExpAverage(ys1, nn);
def rk4 = StDev(ys1, nn);
def rk5 = (ys1 - rk3) * 200 / rk4;
def rk6 = ExpAverage(rk5, nn);
def up = ExpAverage(rk6, nn);
def down = ExpAverage(up, nn);
def Oo = If(up < down, up, down);
def Hh = Oo;
def Ll = If(up < down, down, up);
def Cc = Ll;


def Lookback = SupResPeriod;
def PerCent = SupResPercentage;
def Pds = PricePeriod;

def C3 = CCI(length = Pds);

def Osc = C3;
def Value1 = Osc;
def Value2 = Highest(Value1, Lookback);
def Value3 = Lowest(Value1, Lookback);
def Value4 = Value2 - Value3;
def Value5 = Value4 * (PerCent / 100);
def ResistanceLine = Value3 + Value5;
def SupportLine = Value2 - Value5;

#CUSTOM CANDLES
def cUpO;
def cUpH;
def cUpL;
def cUpC;
if up > down
then {
cUpO = oo;
cUpH = hh;
cUpL = ll;
cUpC = cc;
} else {
cUpO = Double.NaN;
cUpH = Double.NaN;
cUpL = Double.NaN;
cUpC = Double.NaN;
}

def cDnO;
def cDnH;
def cDnL;
def cDnC;
if up < down
then {
cDnO = Oo;
cDnH = Hh;
cDnL = Ll;
cDnC = Cc;
} else {
cdnO = Double.NaN;
cdnH = Double.NaN;
cdnL = Double.NaN;
cdnC = Double.NaN;
}

AddChart(high = cUpH, low = cUpL, open = cUpC, close = cUpO, type = ChartType.CANDLE, COLOR.GREEN);
AddChart(high = cDnH, low = cDnL, open = cDnO, close = cDnC, type = ChartType.CANDLE, COLOR.RED);
AddChart(high = cUpH, low = cUpL, open = cUpO, close = cUpC, type = ChartType.CANDLE, growcolor = COLOR.GREEN);
AddChart(high = cDnH, low = cDnL, open = cDnC, close = cDnO, type = ChartType.CANDLE, growcolor = COLOR.RED);

#COLORBARS
AssignPriceColor(if showColorBars then
if Oo > Cc then COLOR.RED else if up > down then COLOR.GREEN
else COLOR.RED
else
COLOR.CURRENT
);

#PLOTS
plot pResistanceLine = ResistanceLine;
pResistanceLine.SetHiding(!showDynamics);

plot pSupportLine = SupportLine;
pSupportLine.SetHiding(!showDynamics);

def UpShape = if up > ob and up > down then highest(up,1) + 20 else if up > ob and up < down then highest(down,1) + 20 else Double.NaN;

def DownShape = if down < os and up > down then lowest(down,1) - 20 else if
down < os and up < down then lowest(up,1) - 20 else Double.NaN;

def sState = if !isNan(UpShape) then 100 else if !isNan(DownShape) then -100 else sState[1];

plot pUP = UpShape;
pUP.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
pUP.SetDefaultColor(Color.CYAN);
pUP.SetLineWeight(1);

plot pDown = DownShape;
pDown.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
pDown.SetDefaultColor(Color.CYAN);
pDown.SetLineWeight(1);
;

plot pOB = OB;
pOB.SetHiding(!showOBOS);

plot pOS = OS;
pOS.SetHiding(!showOBOS);
Phoenix Finder Trend Strength Indicator
August 08, 2022 01:27PM
Fresh version of the Phoenix Finder indicator for ThinkorSwim. Plots candles for 14 stocks based on Phoenix Strength. It can help track stocks in a specific sector and identify trends based on Phoenix Strength and overall conditions







declare lower;

input symbol1 = "QQQ";
input symbol2 = "SPY";
input symbol3 = "AAPL";
input symbol4 = "MSFT";
input symbol5 = "PLUG";
input symbol6 = "TSLA";
input symbol7 = "GOOG";
input symbol8 = "CRM";
input symbol9 = "NIO";
input symbol10 = "SNAP";
input symbol11 = "PTON";
input symbol12 = "ZM";
input symbol13 = "FSLY";
input symbol14 = "AMD";
def symbol1Signal = 1;
def symbol2Signal = 2;
def symbol3Signal = 3;
def symbol4Signal = 4;
def symbol5Signal = 5;
def symbol6Signal = 6;
def symbol7Signal = 7;
def symbol8Signal = 8;
def symbol9Signal = 9;
def symbol10Signal = 10;
def symbol11Signal = 11;
def symbol12Signal = 12;
def symbol13Signal = 13;
def symbol14Signal = 14;
plot break155 = 15.5;
plot break145 = 14.5;
plot break135 = 13.5;
plot break125 = 12.5;
plot break115 = 11.5;
plot break105 = 10.5;
plot break95 = 9.5;
plot break85 = 8.5;
plot break75 = 7.5;
plot break65 = 6.5;
plot break55 = 5.5;
plot break45 = 4.5;
plot break35 = 3.5;
plot break25 = 2.5;
plot break15 = 1.5;
break155.HideBubble();
break145.HideBubble();
break135.HideBubble();
break125.HideBubble();
break115.HideBubble();
break105.HideBubble();
break95.HideBubble();
break85.HideBubble();
break75.HideBubble();
break65.HideBubble();
break55.HideBubble();
break45.HideBubble();
break35.HideBubble();
break25.HideBubble();
break15.HideBubble();
break155.HideBubble();
break145.HideBubble();
break135.HideTitle();
break125.HideTitle();
break115.HideTitle();
break105.HideTitle();
break95.HideTitle();
break85.HideTitle();
break75.HideTitle();
break65.HideTitle();
break55.HideTitle();
break45.HideTitle();
break35.HideTitle();
break25.HideTitle();
break15.HideTitle();
break155.SetDefaultColor(Color.GRAY);
break145.SetDefaultColor(Color.GRAY);
break135.SetDefaultColor(Color.GRAY);
break125.SetDefaultColor(Color.GRAY);
break115.SetDefaultColor(Color.GRAY);
break105.SetDefaultColor(Color.GRAY);
break95.SetDefaultColor(Color.GRAY);
break85.SetDefaultColor(Color.GRAY);
break75.SetDefaultColor(Color.GRAY);
break65.SetDefaultColor(Color.GRAY);
break55.SetDefaultColor(Color.GRAY);
break45.SetDefaultColor(Color.GRAY);
break35.SetDefaultColor(Color.GRAY);
break25.SetDefaultColor(Color.GRAY);
break15.SetDefaultColor(Color.GRAY);


def x = -5;
def y = -2;
def Length1 = 5;
def Length2 = 8;
def Length3 = 13;
def Length4 = 21;
def Length5 = 34;


################## ----------- SYMBOL #1
def ema1Symbol1 = expAverage(close(symbol1), Length1);
def ema2Symbol1 = expAverage(close(symbol1), Length2);
def ema3Symbol1 = expAverage(close(symbol1), Length3);
def ema4Symbol1 = expAverage(close(symbol1), Length4);

def u1Symbol1 = ema1Symbol1 > ema2Symbol1;
def u2Symbol1 = ema2Symbol1 > ema3Symbol1;
def u3Symbol1 = ema3Symbol1 > ema4Symbol1;

def d1Symbol1 = ema1Symbol1 < ema2Symbol1;
def d2Symbol1 = ema2Symbol1 < ema3Symbol1;
def d3Symbol1 = ema3Symbol1 < ema4Symbol1;

def trendStrengthSymbol1 = if (u1Symbol1 and u2Symbol1 and u3Symbol1) then 2 else if (u1Symbol1 and u2Symbol1 and !u3Symbol1) then 1 else if (d1Symbol1 and d2Symbol1 and d3Symbol1) then -2 else if (d1Symbol1 and d2Symbol1 and !d3Symbol1) then -1 else 0;

plot Symbol1Plot1 = if trendStrengthSymbol1 == 2 then symbol1Signal else Double.NaN;
Symbol1Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol1Plot1.SetLineWeight(3);
Symbol1Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol1Plot2 = if trendStrengthSymbol1 == 1 then symbol1Signal else Double.NaN;
Symbol1Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol1Plot2.SetLineWeight(3);
Symbol1Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol1Plot3 = if trendStrengthSymbol1 == -2 then symbol1Signal else Double.NaN;
Symbol1Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol1Plot3.SetLineWeight(3);
Symbol1Plot3.AssignValueColor(COLOR.RED);
plot Symbol1Plot4 = if trendStrengthSymbol1 == -1 then symbol1Signal else Double.NaN;
Symbol1Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol1Plot4.SetLineWeight(3);
Symbol1Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol1Plot5 = if trendStrengthSymbol1 == 0 then symbol1Signal else Double.NaN;
Symbol1Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol1Plot5.SetLineWeight(3);
Symbol1Plot5.AssignValueColor(COLOR.YELLOW);
Symbol1Plot1.HideTitle();
Symbol1Plot2.HideTitle();
Symbol1Plot3.HideTitle();
Symbol1Plot4.HideTitle();
Symbol1Plot5.HideTitle();
def highestBarSymbol1 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol1 = highestBarSymbol1 - x;
AddChartBubble( barNumber() == referenceBarSymbol1,symbol1Signal,"1:"+symbol1,if trendStrengthSymbol1[5] == 2 then Color.GREEN else if trendStrengthSymbol1[5] == 1then Color.DARK_GRAY else if trendStrengthSymbol1[5] == -2 then Color.RED else if trendStrengthSymbol1[5] == -1 then Color.DARK_RED else if trendStrengthSymbol1[5] == 0 then Color.YELLOW else Color.GRAY,yes);
AddLabel(yes,trendStrengthSymbol1);




################## ----------- SYMBOL #2
def ema1Symbol2 = expAverage(close(symbol2), Length1);
def ema2Symbol2 = expAverage(close(symbol2), Length2);
def ema3Symbol2 = expAverage(close(symbol2), Length3);
def ema4Symbol2 = expAverage(close(symbol2), Length4);

def u1Symbol2 = ema1Symbol2 > ema2Symbol2;
def u2Symbol2 = ema2Symbol2 > ema3Symbol2;
def u3Symbol2 = ema3Symbol2 > ema4Symbol2;

def d1Symbol2 = ema1Symbol2 < ema2Symbol2;
def d2Symbol2 = ema2Symbol2 < ema3Symbol2;
def d3Symbol2 = ema3Symbol2 < ema4Symbol2;

def trendStrengthSymbol2 = if (u1Symbol2 and u2Symbol2 and u3Symbol2) then 2 else if (u1Symbol2 and u2Symbol2 and !u3Symbol2) then 1 else if (d1Symbol2 and d2Symbol2 and d3Symbol2) then -2 else if (d1Symbol2 and d2Symbol2 and !d3Symbol2) then -1 else 0;

plot Symbol2Plot1 = if trendStrengthSymbol2 == 2 then symbol2Signal else Double.NaN;
Symbol2Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol2Plot1.SetLineWeight(3);
Symbol2Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol2Plot2 = if trendStrengthSymbol2 == 1 then symbol2Signal else Double.NaN;
Symbol2Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol2Plot2.SetLineWeight(3);
Symbol2Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol2Plot3 = if trendStrengthSymbol2 == -2 then symbol2Signal else Double.NaN;
Symbol2Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol2Plot3.SetLineWeight(3);
Symbol2Plot3.AssignValueColor(COLOR.RED);
plot Symbol2Plot4 = if trendStrengthSymbol2 == -1 then symbol2Signal else Double.NaN;
Symbol2Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol2Plot4.SetLineWeight(3);
Symbol2Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol2Plot5 = if trendStrengthSymbol2 == 0 then symbol2Signal else Double.NaN;
Symbol2Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol2Plot5.SetLineWeight(3);
Symbol2Plot5.AssignValueColor(Color.YELLOW);
Symbol2Plot1.HideTitle();
Symbol2Plot2.HideTitle();
Symbol2Plot3.HideTitle();
Symbol2Plot4.HideTitle();
Symbol2Plot5.HideTitle();
def highestBarSymbol2 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol2 = highestBarSymbol2 - y;
AddChartBubble( barNumber() == referenceBarSymbol2,symbol2Signal,"2:"+symbol2,if trendStrengthSymbol2[2] == 2 then Color.GREEN else if trendStrengthSymbol2[2] == 1then Color.DARK_GRAY else if trendStrengthSymbol2[2] == -2 then Color.RED else if trendStrengthSymbol2[2] == -1 then Color.DARK_RED else if trendStrengthSymbol2[2] == 0 then Color.YELLOW else Color.GRAY,yes);




################## ----------- SYMBOL #3
def ema1Symbol3 = expAverage(close(symbol3), Length1);
def ema2Symbol3 = expAverage(close(symbol3), Length2);
def ema3Symbol3 = expAverage(close(symbol3), Length3);
def ema4Symbol3 = expAverage(close(symbol3), Length4);

def u1Symbol3 = ema1Symbol3 > ema2Symbol3;
def u2Symbol3 = ema2Symbol3 > ema3Symbol3;
def u3Symbol3 = ema3Symbol3 > ema4Symbol3;

def d1Symbol3 = ema1Symbol3 < ema2Symbol3;
def d2Symbol3 = ema2Symbol3 < ema3Symbol3;
def d3Symbol3 = ema3Symbol3 < ema4Symbol3;

def trendStrengthSymbol3 = if (u1Symbol3 and u2Symbol3 and u3Symbol3) then 2 else if (u1Symbol3 and u2Symbol3 and !u3Symbol3) then 1 else if (d1Symbol3 and d2Symbol3 and d3Symbol3) then -2 else if (d1Symbol3 and d2Symbol3 and !d3Symbol3) then -1 else 0;

plot Symbol3Plot1 = if trendStrengthSymbol3 == 2 then symbol3Signal else Double.NaN;
Symbol3Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol3Plot1.SetLineWeight(3);
Symbol3Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol3Plot2 = if trendStrengthSymbol3 == 1 then symbol3Signal else Double.NaN;
Symbol3Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol3Plot2.SetLineWeight(3);
Symbol3Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol3Plot3 = if trendStrengthSymbol3 == -2 then symbol3Signal else Double.NaN;
Symbol3Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol3Plot3.SetLineWeight(3);
Symbol3Plot3.AssignValueColor(COLOR.RED);
plot Symbol3Plot4 = if trendStrengthSymbol3 == -1 then symbol3Signal else Double.NaN;
Symbol3Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol3Plot4.SetLineWeight(3);
Symbol3Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol3Plot5 = if trendStrengthSymbol3 == 0 then symbol3Signal else Double.NaN;
Symbol3Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol3Plot5.SetLineWeight(3);
Symbol3Plot5.AssignValueColor(COLOR.YELLOW);
Symbol3Plot1.HideTitle();
Symbol3Plot2.HideTitle();
Symbol3Plot3.HideTitle();
Symbol3Plot4.HideTitle();
Symbol3Plot5.HideTitle();
def highestBarSymbol3 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol3 = highestBarSymbol3 - x;
AddChartBubble( barNumber() == referenceBarSymbol3,symbol3Signal,"3:"+symbol3,if trendStrengthSymbol3[5] == 2 then Color.GREEN else if trendStrengthSymbol3[5] == 1then Color.DARK_GRAY else if trendStrengthSymbol3[5] == -2 then Color.RED else if trendStrengthSymbol3[5] == -1 then Color.DARK_RED else if trendStrengthSymbol3[5] == 0 then Color.YELLOW else Color.GRAY);



################## ----------- SYMBOL #4
def ema1Symbol4 = expAverage(close(symbol4), Length1);
def ema2Symbol4 = expAverage(close(symbol4), Length2);
def ema3Symbol4 = expAverage(close(symbol4), Length3);
def ema4Symbol4 = expAverage(close(symbol4), Length4);

def u1Symbol4 = ema1Symbol4 > ema2Symbol4;
def u2Symbol4 = ema2Symbol4 > ema3Symbol4;
def u3Symbol4 = ema3Symbol4 > ema4Symbol4;

def d1Symbol4 = ema1Symbol4 < ema2Symbol4;
def d2Symbol4 = ema2Symbol4 < ema3Symbol4;
def d3Symbol4 = ema3Symbol4 < ema4Symbol4;

def trendStrengthSymbol4 = if (u1Symbol4 and u2Symbol4 and u3Symbol4) then 2 else if (u1Symbol4 and u2Symbol4 and !u3Symbol4) then 1 else if (d1Symbol4 and d2Symbol4 and d3Symbol4) then -2 else if (d1Symbol4 and d2Symbol4 and !d3Symbol4) then -1 else 0;

plot Symbol4Plot1 = if trendStrengthSymbol4 == 2 then symbol4Signal else Double.NaN;
Symbol4Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol4Plot1.SetLineWeight(3);
Symbol4Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol4Plot2 = if trendStrengthSymbol4 == 1 then symbol4Signal else Double.NaN;
Symbol4Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol4Plot2.SetLineWeight(3);
Symbol4Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol4Plot3 = if trendStrengthSymbol4 == -2 then symbol4Signal else Double.NaN;
Symbol4Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol4Plot3.SetLineWeight(3);
Symbol4Plot3.AssignValueColor(COLOR.RED);
plot Symbol4Plot4 = if trendStrengthSymbol4 == -1 then symbol4Signal else Double.NaN;
Symbol4Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol4Plot4.SetLineWeight(3);
Symbol4Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol4Plot5 = if trendStrengthSymbol4 == 0 then symbol4Signal else Double.NaN;
Symbol4Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol4Plot5.SetLineWeight(3);
Symbol4Plot5.AssignValueColor(COLOR.YELLOW);
Symbol4Plot1.HideTitle();
Symbol4Plot2.HideTitle();
Symbol4Plot3.HideTitle();
Symbol4Plot4.HideTitle();
Symbol4Plot5.HideTitle();
def highestBarSymbol4 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol4 = highestBarSymbol4 - y;
AddChartBubble( barNumber() == referenceBarSymbol4,symbol4Signal,"4:"+symbol4,if trendStrengthSymbol4[2] == 2 then Color.GREEN else if trendStrengthSymbol4[2] == 1then Color.DARK_GRAY else if trendStrengthSymbol4[2] == -2 then Color.RED else if trendStrengthSymbol4[2] == -1 then Color.DARK_RED else if trendStrengthSymbol4[2] == 0 then Color.YELLOW else Color.GRAY,yes);




################## ----------- SYMBOL #5
def ema1Symbol5 = expAverage(close(symbol5), Length1);
def ema2Symbol5 = expAverage(close(symbol5), Length2);
def ema3Symbol5 = expAverage(close(symbol5), Length3);
def ema4Symbol5 = expAverage(close(symbol5), Length4);

def u1Symbol5 = ema1Symbol5 > ema2Symbol5;
def u2Symbol5 = ema2Symbol5 > ema3Symbol5;
def u3Symbol5 = ema3Symbol5 > ema4Symbol5;

def d1Symbol5 = ema1Symbol5 < ema2Symbol5;
def d2Symbol5 = ema2Symbol5 < ema3Symbol5;
def d3Symbol5 = ema3Symbol5 < ema4Symbol5;

def trendStrengthSymbol5 = if (u1Symbol5 and u2Symbol5 and u3Symbol5) then 2 else if (u1Symbol5 and u2Symbol5 and !u3Symbol5) then 1 else if (d1Symbol5 and d2Symbol5 and d3Symbol5) then -2 else if (d1Symbol5 and d2Symbol5 and !d3Symbol5) then -1 else 0;

plot Symbol5Plot1 = if trendStrengthSymbol5 == 2 then symbol5Signal else Double.NaN;
Symbol5Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol5Plot1.SetLineWeight(3);
Symbol5Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol5Plot2 = if trendStrengthSymbol5 == 1 then symbol5Signal else Double.NaN;
Symbol5Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol5Plot2.SetLineWeight(3);
Symbol5Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol5Plot3 = if trendStrengthSymbol5 == -2 then symbol5Signal else Double.NaN;
Symbol5Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol5Plot3.SetLineWeight(3);
Symbol5Plot3.AssignValueColor(COLOR.RED);
plot Symbol5Plot4 = if trendStrengthSymbol5 == -1 then symbol5Signal else Double.NaN;
Symbol5Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol5Plot4.SetLineWeight(3);
Symbol5Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol5Plot5 = if trendStrengthSymbol5 == 0 then symbol5Signal else Double.NaN;
Symbol5Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol5Plot5.SetLineWeight(3);
Symbol5Plot5.AssignValueColor(COLOR.YELLOW);
Symbol5Plot1.HideTitle();
Symbol5Plot2.HideTitle();
Symbol5Plot3.HideTitle();
Symbol5Plot4.HideTitle();
Symbol5Plot5.HideTitle();
def highestBarSymbol5 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol5 = highestBarSymbol5 - x;
AddChartBubble( barNumber() == referenceBarSymbol5,symbol5Signal,"5:"+symbol5,if trendStrengthSymbol5[5] == 2 then Color.GREEN else if trendStrengthSymbol5[5] == 1then Color.DARK_GRAY else if trendStrengthSymbol5[5] == -2 then Color.RED else if trendStrengthSymbol5[5] == -1 then Color.DARK_RED else if trendStrengthSymbol5[5] == 0 then Color.YELLOW else if IsNaN(trendStrengthSymbol5[5]) then Color.WHITE else Color.GRAY);
AddLabel(yes,trendStrengthSymbol5);


################## ----------- SYMBOL #6
def ema1Symbol6 = expAverage(close(symbol6), Length1);
def ema2Symbol6 = expAverage(close(symbol6), Length2);
def ema3Symbol6 = expAverage(close(symbol6), Length3);
def ema4Symbol6 = expAverage(close(symbol6), Length4);

def u1Symbol6 = ema1Symbol6 > ema2Symbol6;
def u2Symbol6 = ema2Symbol6 > ema3Symbol6;
def u3Symbol6 = ema3Symbol6 > ema4Symbol6;

def d1Symbol6 = ema1Symbol6 < ema2Symbol6;
def d2Symbol6 = ema2Symbol6 < ema3Symbol6;
def d3Symbol6 = ema3Symbol6 < ema4Symbol6;

def trendStrengthSymbol6 = if (u1Symbol6 and u2Symbol6 and u3Symbol6) then 2 else if (u1Symbol6 and u2Symbol6 and !u3Symbol6) then 1 else if (d1Symbol6 and d2Symbol6 and d3Symbol6) then -2 else if (d1Symbol6 and d2Symbol6 and !d3Symbol6) then -1 else 0;

plot Symbol6Plot1 = if trendStrengthSymbol6 == 2 then symbol6Signal else Double.NaN;
Symbol6Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol6Plot1.SetLineWeight(3);
Symbol6Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol6Plot2 = if trendStrengthSymbol6 == 1 then symbol6Signal else Double.NaN;
Symbol6Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol6Plot2.SetLineWeight(3);
Symbol6Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol6Plot3 = if trendStrengthSymbol6 == -2 then symbol6Signal else Double.NaN;
Symbol6Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol6Plot3.SetLineWeight(3);
Symbol6Plot3.AssignValueColor(COLOR.RED);
plot Symbol6Plot4 = if trendStrengthSymbol6 == -1 then symbol6Signal else Double.NaN;
Symbol6Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol6Plot4.SetLineWeight(3);
Symbol6Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol6Plot5 = if trendStrengthSymbol6 == 0 then symbol6Signal else Double.NaN;
Symbol6Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol6Plot5.SetLineWeight(3);
Symbol6Plot5.AssignValueColor(COLOR.YELLOW);
Symbol6Plot1.HideTitle();
Symbol6Plot2.HideTitle();
Symbol6Plot3.HideTitle();
Symbol6Plot4.HideTitle();
Symbol6Plot5.HideTitle();
def highestBarSymbol6 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol6 = highestBarSymbol6 - y;
AddChartBubble( barNumber() == referenceBarSymbol6,symbol6Signal,"6:"+symbol6,if trendStrengthSymbol6[2] == 2 then Color.GREEN else if trendStrengthSymbol6[2] == 1then Color.DARK_GRAY else if trendStrengthSymbol6[2] == -2 then Color.RED else if trendStrengthSymbol6[2] == -1 then Color.DARK_RED else if trendStrengthSymbol6[2] == 0 then Color.YELLOW else Color.GRAY,yes);



################## ----------- SYMBOL #7
def ema1Symbol7 = expAverage(close(symbol7), Length1);
def ema2Symbol7 = expAverage(close(symbol7), Length2);
def ema3Symbol7 = expAverage(close(symbol7), Length3);
def ema4Symbol7 = expAverage(close(symbol7), Length4);

def u1Symbol7 = ema1Symbol7 > ema2Symbol7;
def u2Symbol7 = ema2Symbol7 > ema3Symbol7;
def u3Symbol7 = ema3Symbol7 > ema4Symbol7;

def d1Symbol7 = ema1Symbol7 < ema2Symbol7;
def d2Symbol7 = ema2Symbol7 < ema3Symbol7;
def d3Symbol7 = ema3Symbol7 < ema4Symbol7;

def trendStrengthSymbol7 = if (u1Symbol7 and u2Symbol7 and u3Symbol7) then 2 else if (u1Symbol7 and u2Symbol7 and !u3Symbol7) then 1 else if (d1Symbol7 and d2Symbol7 and d3Symbol7) then -2 else if (d1Symbol7 and d2Symbol7 and !d3Symbol7) then -1 else 0;

plot Symbol7Plot1 = if trendStrengthSymbol7 == 2 then symbol7Signal else Double.NaN;
Symbol7Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol7Plot1.SetLineWeight(3);
Symbol7Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol7Plot2 = if trendStrengthSymbol7 == 1 then symbol7Signal else Double.NaN;
Symbol7Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol7Plot2.SetLineWeight(3);
Symbol7Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol7Plot3 = if trendStrengthSymbol7 == -2 then symbol7Signal else Double.NaN;
Symbol7Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol7Plot3.SetLineWeight(3);
Symbol7Plot3.AssignValueColor(COLOR.RED);
plot Symbol7Plot4 = if trendStrengthSymbol7 == -1 then symbol7Signal else Double.NaN;
Symbol7Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol7Plot4.SetLineWeight(3);
Symbol7Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol7Plot5 = if trendStrengthSymbol7 == 0 then symbol7Signal else Double.NaN;
Symbol7Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol7Plot5.SetLineWeight(3);
Symbol7Plot5.AssignValueColor(COLOR.YELLOW);
Symbol7Plot1.HideTitle();
Symbol7Plot2.HideTitle();
Symbol7Plot3.HideTitle();
Symbol7Plot4.HideTitle();
Symbol7Plot5.HideTitle();
def highestBarSymbol7 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol7 = highestBarSymbol7 - x;
AddChartBubble( barNumber() == referenceBarSymbol7,symbol7Signal,"7:"+symbol7,if trendStrengthSymbol7[5] == 2 then Color.GREEN else if trendStrengthSymbol7[5] == 1then Color.DARK_GRAY else if trendStrengthSymbol7[5] == -2 then Color.RED else if trendStrengthSymbol7[5] == -1 then Color.DARK_RED else if trendStrengthSymbol7[5] == 0 then Color.YELLOW else Color.GRAY,yes);



################## ----------- SYMBOL #8
def ema1Symbol8 = expAverage(close(symbol8), Length1);
def ema2Symbol8 = expAverage(close(symbol8), Length2);
def ema3Symbol8 = expAverage(close(symbol8), Length3);
def ema4Symbol8 = expAverage(close(symbol8), Length4);

def u1Symbol8 = ema1Symbol8 > ema2Symbol8;
def u2Symbol8 = ema2Symbol8 > ema3Symbol8;
def u3Symbol8 = ema3Symbol8 > ema4Symbol8;

def d1Symbol8 = ema1Symbol8 < ema2Symbol8;
def d2Symbol8 = ema2Symbol8 < ema3Symbol8;
def d3Symbol8 = ema3Symbol8 < ema4Symbol8;

def trendStrengthSymbol8 = if (u1Symbol8 and u2Symbol8 and u3Symbol8) then 2 else if (u1Symbol8 and u2Symbol8 and !u3Symbol8) then 1 else if (d1Symbol8 and d2Symbol8 and d3Symbol8) then -2 else if (d1Symbol8 and d2Symbol8 and !d3Symbol8) then -1 else 0;

plot Symbol8Plot1 = if trendStrengthSymbol8 == 2 then symbol8Signal else Double.NaN;
Symbol8Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol8Plot1.SetLineWeight(3);
Symbol8Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol8Plot2 = if trendStrengthSymbol8 == 1 then symbol8Signal else Double.NaN;
Symbol8Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol8Plot2.SetLineWeight(3);
Symbol8Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol8Plot3 = if trendStrengthSymbol8 == -2 then symbol8Signal else Double.NaN;
Symbol8Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol8Plot3.SetLineWeight(3);
Symbol8Plot3.AssignValueColor(COLOR.RED);
plot Symbol8Plot4 = if trendStrengthSymbol8 == -1 then symbol8Signal else Double.NaN;
Symbol8Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol8Plot4.SetLineWeight(3);
Symbol8Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol8Plot5 = if trendStrengthSymbol8 == 0 then symbol8Signal else Double.NaN;
Symbol8Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol8Plot5.SetLineWeight(3);
Symbol8Plot5.AssignValueColor(COLOR.YELLOW);
Symbol8Plot1.HideTitle();
Symbol8Plot2.HideTitle();
Symbol8Plot3.HideTitle();
Symbol8Plot4.HideTitle();
Symbol8Plot5.HideTitle();
def highestBarSymbol8 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol8 = highestBarSymbol8 - y;
AddChartBubble( barNumber() == referenceBarSymbol8,symbol8Signal,"8:"+symbol8,if trendStrengthSymbol8[2] == 2 then Color.GREEN else if trendStrengthSymbol8[2] == 1then Color.DARK_GRAY else if trendStrengthSymbol8[2] == -2 then Color.RED else if trendStrengthSymbol8[2] == -1 then Color.DARK_RED else if trendStrengthSymbol8[2] == 0 then Color.YELLOW else Color.GRAY,yes);




################## ----------- SYMBOL #9
def ema1Symbol9 = expAverage(close(symbol9), Length1);
def ema2Symbol9 = expAverage(close(symbol9), Length2);
def ema3Symbol9 = expAverage(close(symbol9), Length3);
def ema4Symbol9 = expAverage(close(symbol9), Length4);

def u1Symbol9 = ema1Symbol9 > ema2Symbol9;
def u2Symbol9 = ema2Symbol9 > ema3Symbol9;
def u3Symbol9 = ema3Symbol9 > ema4Symbol9;

def d1Symbol9 = ema1Symbol9 < ema2Symbol9;
def d2Symbol9 = ema2Symbol9 < ema3Symbol9;
def d3Symbol9 = ema3Symbol9 < ema4Symbol9;

def trendStrengthSymbol9 = if (u1Symbol9 and u2Symbol9 and u3Symbol9) then 2 else if (u1Symbol9 and u2Symbol9 and !u3Symbol9) then 1 else if (d1Symbol9 and d2Symbol9 and d3Symbol9) then -2 else if (d1Symbol9 and d2Symbol9 and !d3Symbol9) then -1 else 0;

plot Symbol9Plot1 = if trendStrengthSymbol9 == 2 then symbol9Signal else Double.NaN;
Symbol9Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol9Plot1.SetLineWeight(3);
Symbol9Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol9Plot2 = if trendStrengthSymbol9 == 1 then symbol9Signal else Double.NaN;
Symbol9Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol9Plot2.SetLineWeight(3);
Symbol9Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol9Plot3 = if trendStrengthSymbol9 == -2 then symbol9Signal else Double.NaN;
Symbol9Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol9Plot3.SetLineWeight(3);
Symbol9Plot3.AssignValueColor(COLOR.RED);
plot Symbol9Plot4 = if trendStrengthSymbol9 == -1 then symbol9Signal else Double.NaN;
Symbol9Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol9Plot4.SetLineWeight(3);
Symbol9Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol9Plot5 = if trendStrengthSymbol9 == 0 then symbol9Signal else Double.NaN;
Symbol9Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol9Plot5.SetLineWeight(3);
Symbol9Plot5.AssignValueColor(COLOR.YELLOW);
Symbol9Plot1.HideTitle();
Symbol9Plot2.HideTitle();
Symbol9Plot3.HideTitle();
Symbol9Plot4.HideTitle();
Symbol9Plot5.HideTitle();
def highestBarSymbol9 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol9 = highestBarSymbol9 - x;
AddChartBubble( barNumber() == referenceBarSymbol9,symbol9Signal,"9:"+symbol9,if trendStrengthSymbol9[5] == 2 then Color.GREEN else if trendStrengthSymbol9[5] == 1then Color.DARK_GRAY else if trendStrengthSymbol9[5] == -2 then Color.RED else if trendStrengthSymbol9[5] == -1 then Color.DARK_RED else if trendStrengthSymbol9[5] == 0 then Color.YELLOW else Color.GRAY,yes);




################## ----------- SYMBOL #10
def ema1Symbol10 = expAverage(close(symbol10), Length1);
def ema2Symbol10 = expAverage(close(symbol10), Length2);
def ema3Symbol10 = expAverage(close(symbol10), Length3);
def ema4Symbol10 = expAverage(close(symbol10), Length4);

def u1Symbol10 = ema1Symbol10 > ema2Symbol10;
def u2Symbol10 = ema2Symbol10 > ema3Symbol10;
def u3Symbol10 = ema3Symbol10 > ema4Symbol10;

def d1Symbol10 = ema1Symbol10 < ema2Symbol10;
def d2Symbol10 = ema2Symbol10 < ema3Symbol10;
def d3Symbol10 = ema3Symbol10 < ema4Symbol10;

def trendStrengthSymbol10 = if (u1Symbol10 and u2Symbol10 and u3Symbol10) then 2 else if (u1Symbol10 and u2Symbol10 and !u3Symbol10) then 1 else if (d1Symbol10 and d2Symbol10 and d3Symbol10) then -2 else if (d1Symbol10 and d2Symbol10 and !d3Symbol10) then -1 else 0;

plot Symbol10Plot1 = if trendStrengthSymbol10 == 2 then symbol10Signal else Double.NaN;
Symbol10Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol10Plot1.SetLineWeight(3);
Symbol10Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol10Plot2 = if trendStrengthSymbol10 == 1 then symbol10Signal else Double.NaN;
Symbol10Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol10Plot2.SetLineWeight(3);
Symbol10Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol10Plot3 = if trendStrengthSymbol10 == -2 then symbol10Signal else Double.NaN;
Symbol10Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol10Plot3.SetLineWeight(3);
Symbol10Plot3.AssignValueColor(COLOR.RED);
plot Symbol10Plot4 = if trendStrengthSymbol10 == -1 then symbol10Signal else Double.NaN;
Symbol10Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol10Plot4.SetLineWeight(3);
Symbol10Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol10Plot5 = if trendStrengthSymbol10 == 0 then symbol10Signal else Double.NaN;
Symbol10Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol10Plot5.SetLineWeight(3);
Symbol10Plot5.AssignValueColor(COLOR.YELLOW);
Symbol10Plot1.HideTitle();
Symbol10Plot2.HideTitle();
Symbol10Plot3.HideTitle();
Symbol10Plot4.HideTitle();
Symbol10Plot5.HideTitle();
def highestBarSymbol10 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol10 = highestBarSymbol10 - y;
AddChartBubble( barNumber() == referenceBarSymbol10,symbol10Signal,"10:"+symbol10,if trendStrengthSymbol10[2] == 2 then Color.GREEN else if trendStrengthSymbol10[2] == 1then Color.DARK_GRAY else if trendStrengthSymbol10[2] == -2 then Color.RED else if trendStrengthSymbol10[2] == -1 then Color.DARK_RED else if trendStrengthSymbol10[2] == 0 then Color.YELLOW else Color.GRAY,yes);

################## ----------- SYMBOL #11
def ema1Symbol11 = expAverage(close(symbol11), Length1);
def ema2Symbol11 = expAverage(close(symbol11), Length2);
def ema3Symbol11 = expAverage(close(symbol11), Length3);
def ema4Symbol11 = expAverage(close(symbol11), Length4);

def u1Symbol11 = ema1Symbol11 > ema2Symbol11;
def u2Symbol11 = ema2Symbol11 > ema3Symbol11;
def u3Symbol11 = ema3Symbol11 > ema4Symbol11;

def d1Symbol11 = ema1Symbol11 < ema2Symbol11;
def d2Symbol11 = ema2Symbol11 < ema3Symbol11;
def d3Symbol11 = ema3Symbol11 < ema4Symbol11;

def trendStrengthSymbol11 = if (u1Symbol11 and u2Symbol11 and u3Symbol11) then 2 else if (u1Symbol11 and u2Symbol11 and !u3Symbol11) then 1 else if (d1Symbol11 and d2Symbol11 and d3Symbol11) then -2 else if (d1Symbol11 and d2Symbol11 and !d3Symbol11) then -1 else 0;

plot Symbol11Plot1 = if trendStrengthSymbol11 == 2 then symbol11Signal else Double.NaN;
Symbol11Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol11Plot1.SetLineWeight(3);
Symbol11Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol11Plot2 = if trendStrengthSymbol11 == 1 then symbol11Signal else Double.NaN;
Symbol11Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol11Plot2.SetLineWeight(3);
Symbol11Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol11Plot3 = if trendStrengthSymbol11 == -2 then symbol11Signal else Double.NaN;
Symbol11Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol11Plot3.SetLineWeight(3);
Symbol11Plot3.AssignValueColor(COLOR.RED);
plot Symbol11Plot4 = if trendStrengthSymbol11 == -1 then symbol11Signal else Double.NaN;
Symbol11Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol11Plot4.SetLineWeight(3);
Symbol11Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol11Plot5 = if trendStrengthSymbol11 == 0 then symbol11Signal else Double.NaN;
Symbol11Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol11Plot5.SetLineWeight(3);
Symbol11Plot5.AssignValueColor(COLOR.YELLOW);
Symbol11Plot1.HideTitle();
Symbol11Plot2.HideTitle();
Symbol11Plot3.HideTitle();
Symbol11Plot4.HideTitle();
Symbol11Plot5.HideTitle();
def highestBarSymbol11 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol11 = highestBarSymbol11 - x;
AddChartBubble( barNumber() == referenceBarSymbol11,symbol11Signal,"11:"+symbol11,if trendStrengthSymbol11[5] == 2 then Color.GREEN else if trendStrengthSymbol11[5] == 1then Color.DARK_GRAY else if trendStrengthSymbol11[5] == -2 then Color.RED else if trendStrengthSymbol11[5] == -1 then Color.DARK_RED else if trendStrengthSymbol11[5] == 0 then Color.YELLOW else Color.GRAY,yes);

################## ----------- SYMBOL #12
def ema1Symbol12 = expAverage(close(symbol12), Length1);
def ema2Symbol12 = expAverage(close(symbol12), Length2);
def ema3Symbol12 = expAverage(close(symbol12), Length3);
def ema4Symbol12 = expAverage(close(symbol12), Length4);

def u1Symbol12 = ema1Symbol12 > ema2Symbol12;
def u2Symbol12 = ema2Symbol12 > ema3Symbol12;
def u3Symbol12 = ema3Symbol12 > ema4Symbol12;

def d1Symbol12 = ema1Symbol12 < ema2Symbol12;
def d2Symbol12 = ema2Symbol12 < ema3Symbol12;
def d3Symbol12 = ema3Symbol12 < ema4Symbol12;

def trendStrengthSymbol12 = if (u1Symbol12 and u2Symbol12 and u3Symbol12) then 2 else if (u1Symbol12 and u2Symbol12 and !u3Symbol12) then 1 else if (d1Symbol12 and d2Symbol12 and d3Symbol12) then -2 else if (d1Symbol12 and d2Symbol12 and !d3Symbol12) then -1 else 0;

plot Symbol12Plot1 = if trendStrengthSymbol12 == 2 then symbol12Signal else Double.NaN;
Symbol12Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol12Plot1.SetLineWeight(3);
Symbol12Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol12Plot2 = if trendStrengthSymbol12 == 1 then symbol12Signal else Double.NaN;
Symbol12Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol12Plot2.SetLineWeight(3);
Symbol12Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol12Plot3 = if trendStrengthSymbol12 == -2 then symbol12Signal else Double.NaN;
Symbol12Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol12Plot3.SetLineWeight(3);
Symbol12Plot3.AssignValueColor(COLOR.RED);
plot Symbol12Plot4 = if trendStrengthSymbol12 == -1 then symbol12Signal else Double.NaN;
Symbol12Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol12Plot4.SetLineWeight(3);
Symbol12Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol12Plot5 = if trendStrengthSymbol12 == 0 then symbol12Signal else Double.NaN;
Symbol12Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol12Plot5.SetLineWeight(3);
Symbol12Plot5.AssignValueColor(COLOR.YELLOW);
Symbol12Plot1.HideTitle();
Symbol12Plot2.HideTitle();
Symbol12Plot3.HideTitle();
Symbol12Plot4.HideTitle();
Symbol12Plot5.HideTitle();
def highestBarSymbol12 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol12 = highestBarSymbol12 - y;
AddChartBubble( barNumber() == referenceBarSymbol12,symbol12Signal,"12:"+symbol12,if trendStrengthSymbol12[2] == 2 then Color.GREEN else if trendStrengthSymbol12[2] == 1then Color.DARK_GRAY else if trendStrengthSymbol12[2] == -2 then Color.RED else if trendStrengthSymbol12[2] == -1 then Color.DARK_RED else if trendStrengthSymbol12[2] == 0 then Color.YELLOW else Color.GRAY,yes);

################## ----------- SYMBOL #13
def ema1Symbol13 = expAverage(close(symbol13), Length1);
def ema2Symbol13 = expAverage(close(symbol13), Length2);
def ema3Symbol13 = expAverage(close(symbol13), Length3);
def ema4Symbol13 = expAverage(close(symbol13), Length4);

def u1Symbol13 = ema1Symbol13 > ema2Symbol13;
def u2Symbol13 = ema2Symbol13 > ema3Symbol13;
def u3Symbol13 = ema3Symbol13 > ema4Symbol13;

def d1Symbol13 = ema1Symbol13 < ema2Symbol13;
def d2Symbol13 = ema2Symbol13 < ema3Symbol13;
def d3Symbol13 = ema3Symbol13 < ema4Symbol13;

def trendStrengthSymbol13 = if (u1Symbol13 and u2Symbol13 and u3Symbol13) then 2 else if (u1Symbol13 and u2Symbol13 and !u3Symbol13) then 1 else if (d1Symbol13 and d2Symbol13 and d3Symbol13) then -2 else if (d1Symbol13 and d2Symbol13 and !d3Symbol13) then -1 else 0;

plot Symbol13Plot1 = if trendStrengthSymbol13 == 2 then symbol13Signal else Double.NaN;
Symbol13Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol13Plot1.SetLineWeight(3);
Symbol13Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol13Plot2 = if trendStrengthSymbol13 == 1 then symbol13Signal else Double.NaN;
Symbol13Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol13Plot2.SetLineWeight(3);
Symbol13Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol13Plot3 = if trendStrengthSymbol13 == -2 then symbol13Signal else Double.NaN;
Symbol13Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol13Plot3.SetLineWeight(3);
Symbol13Plot3.AssignValueColor(COLOR.RED);
plot Symbol13Plot4 = if trendStrengthSymbol13 == -1 then symbol13Signal else Double.NaN;
Symbol13Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol13Plot4.SetLineWeight(3);
Symbol13Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol13Plot5 = if trendStrengthSymbol13 == 0 then symbol13Signal else Double.NaN;
Symbol13Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol13Plot5.SetLineWeight(3);
Symbol13Plot5.AssignValueColor(COLOR.YELLOW);
Symbol13Plot1.HideTitle();
Symbol13Plot2.HideTitle();
Symbol13Plot3.HideTitle();
Symbol13Plot4.HideTitle();
Symbol13Plot5.HideTitle();
def highestBarSymbol13 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol13 = highestBarSymbol13 - x;
AddChartBubble( barNumber() == referenceBarSymbol13,symbol13Signal,"13:"+symbol13,if trendStrengthSymbol11[5] == 2 then Color.GREEN else if trendStrengthSymbol11[5] == 1then Color.DARK_GRAY else if trendStrengthSymbol11[5] == -2 then Color.RED else if trendStrengthSymbol11[5] == -1 then Color.DARK_RED else if trendStrengthSymbol11[5] == 0 then Color.YELLOW else Color.GRAY,yes);

################## ----------- SYMBOL #14
def ema1Symbol14 = expAverage(close(symbol14), Length1);
def ema2Symbol14 = expAverage(close(symbol14), Length2);
def ema3Symbol14 = expAverage(close(symbol14), Length3);
def ema4Symbol14 = expAverage(close(symbol14), Length4);

def u1Symbol14 = ema1Symbol14 > ema2Symbol14;
def u2Symbol14 = ema2Symbol14 > ema3Symbol14;
def u3Symbol14 = ema3Symbol14 > ema4Symbol14;

def d1Symbol14 = ema1Symbol14 < ema2Symbol14;
def d2Symbol14 = ema2Symbol14 < ema3Symbol14;
def d3Symbol14 = ema3Symbol14 < ema4Symbol14;

def trendStrengthSymbol14 = if (u1Symbol14 and u2Symbol14 and u3Symbol14) then 2 else if (u1Symbol14 and u2Symbol14 and !u3Symbol14) then 1 else if (d1Symbol14 and d2Symbol14 and d3Symbol14) then -2 else if (d1Symbol14 and d2Symbol14 and !d3Symbol14) then -1 else 0;

plot Symbol14Plot1 = if trendStrengthSymbol14 == 2 then symbol14Signal else Double.NaN;
Symbol14Plot1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol14Plot1.SetLineWeight(3);
Symbol14Plot1.AssignValueColor(COLOR.GREEN);
plot Symbol14Plot2 = if trendStrengthSymbol14 == 1 then symbol14Signal else Double.NaN;
Symbol14Plot2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol14Plot2.SetLineWeight(3);
Symbol14Plot2.AssignValueColor(COLOR.DARK_GREEN);
plot Symbol14Plot3 = if trendStrengthSymbol14 == -2 then symbol14Signal else Double.NaN;
Symbol14Plot3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Symbol14Plot3.SetLineWeight(3);
Symbol14Plot3.AssignValueColor(COLOR.RED);
plot Symbol14Plot4 = if trendStrengthSymbol14 == -1 then symbol14Signal else Double.NaN;
Symbol14Plot4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol14Plot4.SetLineWeight(3);
Symbol14Plot4.AssignValueColor(COLOR.DARK_RED);
plot Symbol14Plot5 = if trendStrengthSymbol14 == 0 then symbol14Signal else Double.NaN;
Symbol14Plot5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Symbol14Plot5.SetLineWeight(3);
Symbol14Plot5.AssignValueColor(COLOR.YELLOW);
Symbol14Plot1.HideTitle();
Symbol14Plot2.HideTitle();
Symbol14Plot3.HideTitle();
Symbol14Plot4.HideTitle();
Symbol14Plot5.HideTitle();
def highestBarSymbol14 = HighestAll( if IsNaN(close) then Double.NaN else barNumber() );
def referenceBarSymbol14 = highestBarSymbol14 - y;
AddChartBubble( barNumber() == referenceBarSymbol14,symbol14Signal,"14:"+symbol14,if trendStrengthSymbol14[2] == 2 then Color.GREEN else if trendStrengthSymbol14[2] == 1then Color.DARK_GRAY else if trendStrengthSymbol14[2] == -2 then Color.RED else if trendStrengthSymbol14[2] == -1 then Color.DARK_RED else if trendStrengthSymbol14[2] == 0 then Color.YELLOW else Color.GRAY,yes);
SuperTrend Multiple Time Frames
August 08, 2022 01:21PM
# SuperTrend Multiple Time Frames

declare lower;

input agg1 = AggregationPeriod.FIVE_MIN;
input agg2 = AggregationPeriod.TEN_MIN;
input agg3 = AggregationPeriod.FIFTEEN_MIN;
input agg4 = AggregationPeriod.THIRTY_MIN;
input agg5 = AggregationPeriod.HOUR;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;

script ST {
input agg = AggregationPeriod.FIVE_MIN;
input AtrMult = .70;
input nATR = 4;
input AvgType = AverageType.HULL;
def Fh = FundamentalType.HIGH;
def Fl = FundamentalType.LOW;
def Fc = FundamentalType.CLOSE;
def Fhl2 = FundamentalType.HL2;
def h = Fundamental(Fh, period = agg);
def l = Fundamental(Fl, period = agg);
def c = Fundamental(Fc, period = agg);
def hl = Fundamental(Fhl2, period = agg);
def ATR = MovingAverage(AvgType, TrueRange(h, c, l), nATR);
def UP = hl + (AtrMult * ATR);
def DN = hl + (-AtrMult * ATR);
def S = if c < S[1]
then Round(UP / TickSize(), 0) * TickSize()
else Round(DN / TickSize(), 0) * TickSize();
plot ST = if c > S then 1 else 0;
}
def cl = close;
def x = IsNaN(cl[2]) and !IsNaN(cl[3]);
def FirstAgg = ST(agg = agg1, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FirstAggPlot = if IsNaN(cl)
then Double.NaN
else 1;
FirstAggPlot.SetStyle(Curve.POINTS);
FirstAggPlot.SetLineWeight(3);
FirstAggPlot.AssignValueColor(if FirstAgg == 1
then Color.GREEN
else Color.RED);
AddChartBubble(x, 1, (agg1 / 1000 / 60) + " min", Color.WHITE, yes);
def SecondAgg = ST(agg = agg2, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot SecondAggPlot = if IsNaN(cl)
then Double.NaN
else 2;
SecondAggPlot.SetStyle(Curve.POINTS);
SecondAggPlot.SetLineWeight(3);
SecondAggPlot.AssignValueColor(if SecondAgg == 1
then Color.GREEN
else Color.RED);
AddChartBubble(x, 2, (agg2 / 1000 / 60) + " min", Color.WHITE, yes);
def ThirdAgg = ST(agg = agg3, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot ThirdAggPlot = if IsNaN(cl)
then Double.NaN
else 3;
ThirdAggPlot.SetStyle(Curve.POINTS);
ThirdAggPlot.SetLineWeight(3);
ThirdAggPlot.AssignValueColor(if ThirdAgg == 1
then Color.GREEN
else Color.RED);
AddChartBubble(x, 3, (agg3 / 1000 / 60) + " min", Color.WHITE, yes);
def FourthAgg = ST(agg = agg4, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FourthAggPlot = if IsNaN(cl)
then Double.NaN
else 4;
FourthAggPlot.SetStyle(Curve.POINTS);
FourthAggPlot.SetLineWeight(3);
FourthAggPlot.AssignValueColor(if FourthAgg == 1
then Color.GREEN
else Color.RED);
AddChartBubble(x, 4, (agg4 / 1000 / 60) + " min", Color.WHITE, yes);
def FifthAgg = ST(agg = agg5, AtrMult = AtrMult, nATR = nATR, AvgType = AvgType);
plot FifthAggPlot = if IsNaN(cl)
then Double.NaN
else 5;
FifthAggPlot.SetStyle(Curve.POINTS);
FifthAggPlot.SetLineWeight(3);
FifthAggPlot.AssignValueColor(if FifthAgg == 1
then Color.GREEN
else Color.RED);
AddChartBubble(x, 5, (agg5 / 1000 / 60) + " min", Color.WHITE, yes);
plot Six = if IsNaN(cl)
then Double.NaN
else 6;
Six.SetStyle(Curve.POINTS);
Six.SetLineWeight(3);
Six.AssignValueColor(if FirstAgg and
SecondAgg and
ThirdAgg and
FourthAgg and
FifthAgg
then Color.GREEN
else if !FirstAgg and
!SecondAgg and
!ThirdAgg and
!FourthAgg and
!FifthAgg
then Color.RED
else Color.BLACK);
# End Code SUPERTREND MTF
Re: Fun with ThinkScript
August 11, 2022 12:40PM
Is it possible to reference a 1min chart for indicator data to plot on a tick chart?

I want to 'see' the Williams %R overbought and oversold areas per the 1min chart as a paintbar study on a tick chart. This is the code that I have for the 1min aggregation that works on the 1min chart but when I add this to a tick chart the paintbars do not show up:


input PaintBars = yes;
input aggregationperiod1 = AggregationPeriod.MIN;
input length = 13;
input overBought = -39;
input overSold = -62;
def high1 = high(period = aggregationPeriod1);
def low1 = low(period = aggregationPeriod1);
def close1 = close(period = aggregationPeriod1);

def hh = Highest(high1, length);
def ll = Lowest(low1, length);
def result = if hh == ll then -100 else (hh - close1) / (hh - ll) * (-100);

def cond1 = result > -39;
def cond2 = result < -62;

AssignPriceColor (if !PaintBars then Color.CURRENT else if cond1 then Color.yellow else if cond2 then Color.cyan else Color.CURRENT);

Thanks
sum
Re: Fun with ThinkScript
August 16, 2022 10:19PM
Is there a Indicator for weekly or monthly BUY Calls or BUY PUT?
Re: Fun with ThinkScript
August 17, 2022 08:47AM
Hello everyone,

Just a quick note.
For you guys looking for help with your scripts. You'd probably be better served to surf over to usethinkscript.com. There are only a few folks here lurking the board that dabble in script writing. Most of the real thinkscript folks are over at usethinkscript.com. Post your questions there about scripts and I'm sure you'll get lots of responses.

R
Barnumber <> "hand counting"
November 08, 2022 07:08PM
Hi, new to the forum and first post...

I've been working on a script where I need to use the bar number and I was getting some strange results. I coded an iterative variable:

def bn = bn[1] + 1;

to validate BarNumber(). It turns out that the bn, "hand count" is always 10 more than BarNumber().

Any ideas about this? I checked to see if there were any NaN on close and on bn and there were none. I checked the chart settings for Time Axis/Expansion Area and is '0'. I looked everywhere for a "10" and nothing found.

---Todd
ZigZagHighLow Study
November 26, 2022 10:27AM
Hi All --

I would like to plot the difference between each LastL and LastH, either on the bar chart or on a lower chart. This is to have an idea of how much of a move to expect up or down for purposes of setting profit targets and stops.

I figured out that LastH and LastL only exist for the bar where the pivot occurs.

It's a very complicated code.

Thanks
Re: ZigZagHighLow Study
November 27, 2022 12:20PM
Here is the code:

#
# TD Ameritrade IP Company, Inc. (c) 2013-2022
#

input priceH = high;
input priceL = low;
input percentageReversal = 5.0;
input absoluteReversal = 0.0;
input atrLength = 5;
input atrReversal = 1.5;
input tickReversal = 0;

Assert(percentageReversal >= 0, "'percentage reversal' must not be negative: " + percentageReversal);
Assert(absoluteReversal >= 0, "'absolute reversal' must not be negative: " + absoluteReversal);
Assert(atrReversal >= 0, "'atr reversal' must not be negative: " + atrReversal);
Assert(tickReversal >= 0, "'ticks' must not be negative: " + tickReversal);
Assert(percentageReversal != 0 or absoluteReversal != 0 or atrReversal != 0 or tickReversal != 0, "Either 'percentage reversal' or 'absolute reversal' or 'atr reversal' or 'tick reversal' must not be zero"winking smiley;

def absReversal;
if (absoluteReversal != 0) {
absReversal = absoluteReversal;
} else {
absReversal = tickReversal * TickSize();
}

def hlPivot;
if (atrReversal != 0) {
hlPivot = percentageReversal / 100 + WildersAverage(TrueRange(high, close, low), atrLength) / close * atrReversal;
} else {
hlPivot = percentageReversal / 100;
}
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);

if GetValue(state, 1) == GetValue(state.init, 0) {
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 = prevMinL;
newMax = yes;
newMin = no;
} else if priceL <= prevMinL {
state = state.downtrend;
maxPriceH = prevMaxH;
minPriceL = priceL;
newMax = no;
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 <= prevMaxH - prevMaxH * hlPivot - absReversal {
state = state.downtrend;
maxPriceH = prevMaxH;
minPriceL = priceL;
newMax = no;
newMin = yes;
} else {
state = state.uptrend;
if (priceH >= prevMaxH) {
maxPriceH = priceH;
newMax = yes;
} else {
maxPriceH = prevMaxH;
newMax = no;
}
minPriceL = prevMinL;
newMin = no;
}
} else {
if priceH >= prevMinL + prevMinL * hlPivot + absReversal {
state = state.uptrend;
maxPriceH = priceH;
minPriceL = prevMinL;
newMax = yes;
newMin = no;
} else {
state = state.downtrend;
maxPriceH = prevMaxH;
newMax = no;
if (priceL <= prevMinL) {
minPriceL = priceL;
newMin = yes;
} else {
minPriceL = prevMinL;
newMin = no;
}
}
}

def barNumber = BarNumber();
def barCount = HighestAll(If(IsNaN(priceH), 0, barNumber));
def newState = GetValue(state, 0) != GetValue(state, 1);
def offset = barCount - barNumber + 1;
def highPoint = state == state.uptrend and priceH == maxPriceH;
def lowPoint = state == state.downtrend and priceL == minPriceL;

def lastH;
if highPoint and offset > 1 {
lastH = fold iH = 1 to offset with tH = priceH while !IsNaN(tH) and !GetValue(newState, -iH) do if GetValue(newMax, -iH) or iH == offset - 1 and GetValue(priceH, -iH) == tH then Double.NaN else tH;
} else {
lastH = Double.NaN;
}

def lastL;
if lowPoint and offset > 1 {
lastL = fold iL = 1 to offset with tL = priceL while !IsNaN(tL) and !GetValue(newState, -iL) do if GetValue(newMin, -iL) or iL == offset - 1 and GetValue(priceL, -iL) == tL then Double.NaN else tL;
} else {
lastL = Double.NaN;
}

plot ZZ;
if barNumber == 1 {
ZZ = fold iF = 1 to offset with tP = Double.NaN while IsNaN(tP) do if GetValue(state, -iF) == GetValue(state.uptrend, 0) then priceL else if GetValue(state, -iF) == GetValue(state.downtrend, 0) then priceH else Double.NaN;
} else if barNumber == barCount {
ZZ = if highPoint or state == state.downtrend and priceL > minPriceL then priceH else if lowPoint or state == state.uptrend and priceH < maxPriceH then priceL else Double.NaN;
} else {
ZZ = if !IsNaN(lastH) then lastH else if !IsNaN(lastL) then lastL else Double.NaN;
}
ZZ.SetDefaultColor(GetColor(1));
ZZ.EnableApproximation();
Re: Fun with ThinkScript
May 26, 2023 07:18PM
Hello guys,

I wanted to see if someone could help me, I put below a piece of the code, where I plot two lines for each support and two for each resistance and when the price crosses the support or resistance those lines are hidden but it happens to me that the cloud keeps active, there are 10 resistances and 10 supports, if necessary let me know if need the complete code, I just want to fix when the lines are hidden, the cloud will also hide

Note : I don't make this code , I just adding the cloud

, thanks


plot R1 = LinePlot(BarID = PHBarID, Value = PHValue, BarOrigin = PHBarOrigin);
R1.SetDefaultColor(Color.RED);
def r1v = if bar == HighestAll(PHBarOrigin) then h else r1v[1];
def crossr1 = if bar < HighestAll(PHBarOrigin) then 0 else if bar > HighestAll(PHBarOrigin) and c crosses HighestAll(r1v) then crossr1[1] + 1
else crossr1[1];
R1.SetHiding(crossr1 >= sh);
AddChartBubble(HighestAll(crossr1) < sh and bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.RED, 1);

plot hidecloudr1 =crossr1 >=R1[1];
hidecloudr1.hideBubble();
plot R1_ = LinePlot(BarID = PHBarID, Value = R1 + Num_Dev_up , BarOrigin = PHBarOrigin);
R1_.SetDefaultColor(Color.RED);
R1_.SetHiding(crossr1 >= sh);
AddCloud(if hidecloudr1 then R1 else nan , R1_ , Color.LIGHT_RED );


plot R2 = LinePlot(BarID = R2PHBarID, Value = R2PHValue, BarOrigin = R2PHBarOrigin);
R2.SetDefaultColor(Color.RED);
def r2v = if bar == HighestAll(R2PHBarOrigin) then h else r2v[1];
def crossr2 = if bar < HighestAll(R2PHBarOrigin) then 0 else if bar > HighestAll(R2PHBarOrigin) and c crosses HighestAll(r2v) then crossr2[1] + 1 else crossr2[1];
R2.SetHiding(crossr2 >= sh);
AddChartBubble(HighestAll(crossr2) < sh and bar == HighestAll(R2PHBarOrigin), PHValue, "R2", Color.RED, 1);

plot hidecloudr2 =crossr2 >= R2;
hidecloudr2.hideBubble();
plot R2_ = LinePlot(BarID = R2PHBarID, Value = R2 + Num_Dev_up, BarOrigin = R2PHBarOrigin);
R2_.SetDefaultColor(Color.RED);
R2_.SetHiding(crossr2 >= sh);
AddCloud(if hidecloudr2 then R2 else nan , R2_ , Color.LIGHT_RED );
wmoreno
May 31, 2023 02:58PM
The code is incomplete, therefore not possible to see the problem
Re: wmoreno
May 31, 2023 04:28PM
I've posted this before, but I suppose it's time to refresh it. smiling smiley

Just a quick note.
For you guys looking for help with your scripts. You'd probably be better served to surf over to usethinkscript.com. There are only a few folks here lurking the board that dabble in script writing. Most of the real thinkscript folks are over at usethinkscript.com. Post your questions there about scripts and I'm sure you'll get lots of responses.


R
Re: wmoreno
May 31, 2023 04:51PM
RichieRick Wrote:
-------------------------------------------------------
> I've posted this before, but I suppose it's time
> to refresh it. smiling smiley
>
> Just a quick note.
> For you guys looking for help with your scripts.
> You'd probably be better served to surf over to
> usethinkscript.com. There are only a few folks
> here lurking the board that dabble in script
> writing. Most of the real thinkscript folks are
> over at usethinkscript.com. Post your questions
> there about scripts and I'm sure you'll get lots
> of responses.
>
> R


Thanks
help modifying this script
May 29, 2023 06:21PM
Hello

I'm trying to put a cloud on the supports and resistances but when the lines hide the cloud keeps showing up, any help I appreciate , I did to Resistances for now

Thank


#StudyName: BLT_HarndogLazyFractalPivots
#Version/Date: v2 01-13-2016 TOS.mx Link: [tos.mx] #Type: [Study | Strategy]
#Description: Instead of redrafting fractal pivots to frame market behavior
# this adaption of Mobius' FractalPivotsArrayV3 was modified by
# by BLT/ZZZ/LB using a Harndog test script idea to generate
# lazy fractal pivot lines.
#Requested By: Harndog in chat starting around 02/12/17
#History: TOS.mx Link:
# Notes: The idea is based on Mobius Fractal Pivot Array [tos.mx]
# Annotation:
# V02: Added ExtLine.Hide: because script was generating expansion problems
# Changed Plot Support Line (line 450) to
# plot SupportLine = if bar == ParentHbarOrigin
# then ParentHigh
# else if bar == ParentLbarOrigin
# then ParentLow
# else double.nan;
# Suggestion from Brian_ss
# Trading Notes: Play with the script properties to adjust fractal pivots,
# aggregations
# 18:58 blt_: harndog, if you still are looking for hiding pivots in your version of "lazy pivots", maybe this will help. It hides pivots when a close crosses the pivot. You can set how many crosses before a line is hidden. The bubble was also set to hide if the pivot line is hidden. The current/higher option was changed to allow for more

# Fractal Pivot Array 11 deep
# Mobius
# V03.01.2017
# V02: Added some information on Basic Wave Structure and labels to hold wave data started
# V03: Added User Input for secondary aggregations. Add a label to show what chart aggregation pivots are being plotted. Add a cloud to show first zone of support / resistance. Altered Support line plot to extend at a consistent slope. Reset UI's for WaveLabel and ShowWaves to no.

# User Inputs
input length = 300;
input averageType = AverageType.WILDERS;
input n = 10;
input WaveLabel = no;
input ShowWaves = no;
input ShowSupportResistanceCloud = no;
input select_aggperiod = {default "Current", "Higher"};
input higheragg = AggregationPeriod.THREE_MIN;
input sethiding_crosses_required = 1;
input ShowSRLevelsCloud = yes;



def sh = sethiding_crosses_required;
def ATR = MovingAverage(AverageType.SIMPLE, TrueRange(high, close, low),length);
def Num_Dev_Dn = ATR ;
def Num_Dev_up = - ATR ;



# Internal Script Reference
script LinePlot
{
input BarID = 0;
input Value = 0;
input BarOrigin = 0;
def ThisBar = HighestAll(BarOrigin);
def ValueLine = if BarOrigin == ThisBar then Value else Double.NaN;

plot P = if ThisBar - BarID <= BarOrigin then HighestAll(ValueLine) else Double.NaN;
}

# Variables

def o;
def h;
def l;
def c;
switch (select_aggperiod) {
case Current:
o = open;
h = high;
l = low;
c = if IsNaN(close) then c[1] else close;
case Higher:
o = open(period = higheragg);
h = high(period = higheragg);
l = low(period = higheragg);
c = if IsNaN(close(period = higheragg)) then c[1] else close(period = higheragg);
}

def bar = BarNumber();
def BBar = bar == HighestAll(bar);
def nan = Double.NaN;

# Parent High

def ParentHigh = HighestAll(h);
def ParentHBarOrigin = if h == ParentHigh then bar else ParentHBarOrigin[1];
def ParentHBarID = bar - HighestAll(ParentHBarOrigin);


# R1

def hh = fold i = 1 to n + 1 with p = 1 while p do h > GetValue(h, -i);
def PivotH = if (bar > n and h == Highest(h, n) and hh) then h else Double.NaN;
def PHValue = if !IsNaN(PivotH) then PivotH else PHValue[1];
def PHBarOrigin = if !IsNaN(PivotH) then bar else PHBarOrigin[1];
def PHBarID = bar - PHBarOrigin;
def xh = if h == hh then c else nan;


#plot hh_ = if PivotH >= HighestAll(xh) then HighestAll(if IsNaN(close[-1]) then hh else nan) else nan;
#hh_.SetDefaultColor(Color.RED);


# R2

def R2PHValue = if PHBarOrigin != PHBarOrigin[1] then PHValue[1] else R2PHValue[1];
def R2PHBarOrigin = if PHBarOrigin != PHBarOrigin[1] then PHBarOrigin[1] else R2PHBarOrigin[1];
def R2PHBarID = bar - R2PHBarOrigin;

# R3

def R3PHValue = if R2PHBarOrigin != R2PHBarOrigin[1] then R2PHValue[1] else R3PHValue[1];
def R3PHBarOrigin = if R2PHBarOrigin != R2PHBarOrigin[1] then R2PHBarOrigin[1] else R3PHBarOrigin[1];
def R3PHBarID = bar - R3PHBarOrigin;

# R4

def R4PHValue = if R3PHBarOrigin != R3PHBarOrigin[1] then R3PHValue[1] else R4PHValue[1];
def R4PHBarOrigin = if R3PHBarOrigin != R3PHBarOrigin[1] then R3PHBarOrigin[1] else R4PHBarOrigin[1];
def R4PHBarID = bar - R4PHBarOrigin;

# R5

def R5PHValue = if R4PHBarOrigin != R4PHBarOrigin[1] then R4PHValue[1] else R5PHValue[1];
def R5PHBarOrigin = if R4PHBarOrigin != R4PHBarOrigin[1] then R4PHBarOrigin[1] else R5PHBarOrigin[1];
def R5PHBarID = bar - R5PHBarOrigin;

# R6

def R6PHValue = if R5PHBarOrigin != R5PHBarOrigin[1] then R5PHValue[1] else R6PHValue[1];
def R6PHBarOrigin = if R5PHBarOrigin != R5PHBarOrigin[1] then R5PHBarOrigin[1] else R6PHBarOrigin[1];
def R6PHBarID = bar - R6PHBarOrigin;

# R5

def R7PHValue = if R6PHBarOrigin != R6PHBarOrigin[1] then R6PHValue[1] else R7PHValue[1];
def R7PHBarOrigin = if R6PHBarOrigin != R6PHBarOrigin[1] then R6PHBarOrigin[1] else R7PHBarOrigin[1];
def R7PHBarID = bar - R7PHBarOrigin;

# R8

def R8PHValue = if R7PHBarOrigin != R7PHBarOrigin[1] then R7PHValue[1] else R8PHValue[1];
def R8PHBarOrigin = if R7PHBarOrigin != R7PHBarOrigin[1] then R7PHBarOrigin[1] else R8PHBarOrigin[1];
def R8PHBarID = bar - R8PHBarOrigin;

# R9

def R9PHValue = if R8PHBarOrigin != R8PHBarOrigin[1] then R8PHValue[1] else R9PHValue[1];
def R9PHBarOrigin = if R8PHBarOrigin != R8PHBarOrigin[1] then R8PHBarOrigin[1] else R9PHBarOrigin[1];
def R9PHBarID = bar - R9PHBarOrigin;

# R10

def R10PHValue = if R9PHBarOrigin != R9PHBarOrigin[1] then R9PHValue[1] else R10PHValue[1];
def R10PHBarOrigin = if R9PHBarOrigin != R9PHBarOrigin[1] then R9PHBarOrigin[1] else R10PHBarOrigin[1];
def R10PHBarID = bar - R10PHBarOrigin;


# Parent Low

def ParentLow = LowestAll(l);
def ParentLBarOrigin = if l == ParentLow then bar else ParentLBarOrigin[1];
def ParentLBarID = bar - ParentLBarOrigin;

# S1

def ll = fold j = 1 to n + 1 with q = 1 while q do l < GetValue(l, -j);
def PivotL = if (bar > n and l == Lowest(l, n) and ll) then l else Double.NaN;
def PLValue = if !IsNaN(PivotL) then PivotL else PLValue[1];
def PLBarOrigin = if !IsNaN(PivotL) then bar else PLBarOrigin[1];
def PLBarID = bar - PLBarOrigin;

# S2

def S2PLValue = if PLBarOrigin != PLBarOrigin[1] then PLValue[1] else S2PLValue[1];
def S2PLBarOrigin = if PLBarOrigin != PLBarOrigin[1] then PLBarOrigin[1] else S2PLBarOrigin[1];
def S2PLBarID = bar - S2PLBarOrigin;

# S3

def S3PLValue = if S2PLBarOrigin != S2PLBarOrigin[1] then S2PLValue[1] else S3PLValue[1];
def S3PLBarOrigin = if S2PLBarOrigin != S2PLBarOrigin[1] then S2PLBarOrigin[1] else S3PLBarOrigin[1];
def S3PLBarID = bar - S3PLBarOrigin;

# S4

def S4PLValue = if S3PLBarOrigin != S3PLBarOrigin[1] then S3PLValue[1] else S4PLValue[1];
def S4PLBarOrigin = if S3PLBarOrigin != S3PLBarOrigin[1] then S3PLBarOrigin[1] else S4PLBarOrigin[1];
def S4PLBarID = bar - S4PLBarOrigin;

# S5

def S5PLValue = if S4PLBarOrigin != S4PLBarOrigin[1] then S4PLValue[1] else S5PLValue[1];
def S5PLBarOrigin = if S4PLBarOrigin != S4PLBarOrigin[1] then S4PLBarOrigin[1] else S5PLBarOrigin[1];
def S5PLBarID = bar - S5PLBarOrigin;

# S6

def S6PLValue = if S5PLBarOrigin != S5PLBarOrigin[1] then S5PLValue[1] else S6PLValue[1];
def S6PLBarOrigin = if S5PLBarOrigin != S5PLBarOrigin[1] then S5PLBarOrigin[1] else S6PLBarOrigin[1];
def S6PLBarID = bar - S6PLBarOrigin;

# S7

def S7PLValue = if S6PLBarOrigin != S6PLBarOrigin[1] then S6PLValue[1] else S7PLValue[1];
def S7PLBarOrigin = if S6PLBarOrigin != S6PLBarOrigin[1] then S6PLBarOrigin[1] else S7PLBarOrigin[1];
def S7PLBarID = bar - S7PLBarOrigin;

# S8

def S8PLValue = if S7PLBarOrigin != S7PLBarOrigin[1] then S7PLValue[1] else S8PLValue[1];
def S8PLBarOrigin = if S7PLBarOrigin != S7PLBarOrigin[1] then S7PLBarOrigin[1] else S8PLBarOrigin[1];
def S8PLBarID = bar - S8PLBarOrigin;

# S9

def S9PLValue = if S8PLBarOrigin != S8PLBarOrigin[1] then S8PLValue[1] else S9PLValue[1];
def S9PLBarOrigin = if S8PLBarOrigin != S8PLBarOrigin[1] then S8PLBarOrigin[1] else S9PLBarOrigin[1];
def S9PLBarID = bar - S9PLBarOrigin;

# S10

def S10PLValue = if S9PLBarOrigin != S9PLBarOrigin[1] then S9PLValue[1] else S10PLValue[1];
def S10PLBarOrigin = if S9PLBarOrigin != S9PLBarOrigin[1] then S9PLBarOrigin[1] else S10PLBarOrigin[1];
def S10PLBarID = bar - S10PLBarOrigin;

# Plots

plot PR1 = LinePlot(BarID = ParentHBarID, Value = ParentHigh, BarOrigin = HighestAll(ParentHBarOrigin));
PR1.SetDefaultColor(Color.RED);
AddChartBubble(bar == HighestAll(ParentHBarOrigin), ParentHigh, "B", Color.YELLOW, 1);

plot R1 = LinePlot(BarID = PHBarID, Value = PHValue, BarOrigin = PHBarOrigin);
R1.SetDefaultColor(Color.RED);
def r1v = if bar == HighestAll(PHBarOrigin) then h else r1v[1];
def crossr1 = if bar < HighestAll(PHBarOrigin) then 0 else if bar > HighestAll(PHBarOrigin) and c crosses HighestAll(r1v) then crossr1[1] + 1 else crossr1[1];
R1.SetHiding(crossr1 >= sh);
AddChartBubble(HighestAll(crossr1) < sh and bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.RED, 1);


plot R1_ = LinePlot(BarID = PHBarID, Value = R1 + Num_Dev_up , BarOrigin = PHBarOrigin);
R1_.SetDefaultColor(Color.RED);
R1_.SetHiding(crossr1 >= sh);
AddCloud(if ShowSRLevelsCloud then R1_ else Double.NaN, R1, Color.LIGHT_RED, Color.LIGHT_RED);


plot R2 = LinePlot(BarID = R2PHBarID, Value = R2PHValue, BarOrigin = R2PHBarOrigin);
R2.SetDefaultColor(Color.RED);
def r2v = if bar == HighestAll(R2PHBarOrigin) then h else r2v[1];
def crossr2 = if bar < HighestAll(R2PHBarOrigin) then 0 else if bar > HighestAll(R2PHBarOrigin) and c crosses HighestAll(r2v) then crossr2[1] + 1 else crossr2[1];
R2.SetHiding(crossr2 >= sh);
AddChartBubble(HighestAll(crossr2) < sh and bar == HighestAll(R2PHBarOrigin), PHValue, "R2", Color.RED, 1);


plot R2_ = LinePlot(BarID = R2PHBarID, Value = R2 + Num_Dev_up, BarOrigin = R2PHBarOrigin);
R2_.SetDefaultColor(Color.RED);
R2_.SetHiding(crossr2 >= sh);
AddCloud(if ShowSRLevelsCloud then R2_ else Double.NaN, R2, Color.LIGHT_RED, Color.LIGHT_RED);

plot R3 = LinePlot(BarID = R3PHBarID, Value = R3PHValue, BarOrigin = R3PHBarOrigin);
R3.SetDefaultColor(Color.RED);
def r3v = if bar == HighestAll(R3PHBarOrigin) then h else r3v[1];
def crossr3 = if bar < HighestAll(R3PHBarOrigin) then 0 else if bar > HighestAll(R3PHBarOrigin) and c crosses HighestAll(r3v) then crossr3[1] + 1 else crossr3[1];
R3.SetHiding(crossr3 >= sh);
AddChartBubble(HighestAll(crossr3) < sh and bar == HighestAll(R3PHBarOrigin), PHValue, "R3", Color.RED, 1);


plot R3_ = LinePlot(BarID = R3PHBarID, Value = R3 + Num_Dev_up, BarOrigin = R3PHBarOrigin);
R3_.SetDefaultColor(Color.RED);
R3_.SetHiding(crossr3 >= sh);
AddCloud(if ShowSRLevelsCloud then R3_ else Double.NaN, R3, Color.LIGHT_RED, Color.LIGHT_RED);

plot R4 = LinePlot(BarID = R4PHBarID, Value = R4PHValue, BarOrigin = R4PHBarOrigin);
R4.SetDefaultColor(Color.RED);
def r4v = if bar == HighestAll(R4PHBarOrigin) then h else r4v[1];
def crossr4 = if bar < HighestAll(R4PHBarOrigin) then 0 else if bar > HighestAll(R4PHBarOrigin) and c crosses HighestAll(r4v) then crossr4[1] + 1 else crossr4[1];
R4.SetHiding(crossr4 >= sh);
AddChartBubble(HighestAll(crossr4) < sh and bar == HighestAll(R4PHBarOrigin), PHValue, "R4", Color.RED, 1);

plot R4_ = LinePlot(BarID = R4PHBarID, Value = R4 + Num_Dev_up, BarOrigin = R4PHBarOrigin);
R4_.SetDefaultColor(Color.LIGHT_RED);
R4_.SetHiding(crossr4 >= sh);
AddCloud(if ShowSRLevelsCloud then R4_ else Double.NaN, R4, Color.LIGHT_RED, Color.LIGHT_RED);

plot R5 = LinePlot(BarID = R5PHBarID, Value = R5PHValue, BarOrigin = R5PHBarOrigin);
R5.SetDefaultColor(Color.RED);
def r5v = if bar == HighestAll(R5PHBarOrigin) then h else r5v[1];
def crossr5 = if bar < HighestAll(R5PHBarOrigin) then 0 else if bar > HighestAll(R5PHBarOrigin) and c crosses HighestAll(r5v) then crossr5[1] + 1 else crossr5[1];
R5.SetHiding(crossr5 >= sh);
AddChartBubble(HighestAll(crossr5) < sh and bar == HighestAll(R5PHBarOrigin), PHValue, "R5", Color.RED, 1);


plot R5_ = LinePlot(BarID = R5PHBarID, Value = R5 + Num_Dev_up, BarOrigin = R5PHBarOrigin);
R5_.SetDefaultColor(Color.RED);
R5_.SetHiding(crossr5 >= sh);
AddCloud(if ShowSRLevelsCloud then R5_ else Double.NaN, R5, Color.LIGHT_RED, Color.LIGHT_RED);


plot R6 = LinePlot(BarID = R6PHBarID, Value = R6PHValue, BarOrigin = R6PHBarOrigin);
R6.SetDefaultColor(Color.RED);
def r6v = if bar == HighestAll(R6PHBarOrigin) then h else r6v[1];
def crossr6 = if bar < HighestAll(R6PHBarOrigin) then 0 else if bar > HighestAll(R6PHBarOrigin) and c crosses HighestAll(r6v) then crossr6[1] + 1 else crossr6[1];
R6.SetHiding(crossr6 >= sh);
AddChartBubble(HighestAll(crossr6) < sh and bar == HighestAll(R6PHBarOrigin), PHValue, "R6", Color.RED, 1);


plot R6_ = LinePlot(BarID = R6PHBarID, Value = R6 + Num_Dev_up, BarOrigin = R6PHBarOrigin);
R6_.SetDefaultColor(Color.RED);
R6_.SetHiding(crossr6 >= sh);
AddCloud(if ShowSRLevelsCloud then R6_ else Double.NaN, R6, Color.LIGHT_RED, Color.LIGHT_RED);

plot R7 = LinePlot(BarID = R7PHBarID, Value = R7PHValue, BarOrigin = R7PHBarOrigin);
R7.SetDefaultColor(Color.RED);
def r7v = if bar == HighestAll(R7PHBarOrigin) then h else r7v[1];
def crossr7 = if bar < HighestAll(R7PHBarOrigin) then 0 else if bar > HighestAll(R7PHBarOrigin) and c crosses HighestAll(r7v) then crossr7[1] + 1 else crossr7[1];
R7.SetHiding(crossr7 >= sh);
AddChartBubble(HighestAll(crossr7) < sh and bar == HighestAll(R7PHBarOrigin), PHValue, "R7", Color.RED, 1);

plot R7_ = LinePlot(BarID = R7PHBarID, Value = R7 + Num_Dev_up, BarOrigin = R7PHBarOrigin);
R7_.SetDefaultColor(Color.RED);
R7_.SetHiding(crossr7 >= sh);
AddCloud(if ShowSRLevelsCloud then R7_ else Double.NaN, R7, Color.LIGHT_RED, Color.LIGHT_RED);

plot R8 = LinePlot(BarID = R8PHBarID, Value = R8PHValue, BarOrigin = R8PHBarOrigin);
R8.SetDefaultColor(Color.RED);
def r8v = if bar == HighestAll(R8PHBarOrigin) then h else r8v[1];
def crossr8 = if bar < HighestAll(R8PHBarOrigin) then 0 else if bar > HighestAll(R8PHBarOrigin) and c crosses HighestAll(r8v) then crossr8[1] + 1 else crossr8[1];
R8.SetHiding(crossr8 >= sh);
AddChartBubble(HighestAll(crossr8) < sh and bar == HighestAll(R8PHBarOrigin), PHValue, "R8", Color.RED, 1);


plot R8_ = LinePlot(BarID = R8PHBarID, Value = R8 + Num_Dev_up, BarOrigin = R8PHBarOrigin);
R8_.SetDefaultColor(Color.RED);
R8_.SetHiding(crossr8 >= sh);
AddCloud(if ShowSRLevelsCloud then R8_ else Double.NaN, R8, Color.LIGHT_RED, Color.LIGHT_RED);

plot R9 = LinePlot(BarID = R9PHBarID, Value = R9PHValue, BarOrigin = R9PHBarOrigin);
R9.SetDefaultColor(Color.RED);
def r9v = if bar == HighestAll(R9PHBarOrigin) then h else r9v[1];
def crossr9 = if bar < HighestAll(R9PHBarOrigin) then 0 else if bar > HighestAll(R9PHBarOrigin) and c crosses HighestAll(r9v) then crossr9[1] + 1 else crossr9[1];
R9.SetHiding(crossr9 >= sh);
AddChartBubble(HighestAll(crossr9) < sh and bar == HighestAll(R9PHBarOrigin), PHValue, "R9", Color.RED, 1);


plot R9_ = LinePlot(BarID = R9PHBarID, Value = R9 + Num_Dev_up, BarOrigin = R9PHBarOrigin);
R9_.SetDefaultColor(Color.RED);
R9_.SetHiding(crossr9 >= sh);
AddCloud(if ShowSRLevelsCloud then R9_ else Double.NaN, R9, Color.LIGHT_RED, Color.LIGHT_RED);

plot R10 = LinePlot(BarID = R10PHBarID, Value = R10PHValue, BarOrigin = R10PHBarOrigin);
R10.SetDefaultColor(Color.RED);
def r10v = if bar == HighestAll(R10PHBarOrigin) then h else r10v[1];
def crossr10 = if bar < HighestAll(R10PHBarOrigin) then 0 else if bar > HighestAll(R10PHBarOrigin) and c crosses HighestAll(r10v) then crossr10[1] + 1 else crossr10[1];
R10.SetHiding(crossr10 >= sh);
AddChartBubble(HighestAll(crossr10) < sh and bar == HighestAll(R10PHBarOrigin), PHValue, "R10", Color.RED, 1);


plot R10_ = LinePlot(BarID = R10PHBarID, Value = R10 + Num_Dev_up, BarOrigin = R10PHBarOrigin);
R10_.SetDefaultColor(Color.RED);
R10_.SetHiding(crossr10 >= sh);
AddCloud(if ShowSRLevelsCloud then R10_ else Double.NaN, R10, Color.LIGHT_RED, Color.LIGHT_RED);

plot PS1 = LinePlot(BarID = ParentLBarID, Value = ParentLow, BarOrigin = HighestAll(ParentLBarOrigin));
PS1.SetDefaultColor(Color.GREEN);
AddChartBubble(bar == HighestAll(ParentLBarOrigin), ParentLow, "A", Color.YELLOW, 0);

plot S1 = LinePlot(BarID = PLBarID, Value = PLValue, BarOrigin = PLBarOrigin);
S1.SetDefaultColor(Color.GREEN);
def s1v = if bar == HighestAll(PLBarOrigin) then l else s1v[1];
def crosss1 = if bar < HighestAll(PLBarOrigin) then 0 else if bar > HighestAll(PLBarOrigin) and c crosses HighestAll(s1v) then crosss1[1] + 1 else crosss1[1];
S1.SetHiding(crosss1 >= sh);
AddChartBubble(HighestAll(crosss1) < sh and bar == HighestAll(PLBarOrigin), PLValue, "S1", Color.GREEN, 0);


plot S2 = LinePlot(BarID = S2PLBarID,
Value = S2PLValue,
BarOrigin = S2PLBarOrigin);
S2.SetDefaultColor(Color.GREEN);
def s2v = if bar == HighestAll(S2PLBarOrigin) then l else s2v[1];
def crosss2 = if bar < HighestAll(S2PLBarOrigin) then 0 else if bar > HighestAll(S2PLBarOrigin) and c crosses HighestAll(s2v) then crosss2[1] + 1 else crosss2[1];
S2.SetHiding(crosss2 >= sh);
AddChartBubble(HighestAll(crosss2) < sh and bar == HighestAll(S2PLBarOrigin), PLValue, "S2", Color.GREEN, 0);
plot S3 = LinePlot(BarID = S3PLBarID, Value = S3PLValue, BarOrigin = S3PLBarOrigin);
S3.SetDefaultColor(Color.GREEN);
def s3v = if bar == HighestAll(S3PLBarOrigin) then l else s3v[1];
def crosss3 = if bar < HighestAll(S3PLBarOrigin) then 0 else if bar > HighestAll(S3PLBarOrigin) and c crosses HighestAll(s3v) then crosss3[1] + 1 else crosss3[1];
S3.SetHiding(crosss3 >= sh);
AddChartBubble(HighestAll(crosss3) < sh and bar == HighestAll(S3PLBarOrigin), PLValue, "S3", Color.GREEN, 0);
plot S4 = LinePlot(BarID = S4PLBarID, Value = S4PLValue, BarOrigin = S4PLBarOrigin);
S4.SetDefaultColor(Color.GREEN);
def s4v = if bar == HighestAll(S4PLBarOrigin) then l else s4v[1];
def crosss4 = if bar < HighestAll(S4PLBarOrigin) then 0 else if bar > HighestAll(S4PLBarOrigin) and c crosses HighestAll(s4v) then crosss4[1] + 1 else crosss4[1];
S4.SetHiding(crosss4 >= sh);
AddChartBubble(HighestAll(crosss4) < sh and bar == HighestAll(S4PLBarOrigin), PLValue, "S4", Color.GREEN, 0);
plot S5 = LinePlot(BarID = S5PLBarID,
Value = S5PLValue,
BarOrigin = S5PLBarOrigin);
S5.SetDefaultColor(Color.GREEN);
def s5v = if bar == HighestAll(S5PLBarOrigin) then l else s5v[1];
def crosss5 = if bar < HighestAll(S5PLBarOrigin) then 0 else if bar > HighestAll(S5PLBarOrigin) and c crosses HighestAll(s5v) then crosss5[1] + 1 else crosss5[1];
S5.SetHiding(crosss5 >= sh);
AddChartBubble(HighestAll(crosss5) < sh and bar == HighestAll(S5PLBarOrigin), PLValue, "S5", Color.GREEN, 0);
plot S6 = LinePlot(BarID = S6PLBarID, Value = S6PLValue, BarOrigin = S6PLBarOrigin);
S6.SetDefaultColor(Color.GREEN);
def s6v = if bar == HighestAll(S6PLBarOrigin) then l else s6v[1];
def crosss6 = if bar < HighestAll(S6PLBarOrigin) then 0 else if bar > HighestAll(S6PLBarOrigin) and c crosses HighestAll(s6v) then crosss6[1] + 1 else crosss6[1];
S6.SetHiding(crosss6 >= sh);
AddChartBubble(HighestAll(crosss6) < sh and bar == HighestAll(S6PLBarOrigin), PLValue, "S6", Color.GREEN, 0);
plot S7 = LinePlot(BarID = S7PLBarID, Value = S7PLValue, BarOrigin = S7PLBarOrigin);
S7.SetDefaultColor(Color.GREEN);
def s7v = if bar == HighestAll(S7PLBarOrigin) then l else s7v[1];
def crosss7 = if bar < HighestAll(S7PLBarOrigin) then 0 else if bar > HighestAll(S7PLBarOrigin) and c crosses HighestAll(s7v) then crosss7[1] + 1 else crosss7[1];
S7.SetHiding(crosss7 >= sh);
AddChartBubble(HighestAll(crosss7) < sh and bar == HighestAll(S7PLBarOrigin), PLValue, "S7", Color.GREEN, 0);
plot S8 = LinePlot(BarID = S8PLBarID, Value = S8PLValue, BarOrigin = S8PLBarOrigin);
S8.SetDefaultColor(Color.GREEN);
def s8v = if bar == HighestAll(S8PLBarOrigin) then l else s8v[1];
def crosss8 = if bar < HighestAll(S8PLBarOrigin) then 0 else if bar > HighestAll(S8PLBarOrigin) and c crosses HighestAll(s8v) then crosss8[1] + 1 else crosss8[1];
S8.SetHiding(crosss8 >= sh);
AddChartBubble(HighestAll(crosss8) < sh and bar == HighestAll(S8PLBarOrigin), PLValue, "S8", Color.GREEN, 0);
plot S9 = LinePlot(BarID = S9PLBarID, Value = S9PLValue, BarOrigin = S9PLBarOrigin);
def s9v = if bar == HighestAll(S9PLBarOrigin) then l else s9v[1];
def crosss9 = if bar < HighestAll(S9PLBarOrigin) then 0 else if bar > HighestAll(S9PLBarOrigin) and c crosses HighestAll(s9v) then crosss9[1] + 1 else crosss9[1];
S9.SetHiding(crosss9 >= sh);
AddChartBubble(HighestAll(crosss9) < sh and bar == HighestAll(S9PLBarOrigin), PLValue, "S9", Color.GREEN, 0);
S9.SetDefaultColor(Color.GREEN);
plot S10 = LinePlot(BarID = S10PLBarID, Value = S10PLValue, BarOrigin = S10PLBarOrigin);
S10.SetDefaultColor(Color.GREEN);
def s10v = if bar == HighestAll(S10PLBarOrigin) then l else s10v[1];
def crosss10 = if bar < HighestAll(S10PLBarOrigin) then 0 else if bar > HighestAll(S10PLBarOrigin) and c crosses HighestAll(s10v) then crosss10[1] + 1 else crosss10[1];
S10.SetHiding(crosss10 >= sh);
AddChartBubble(HighestAll(crosss10) < sh and bar == HighestAll(S10PLBarOrigin), PLValue, "S10", Color.GREEN, 0);

# End Code Fractal Array 11 Deep
# Trend Line

def PH_low = if bar == ParentHBarOrigin then l else PH_low[1];
def firstParentBar = Min(HighestAll(ParentLBarOrigin), HighestAll(ParentHBarOrigin));
def lastParentBar = Max(HighestAll(ParentLBarOrigin), HighestAll(ParentHBarOrigin));
def firstParent = if bar == firstParentBar and l == PH_low then PH_low else if bar == firstParentBar and l == ParentLow then ParentLow else firstParent[1];
def lastParent = if bar == lastParentBar and l == PH_low then PH_low else if bar == lastParentBar and l == ParentLow then ParentLow else lastParent[1];
def slope = (lastParent - firstParent) / (lastParentBar - firstParentBar);

plot SupportLine = if bar == ParentHBarOrigin then ParentHigh else if bar == ParentLBarOrigin then ParentLow else Double.NaN;
SupportLine.EnableApproximation();
SupportLine.SetDefaultColor(Color.GRAY);
SupportLine.SetLineWeight(2);
SupportLine.SetStyle(Curve.LONG_DASH);

plot ExtLine = if bar >= lastParentBar then (bar - lastParentBar) * slope + lastParent else Double.NaN;
ExtLine.EnableApproximation();
ExtLine.SetDefaultColor(Color.GRAY);
ExtLine.SetLineWeight(2);
ExtLine.SetStyle(Curve.LONG_DASH);
ExtLine.Hide();

AddChartBubble(WaveLabel and bar == HighestAll(bar), HighestAll(high),
"Basic Elliott Wave Rules:" + "\n" +
"Wave (2) cannot retrace past the start of Wave (1)" + "\n" +
"Wave (3) cannot be the shortest wave in a 5 wave sequence." + "\n" +
"Wave (4) cannot retrace into Wave (1)" + "\n", Color.WHITE, 1);

plot waves = if !IsNaN(PivotH) then PivotH else if !IsNaN(PivotL) then PivotL else Double.NaN;
waves.SetStyle(Curve.FIRM);
waves.EnableApproximation();
waves.SetDefaultColor(Color.CYAN);
waves.SetLineWeight(2);
waves.SetHiding(!ShowWaves);

# Wave Pattern

def ParentMaxBar = Max(ParentHBarOrigin, ParentLBarOrigin);
def ParentMinBar = Min(ParentLBarOrigin, ParentLBarOrigin);
def deltaPos = if ParentHBarOrigin == ParentMaxBar then 1 else 0;

# Clouds

AddCloud(if ShowSupportResistanceCloud then R1 else Double.NaN, S1, Color.DARK_GRAY, Color.DARK_GRAY);
Re: help modifying this script
May 31, 2023 04:29PM
And again, right here.

Just a quick note.
For you guys looking for help with your scripts. You'd probably be better served to surf over to usethinkscript.com. There are only a few folks here lurking the board that dabble in script writing. Most of the real thinkscript folks are over at usethinkscript.com. Post your questions there about scripts and I'm sure you'll get lots of responses.


R
Sorry, only registered users may post in this forum.

Click here to login