Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!

Advanced

Fun with ThinkScript

Posted by robert 
Plotting horizontal lines at calculated bar value
December 19, 2019 08:50PM
I am a newbie here so please excuse mess ups smiling smiley
I came across one of robert's entries on this link

[researchtrade.com]

for plotting horizontal lines at Peaks - Resistance and valleys -- Support.

I am trying to draw the horizontal lines from a bar picked by some logic.

I am able to plot a marker on the bar when (Bear) / (Bull) are true.
When they are true, I would like to draw the horizontal line extended to the right from the BTop,or BBot of the bars

Here is the code I have done so far...

Any help appreciated.

# Red Green Reversal Alerts

Input DnBars = 4;
Input UpBars = 4;
Input GRBars = 6;
input LkBkBrs = 9;

def c = close; def o = open; def h = high; def L = low;

def up = c > o; def dn = c < o;

Def BTop = Max(open,Close); Def BBot = Min(open, Close);

Def LoCk = Low == lowest(Low, LkBkBrs) ;
Def HiCk = High == Highest (High, LkBkBrs) ;

#======== up/Down Counters =====

def BarUp = if UP
then BarUp[1] + 1
else if DN
then 0
else BarUp[1];

def BarDn = if DN
then BarDn[1] + 1
else if UP
then 0
else BarDn[1];

#End ===== up/Down Counters =========

def Bear = HiCk and Dn and BarUp[1] >= upbars;
def Bull = LoCk and Up and BarDn[1] >= dnbars;

plot BearG_R = if Bear then H else Double.NaN;
BearG_R.SetDefaultColor(Color.White);
BearG_R.SetLineWeight(3);
BearG_R.SetStyle(Curve.POINTS);
BearG_R.SetPaintingStrategy(PaintingStrategy.SQUARES);

plot BullR_G = if Bull then L else Double.NaN;
BullR_G.SetDefaultColor(Color.Green);
BullR_G.SetLineWeight(3);
BullR_G.SetStyle(Curve.POINTS);
BullR_G.SetPaintingStrategy(PaintingStrategy.Squares);

# End ===================================
Why the default value selection not working? (your help is appreciated)
December 27, 2019 01:11PM
input price = close;
input X = { default "0.5", "0.6", "0.7"};

plot up = high + ((high - low) * X );
plot low = low - ((high - low) * X );

→ the value of X supposed to be 0.5 when 0.5 is chosen, yet the arithmetic result is 1 (even I change from 0.5 to 0.9 or letter A)
→ the value of X supposed to be 0.6 when 0.6 is chosen, yet the arithmetic result is 2 (even I change from 0.6 to 1.0 or letter cool smiley
→ the value of X supposed to be 0.7 when 0.7 is chosen, yet the arithmetic result is 3 (even I change from 0.7 to 1.1 or letter C)
→ Can anyone tell me how to fix this problem? Thanks a million!
Calculations using the Date of the Highest High
January 26, 2020 11:07AM
I am hoping one of you scripting geniuses have an easy solution to my question. I’m looking for a script that will do some simple moving average percentage calculations on the day of the Highest Close of the last 200 days and compare to today’s close. Here are the details

Identify the Highest Close on a Daily Chart. Then calculate the numeric difference the close vs. the SMA17, SMA50, SMA200. Here’s the code I’m trying to use to identify the Highest Close. I can find the Highest Close but I’m having trouble establishing the date of the highest close to do the moving average calculations from. Hope this makes sense. Thanks in advance for the help.

declare lower;
def SMA17 = close - SimpleMovingAvg(close, 17);
def SMA50 = close - SimpleMovingAvg(close, 50);
def SMA200 = close - SimpleMovingAvg(close, 200);
def HighJump = SMA17 + SMA50 + SMA200;
def HighPoint = if close == HighestAll(close) then HighJump else Double.NaN;
def HDay = GetValue(GetDayOfMonth(GetYYYYMMDD()), HighestAll(close));
def HMo = GetValue(GetMonth(), HighestAll(close));
def HYr = GetValue(Round(GetYYYYMMDD() / 1000, 0), HighestAll(close));
AddLabel(yes, "High Date:" + HMo+"/" + HDay+"/" + AsPrice(HYr), Color.GRAY);
Re: Fun with ThinkScript
February 06, 2020 09:15PM
hi, rigel

i wanted to convert this trading view code into thinkscrip but it works intermittently in different time frames also i am not able to add the VWMA.

could you help please?!

Thank you!


#//@version=3
#study("CandleValue"winking smiley
#Periodo= input (20, 'Period')
#ValorCandle=(close-open)/(high-low)
#MVC=vwma(ValorCandle,Periodo)
#cor =(MVC>0)?green:red
#p=plot(MVC, color=cor)
#fill (p,plot(0),cor)

input length = 20;
def vwma = sum(volume * close, length) / sum(volume, length);
def Value = vwma;

#-----------------------
input p = 20;

def Valor=(close-open)/(high-low);
def MVC = average( valor, p );
plot m = average(mvc, 6);

plot z = 0;
trading view to think script
February 06, 2020 09:17PM
hi, rigel

i wanted to convert this trading view code into thinkscrip but it works intermittently in different time frames also i am not able to add the VWMA.

could you help please?!

Thank you!


#study("CandleValue"winking smiley
#Periodo= input (20, 'Period')
#ValorCandle=(close-open)/(high-low)
#MVC=vwma(ValorCandle,Periodo)
#cor =(MVC>0)?green:red
#p=plot(MVC, color=cor)
#fill (p,plot(0),cor)

input length = 20;
def vwma = sum(volume * close, length) / sum(volume, length);
def Value = vwma;

#-----------------------
input p = 20;

def Valor=(close-open)/(high-low);
def MVC = average( valor, p );
plot m = average(mvc, 6);

plot z = 0;
Re: Fun with ThinkScript
February 11, 2020 05:43PM
hi to all... does anyone would help converting this pine scrip RSI into thinkscript, i am trying but the line or plot does not follow the 0 to 100 parameters it changes on every time frame and also on different markets.

Thank you in advance

#heavily_mod_RSI

#study(title="Relative Strength Index", shorttitle="RSI"winking smiley

#src = close, len = input(14, minval=1, title="Length"winking smiley
#up = rma(max(change(src), 0), len)
#down = rma(-min(change(src), 0), len)

#rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
#plot(rsi, color=yellow)

input length = 14;
input averageType = AverageType.WILDERS;

plot z = 0;

def NetChgAvg = MovingAverage(averageType, close - close[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(close - close[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);

def up = average( close - close[1], length);
def down = average(close - close[1], length);

def R = if down != 0 then up/down else 0;
plot RSI0 = (down + 1);
trouble with a TOS scripts.
February 12, 2020 09:59PM
Robert,

I have been following your communications with many of the members here regarding Thinkscript and TOS and believe you if anyone could solve my problem. I am currently trying to make a study on a day chart and no matter how I approach it I can't seem to make it work. This may be a limitation of Thinkorswim or just simply my own ignorance. Any guidance would be greatly appreciated,.

Concept:
Let me give you an example of one way I am trying to facilitate but you will understand if it works it can very pretty flexible. Ok so I am trying to use InertiaAll in a day aggregation period. What I want to do for this example is say draw a trendline for the say 5 days before an event. Of course the number of days and which event is not the critical part for the example. Here say on Jan 13th the earnings was announced, the HasEarnings() or get earnings etc. has triggered. Now I want to draw a trendline for the 5 days prior to the earnings based on say the close of each of those 5 days. Or the HLC3 or even the VWAP etc. But I want the trendline to only show proceeding the 5 days prior to each earnings.

Problems I am having:
1: Using InertiaAll only shows the last days on the chart with a length equal to the length parameter in the function. But it gives a great trendline calculated from those last days.
1a) using a script function to pull the previous "length/number" of days data during the earnings event and push it into the inertiaAll function still only works on the last days of the chart. (I am not sure if this is my ignorance or a limitation of the platform)

2: Using Inertia will draw a more flexible length but its not a trendline, it more like a trending Moving average. Putting aside that its not the line I want even that isn't simple for me to only show on earnings events.

3: Its really counter intuitive because its so simple to say put a bubble chart or vertical line at an event. But not a horizontal or other object. I am starting to believe that the real issue is that to draw the line I want; the system would in essence have to go backwards the 5 days (in our example). Where the other objects like chartbubble etc. happen as the bar ticks past it. I have tried quite a few approaches as "out of the box" is my credo lol.


Request: Clearly I am lost and need help. Even if its just to tell me it can't be done in TOS. So any guidance would be appreciated.
First: a clever way to trigger a function as an event happens more flexible than, e.g.
plot sky = if HasEarnings() then close else Double.Nan;

Second: How to draw a proper trendline anywhere in the chart over a specific period. Like the trend in only June on a d-1 year chart

Third: If possible the combination like my example above drawing the trendlines on a configurable number of days leading up to an earnings release.

I apologize this turned into such a long email. Again, feel free to clarify anything, and most of all thank you for any help you can provide.


Jim
Ron
Thinkscript code problem - Referencing secondary symbol
February 16, 2020 08:38PM
Hi forum!
Just started on this forum a few minutes ago and here's a question already smiling smiley

I tried this code to reference a secondary symbol on a 15-min intraday chart and followed the rule of breaking it down before doing the calculation. But it is still not working and I was wondering if I am missing any step or is it TS limitation. So here goes -

On intraday chart of some stock, say "MU" 15-min chart, "INTC" is the secondary symbol I am referencing with the following code

def a = close("INTC", period = aggregationPeriod.DAY);
def b = close("INT "winking smiley; #no idea why it's inserting a smiley here instead of "close parentheses"???!
plot x = a; #works fine
plot y = b; #works fine
plot z = a + b; # plots a horizontal straight line only for all the bars of the day based on the value of the first bar of the day??!!

But when I add a random numeric value to "a", like in the line below, it works just fine -
plot z = a + 10; # draws the curved line indicator correctly (ie, a+10) for all bars of the day as expected and not just a horizontal line based on the calculation of the first bar of the day only.

Any explanation/insight pls? Thanks much in advance!
Re: vwma
February 18, 2020 03:45AM
Mobil

Can you point to the indicator you want to convert?

I see in your code two problems:

- you define Value, but do nothing with it.

-the second part will need to be plotted as a lower indicator not in the chart.
Re: Fun with ThinkScript
February 18, 2020 03:20PM
hi, rigel here is the pine script...


#heavily_mod_RSI

#study(title="Relative Strength Index", shorttitle="RSI"winking smiley

src = close, len = input(14, minval=1, title="Length"winking smiley
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)

rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, color=yellow)


... can you help me convert it to thinkscript, please, i have try but no good results. it should feed into a 0 to 100 parameters.

Thank you again.
Re:rsi
February 19, 2020 03:29AM
Mobile

That is just the rsi indicator, you don't need to program it, use the function in TOS
Re: Fun with ThinkScript
February 19, 2020 12:55PM
rigel, this is a different RSI, not the same on tos, it gives you better divergence.
Re: Fun with ThinkScript
February 20, 2020 09:19AM
Hi everyone

I have been using TOS for about 2 years - and normally can think my way through creating very simple stuff ... but for some reason I have a massive brain block and cannot think this one through even though it seems like it should be easy.
I am wondering if someone is willing to help me please?

I am looking to create a moving average of the HIGH and then of the LOW - creating an envelope.

So for the example - the past 3 period highs average for the top then the past 3 period lows for the bottom.

Right now in TOS the only option is the HLC/3 (or OHLC/4) - I cannot figure out how to create an SMA of H/3 and L/3 ...

Thank you for any imput.

-B
Re: Horizontal line from a given average at specified time
February 24, 2020 03:41PM
Hi there... I was wondering if someone can help with the code for the Horizontal Line Moving Average...tyring to make it a MTF...so it would display the hight time frame moving average as a line...

# Plot longer moving average support lines

def lastBar = HighestAll(if !IsNaN(close) then BarNumber() else 0);
def mostRecentClose = HighestAll(if BarNumber() == lastBar then close else 0);
def barNumber = BarNumber();
def barCount = HighestAll(If(IsNaN(close), 0, barNumber));

input period = {default "AggregationPeriod.Hour", "AggregationPeriod.Day"};
input avgType = {default "simple", "exponential"};
input shtAvg = 50;
input medAvg = 100;
input lngAvg = 200;

def avg1;
def avg2;
def avg3;
def data = close(period = period);
switch (avgType) {
case "simple":
avg1 = Average(data, shtAvg);
avg2 = Average(data, medAvg);
avg3 = Average(data, lngAvg);
case "exponential":
avg1 = ExpAverage(close, shtAvg);
avg2 = ExpAverage(close, medAvg);
avg3 = ExpAverage(close, lngAvg);
}

input proximity = 10; #ref 0.5 = 1/2%

def value1 = GetValue(avg1, BarNumber() - HighestAll(lastBar));
def value2 = GetValue(avg2, BarNumber() - HighestAll(lastBar));
def value3 = GetValue(avg3, BarNumber() - HighestAll(lastBar));
def inRange1 = mostRecentClose > (value1 * (1 - proximity / 100)) and mostRecentClose < (value1 * (1 + proximity / 100));
def inRange2 = mostRecentClose > (value2 * (1 - proximity / 100)) and mostRecentClose < (value2 * (1 + proximity / 100));
def inRange3 = mostRecentClose > (value3 * (1 - proximity / 100)) and mostRecentClose < (value3 * (1 + proximity / 100));

def avg1Line = if barNumber == 1 then Double.NaN else if barNumber == barCount then avg1 else if barNumber == barCount then Double.NaN else avg1Line[1];
def avg2Line = if barNumber == 1 then Double.NaN else if barNumber == barCount then avg2 else if barNumber == barCount then Double.NaN else avg2Line[1];
def avg3Line = if barNumber == 1 then Double.NaN else if barNumber == barCount then avg3 else if barNumber == barCount then Double.NaN else avg3Line[1];

plot sandline1 = avg1Line;
sandline1.AssignValueColor(globalColor("sand" ));
sandline1.SetLineWeight(1);
sandline1.SetHiding(!inRange1);
AddChartBubble(yes, if inRange1 and BarNumber() == HighestAll(Lastbar+3) then sandline1 else double.nan, shtAvg + (if avgType == avgType.simple then "sma" else "ema" ), globalColor("sand" ), 0);
plot sandline2 = avg2Line;
sandline2.AssignValueColor(globalColor("sand" ));
sandline2.SetLineWeight(1);
sandline2.SetHiding(!inRange2);
AddChartBubble(yes, if inRange2 and BarNumber() == HighestAll(Lastbar+3) then sandline2 else double.nan, medAvg + (if avgType == avgType.simple then "sma" else "ema" ), globalColor("sand" ), 0);
plot sandline3 = avg3Line;
sandline3.AssignValueColor(globalColor("sand" ));
sandline3.SetLineWeight(1);
sandline3.SetHiding(!inRange3);
AddChartBubble(yes, if inRange3 and BarNumber() == HighestAll(Lastbar+3) then sandline3 else double.nan, lngAvg + (if avgType == avgType.simple then "sma" else "ema" ), globalColor("sand" ), 0);

AddLabel(yes, "proximity: " + proximity + "%", color.white);
AddLabel(yes, shtAvg + (if avgType == avgType.simple then "sma: " else "ema: " ) + round(avg1,2), globalColor("sand" )); #for reference only
AddLabel(yes, medAvg + (if avgType == avgType.simple then "sma: " else "ema: " ) + round(avg2,2), globalColor("sand" )); #for reference only
AddLabel(yes, lngAvg + (if avgType == avgType.simple then "sma: " else "ema: " ) + round(avg3,2), globalColor("sand" )); #for reference only

DefineGlobalColor("sand", CreateColor(255,204,102)); #sand
Re: Horizontal line from a given average at specified time
February 24, 2020 04:22PM
This is what I do on my min chart for the yearly moving averages. Hope this helps.


Jim

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

input aggregationPeriod = AggregationPeriod.DAY;
input averageType = averageType.SIMPLE;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
def smalength200=180;
def smalength50=50;
def smalength20=20;
input ShowTodayOnly={"No", default "Yes"};
def s=ShowTodayOnly;
#
def today=if s==0 OR getday()==getlastday() AND secondsfromtime(0929)>=0 then 1 else 0;
plot PrevDayClose;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { PrevDayClose = Double.NaN;
} else { PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);
}
PrevDayClose.SetDefaultColor(GetColor(9));
PrevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot PrevDayHigh;
if showOnlyLastPeriod and !IsNaN(high(period = aggregationPeriod)[-1]) { PrevDayhigh= Double.NaN;
} else { PrevDayhigh= Highest(high(period = aggregationPeriod)[-displace], length);
}
PrevDayHigh.SetDefaultColor(GetColor(8));
PrevDayHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def priceSMA = close(GetSymbol(),AggregationPeriod.DAY);

plot ESMADay180;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { ESMADay180= Double.NaN;
} else { ESMADay180= MovingAverage(AverageType.EXPONENTIAL,priceSMA[-displace],smalength200);
}
ESMADay180.SetDefaultColor(GetColor(2));
AddchartBubble(BarNumber()==highestall(BarNumber())-1,ESMADay180,"EMA_180",Color.CYAN,yes);
ESMADay180.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


plot SMADay180;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { SMADay180= Double.NaN;
} else { SMADay180= MovingAverage(AverageType.SIMPLE,priceSMA[-displace],smalength200);
}
SMADay180.SetDefaultColor(GetColor(6));
SMADay180.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Addlabel(yes,"sma200:"+SMADay180,color.BLUE);
AddchartBubble(BarNumber()==highestall(BarNumber())-1,SMADay180,"SMA_180",Color.LIGHT_GREEN,yes);
Alert(crosses(open(getSymbol(),AggregationPeriod.DAY),smaday180,crossingDirection.ABOVE),"Crossing 200SMA:$"+smaday180,Alert.BAR,Sound.Ring);

plot SMADay50;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { SMADay50= Double.NaN;
} else { SMADay50= MovingAverage(AverageType.SIMPLE,priceSMA[-displace],smalength50);
}
SMADay50.SetDefaultColor(color.CYAN);
SMADay50.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Addlabel(yes,"sma50:"+SMADay50,color.CYAN);

plot ESMADay20;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { ESMADay20= Double.NaN;
} else { ESMADay20= MovAvgExponential(priceSMA[-displace],smalength20);
}
ESMADay20.SetDefaultColor(color.CYAN);
ESMADay20.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ESMADay20.SetLineWeight(3);

plot ESMADay40;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { ESMADay40= Double.NaN;
} else { ESMADay40= MovAvgExponential(priceSMA[-displace],2*smalength20);
}
ESMADay40.SetDefaultColor(color.ORANGE);
ESMADay40.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ESMADay40.SetLineWeight(3);
Addlabel(yes,"Esma20:"+ESMADay20,color.CYAN);

#plot MiddleLR;
#if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { MiddleLR= Double.NaN;
#} else { MiddleLR= Inertia(close[-displace],smalength200);
#}
#MiddleLR.SetDefaultColor(color.DARK_ORANGE);
#MiddleLR.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot Closeprevious10perc;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { Closeprevious10perc= Double.NaN;
} else { Closeprevious10perc= 1.05*Highest(close(period = aggregationPeriod)[-displace], length);
}
Closeprevious10perc.SetDefaultColor(color.PINK);
Closeprevious10perc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
AddChartBubble(crosses(close,closeprevious10perc,crossingDirection.ABOVE) and SecondsTillTime(0929)<=0,closeprevious10perc,"GpU-LE:$"+close,Color.CYAN,no);
Alert(crosses(close,closeprevious10perc,crossingDirection.ABOVE) and SecondsTillTime(0929)<=0,"GpU-LE:$"+closeprevious10perc,Alert.BAR,Sound.Chimes);

AddChartBubble(crosses(open(getSymbol(),AggregationPeriod.DAY),closeprevious10perc,crossingDirection.ABOVE),closeprevious10perc,"GpU-LE:$"+close,Color.CYAN,no);
Alert(crosses(open(getSymbol(),AggregationPeriod.DAY),closeprevious10perc,crossingDirection.ABOVE),"GpU-LE:$"+closeprevious10perc,Alert.BAR,Sound.Chimes);

plot openprevious10perc;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { openprevious10perc= Double.NaN;
} else { openprevious10perc= 1.1*open(period = aggregationPeriod);
}
openprevious10perc.SetDefaultColor(color.DARK_GREEN);
openprevious10perc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);




###################################################
heavily_mod_RSI
February 28, 2020 10:39AM
#heavily_mod_RSI

#study(title="Relative Strength Index", shorttitle="RSI"winking smiley

src = close, len = input(14, minval=1, title="Length"winking smiley
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)

rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, color=yellow)

hi, this is pinescriot version of RSI and it has better divergence then tos.
... can anyone help me convert it to thinkscript, please, i have try but no good results. it should fit into a 0 to 100 parameters.

Thank you again.
RSI convertion
February 28, 2020 10:40AM
#heavily_mod_RSI

#study(title="Relative Strength Index", shorttitle="RSI"winking smiley

src = close, len = input(14, minval=1, title="Length"winking smiley
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)

rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, color=yellow)

hi, this is pinescriot version of RSI and it has better divergence then tos.
... can anyone help me convert it to thinkscript, please, i have try but no good results. it should fit into a 0 to 100 parameters.

Thank you again.
corrected
February 28, 2020 09:32AM
i need help looking to write a study that captures the 4 period ema of the highs, not the closing price


minute 1.52

[www.youtube.com]
Re: corrected
March 05, 2020 09:03AM
kevinmick Wrote:
-------------------------------------------------------
> i need help looking to write a study that captures
> the 4 period ema of the highs, not the closing
> price
>
>
> minute 1.52
>
>



Thank you Kevin - but the link to the video is not embedded there so there is nothing to be able to click.

I am still banging my head off the table trying to figure this out haha. It seems like it should be easy.
Coding the studies
March 07, 2020 08:42PM
Does anyone know how to code these studies or has a similar study to share? Thank you!
Re: RSI convertion
March 24, 2020 07:39AM
The code you are posting is the rsi. If it is modified and has better divergencies as you saiy, then the code is not complete.

Can you post a link?

R
I need this code
March 30, 2020 01:32AM
Hi ..

On Thinkorswim , I want to add VIX chart to the current chart. so I can see for e.g. SPY with VIX chart in the same window.
Overlay two stocks
April 03, 2020 12:08PM
Sara you can use a build in function
Link
Re: Overlay two stocks
April 04, 2020 05:52AM
rigel Wrote:
-------------------------------------------------------
> Sara you can use a build in function
> Link


Thank you regil .. I know there is a "Comparison indicator" ready to use in thinkorswim, but what I want is the code to use it with some indicator as a cnfirmation.
Re: Watchlist column issue
April 06, 2020 07:34AM
Maybe this was already covered somewhere, but I wasn't able to find it.

How could I get the result of an indicator to show in a watchlist?

For example, if I had an SLI indicator to fire on the chart when I have 3 of 4 up with a light green bar, and 4 of 4 up with a dark green bar. How could I get add that to the watchlist to give me a light green 3 for 3 of 4 up, and a dark green 4 for a 4 of 4 up? For downs I would use light red, and dark red.

I sort of have this already, but in the watchlist I can only choose 4 hours, and I've prefer to use the correct number of mins that GW recommends.



Edited 2 time(s). Last edit at 04/08/2020 11:33AM by RichieRick.
TCB
Re: Overlay two stocks
April 06, 2020 09:18PM
I wish that TOS would let you use custom column time frames but they do not allow that function as I have called and inquired about that in the past.
Re: Watchlist column issue
April 06, 2020 11:25PM
Yeah I called about it before also. No luck either.

Well a study can do it based on the Chart time frame selected. I think (not 100% sure) you can also define the aggregation period in a study. Seems like it has to be in milliseconds if I remember.

I was hoping that you could just setup a watchlist column to call a specific user defined study, and then use Add Label to have it pop the numbers or text you'd want in the column if the conditions were preset. Else show nothing.

So far I've come up with a big fat goose egg. smiling smiley

R



Edited 1 time(s). Last edit at 04/08/2020 11:34AM by RichieRick.
Re: Overlay two stocks
April 07, 2020 03:58PM
You can't do it with code,I believe, due to a conflict of scales.The chart is linked to a symbol with its own scale. If you want vix overlayed, it would be necessary to have a second scale to display it.
Re: Watchlist column issue
April 08, 2020 11:36AM
I didn't realize the I didn't update the Subject line. It was still stuck on "Overlay two stocks" Sorry for that.


I have a TOS study that will draw a vertical line on the chart using any time frame I want. It draws this line when I have 3 of 4 indicators crossing or 4 of 4 indicators crossing on that time frame. I'd like the same thing in my watchlist column, but it only allows me to select 2 hour or 4 hour in the watchlist column. If my chart time frame is for example 3 hours, then neither the 2 hour or the 4 hour would match up.

I was thinking that there might be a way to "trick" the watchlist column into giving what I want by calling a specific study where I can control the aggregation period.

Hope that made sense. smiling smiley
Re: Fun with ThinkScript
April 08, 2020 02:57PM
Greetings!

I'd like to include a scan query with ThinkScript for a watchlist that identifies when an equity's last 3 candlesticks are up (green). I don't care where the 4th candle begins.

I wasn't able to locate this scenario anywhere else so I'm hopeful any one of the experts here could quickly assist.

Thanks in advance for your help!

=Aaron=
Sorry, only registered users may post in this forum.

Click here to login