Thepremier
New member
Can someone help me with a script for an outside day and and an inside day? I would like to create a scan for them.
Last edited:
I can't seem to get this working: Can someone take a look and see what's wrong here? Thanks I have no coding skills. This was posted on Twitter and said to work on TOS, but not for me.
// TW - Holy Grail
// highlights holy grail pattern
study(title="TW - Holy Grail", shorttitle="TW - Holy Grail", overlay=true)
outBar = low[1] < low[2] and high[1] > high[2]
inBar = low > low[1] and high < high[1]
holyGrail = inBar and outBar == 1
barcolor (holyGrail ==1 ? yellow : na)
barcolor (holyGrail ==1 ? yellow : na, offset = -1)
# golden_01b
# https://www.tradingview.com/script/uYiilgYb-TW-Golden-Indicators/
# convert tradingview study
#// TW Golden Indicators Package
#// This package features BB (with 20 ma), inside bar color change (white), outside bar color change (black), and holy grail 2-candle pattern background higlhlight (yellow)
def lastbar = !isnan(close[0]) and isnan(close[-1]);
def src = close;
input length = 20;
input mult = 2.0;
def mult2 = if mult > 50 then 50 else if mult < 0.001 then 0.001 else mult;
# https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AverageType
# EXPONENTIAL, HULL, SIMPLE, WEIGHTED, WILDERS
input avg1_type = AverageType.simple;
def basis = MovingAverage(avg1_type, src, length);
def dev = mult2 * StDev( src , length );
def upper = basis + dev;
def lower = basis - dev;
# horz lines
plot basisLine = highestAll(if isNaN(close[-1]) then basis else Double.NaN);
basisline.SetDefaultColor(Color.red);
basisline.SetStyle(Curve.SHORT_DASH);
plot upperLine = highestAll(if isNaN(close[-1]) then upper else Double.NaN);
upperline.SetDefaultColor(Color.magenta);
plot lowerLine = highestAll(if isNaN(close[-1]) then lower else Double.NaN);
lowerline.SetDefaultColor(Color.magenta);
# inside and outside bars
def inBar = low > low[1] and high < high[1];
def outBar = low < low[1] and high > high[1];
def holyGrail = low[1] < low[2] and high[1] > high[2] and low > low[1] and high < high[1];
input bubble_ht_offset = 0.0006;
addchartbubble(inbar, (high * (1 + bubble_ht_offset)), "IB", color.yellow, yes);
addchartbubble(outbar, (low * (1 - bubble_ht_offset)), "OB", color.blue, no);
def off = 1;
addchartbubble(lastbar[off] and holyGrail[off] and inbar[off], close, "Holy Grail" + "\nInbar", color.yellow, yes);
addchartbubble(lastbar[off] and holyGrail[off] and outbar[off], close, "Holy Grail" + "\nOutbar", color.yellow, yes);
plot hg2 = holygrail;
hg2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_wedge_up);
hg2.SetDefaultColor(Color.white);
hg2.setlineweight(3);
#
this is incredible, thanks so much for porting this over to ToS.i just made this upper chart study for someone. will post it today
ref this
https://www.tradingview.com/script/uYiilgYb-TW-Golden-Indicators/
Ruby:# golden_01b # https://www.tradingview.com/script/uYiilgYb-TW-Golden-Indicators/ # convert tradingview study #// TW Golden Indicators Package #// This package features BB (with 20 ma), inside bar color change (white), outside bar color change (black), and holy grail 2-candle pattern background higlhlight (yellow) def lastbar = !isnan(close[0]) and isnan(close[-1]); def src = close; input length = 20; input mult = 2.0; def mult2 = if mult > 50 then 50 else if mult < 0.001 then 0.001 else mult; # https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AverageType # EXPONENTIAL, HULL, SIMPLE, WEIGHTED, WILDERS input avg1_type = AverageType.simple; def basis = MovingAverage(avg1_type, src, length); def dev = mult2 * StDev( src , length ); def upper = basis + dev; def lower = basis - dev; # horz lines plot basisLine = highestAll(if isNaN(close[-1]) then basis else Double.NaN); basisline.SetDefaultColor(Color.red); basisline.SetStyle(Curve.SHORT_DASH); plot upperLine = highestAll(if isNaN(close[-1]) then upper else Double.NaN); upperline.SetDefaultColor(Color.magenta); plot lowerLine = highestAll(if isNaN(close[-1]) then lower else Double.NaN); lowerline.SetDefaultColor(Color.magenta); # inside and outside bars def inBar = low > low[1] and high < high[1]; def outBar = low < low[1] and high > high[1]; def holyGrail = low[1] < low[2] and high[1] > high[2] and low > low[1] and high < high[1]; input bubble_ht_offset = 0.0006; addchartbubble(inbar, (high * (1 + bubble_ht_offset)), "IB", color.yellow, yes); addchartbubble(outbar, (low * (1 - bubble_ht_offset)), "OB", color.blue, no); def off = 1; addchartbubble(lastbar[off] and holyGrail[off] and inbar[off], close, "Holy Grail" + "\nInbar", color.yellow, yes); addchartbubble(lastbar[off] and holyGrail[off] and outbar[off], close, "Holy Grail" + "\nOutbar", color.yellow, yes); plot hg2 = holygrail; hg2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_wedge_up); hg2.SetDefaultColor(Color.white); hg2.setlineweight(3); #
@halcyonguy ???this is incredible, thanks so much for porting this over to ToS.
is there anyway to recolor the IB/OB candle itself as well?
"Hammer candle script"
input length = 20;
input trendSetup = 3;
input bodyFactor = 0.3;
input shadowFactor = 2.0;
assert(bodyFactor >= 0, "'body factor' must not be negative: " + bodyFactor);
assert(shadowFactor >= 0, "'shadow factor' must not be negative: " + shadowFactor);
def BodyHeight = BodyHeight();
def AverageBodyHeight = Average(BodyHeight, length);
def ErrMargin = 0.05 * AverageBodyHeight;
def IsShort = BodyHeight < bodyFactor * AverageBodyHeight;
plot Bullish = IsDescending(close, trendSetup) and
IsShort and
high - Max(open, close) <= ErrMargin and
Min(open, close) - low > shadowFactor * BodyHeight;
Bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Bullish.SetDefaultColor(GetColor(4));
Bullish.SetLineWeight(2);
--------------------------------------------------------------------------------------------------------------
Updated script ( need help)
def lo = low;
def hi = high;
def vo = volume;
def l = If (hi[1] >= hi[0] and lo[1] < lo[0]);
def s = If (hi[1] <= hi[0] and lo[1] > lo[0]);
plot did = l;
plot did = s;
plot UpArrow = l;
plot DnArrow = s;
UpArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DnArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
did.SetPaintingStrategy( if close < open then UpArrow);
did.SetPaintingStrategy( if close > open then DnArrow);
did.AssignValueColor(if close > open then Color.GREEN else if close < open then Color.RED else Color.WHITE);
did.SetLineWeight(3);
I tried to update the code but not sure whats wrong. Sorry im new to this. If someone can help me would appreciate it
I am trying to see if I can do the the following. I have no computer language knowledge so very sorry to keep asking stupid questions. I am trying to add to the above indicator to have Outside Bar on it as well. Thank you very much.@TieJiaoJie @roughsleeper
there are several examples listed below, in similar posts.
here is one i made , that counts how many bars were smaller before the outside bar
https://usethinkscript.com/threads/...st-65-most-recent-days.7483/page-2#post-72474
declare lower;
input offset = 1;
#def count = 2;
def range = high – low;
#def priorrange = high[1] – low[1];
def priorrange = range[1];
def nibsize = AbsValue(((open – close) / (open[1] – close[1]) - 1));
def sizeConstraint = AbsValue((range / priorrange) - 1) >= .5 and nibsize >= .5;
def hiLowConstraint = high <= high[1] and low >= low[1];
def inside_bar = sizeConstraint and hiLowConstraint;
rec insideBarRange = CompoundValue(1, if inside_bar then range else insideBarRange[1], Double.NaN);
#plot s = inside_bar && lowest(range,count);
def plotRightExpansionArea = !IsNaN(close[1]) and IsNaN(close[0]);
rec longEntry = CompoundValue(1, if plotRightExpansionArea[-1] then if inside_bar[offset] then high[offset] + 0.01 else Double.NaN else longEntry[1], Double.NaN);
rec longExit = CompoundValue(1, if plotRightExpansionArea[-1] then if inside_bar[offset] then longEntry + insideBarRange else Double.NaN else longExit[1], Double.NaN);
#plot longEntryLevel = longEntry;
#longEntryLevel.SetDefaultColor(Color.GREEN);
#plot longExitLevel = longExit;
#longExitLevel.SetDefaultColor(Color.DARK_GREEN);
#longExitLevel.SetPaintingStrategy(PaintingStrategy.DASHES);
#longExitLevel.SetLineWeight(1);
#dataplot
#ALERT
plot entryline = if close > longEntry then 0 else 1;
#1 = green , 0 = red
Looks like no contributor has been able to help you. It could be that it is not clear what you are asking or you did not provide enough information.I am trying to create a scan, chart indicator, and lower study that I could use for mobile to identify an inside day candle I have found some similar ones here and one off of hanntech website but I can't get this to be consistently accurate and the lower study doesn't work at all. I feel like I'm definitely missing something on the syntax
Unsure of how to upload screenshots to the forum, Here are directions.Provide a marked-up screenshot of what a chart that displays what all your conditions would look like.
Questions without images are much less likely to get a response!
# Inside Bar
# Mobius
# 8.7.2017
def inside = high < high[1] and low > low[1];
plot inside_bar = inside;
inside_bar.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
inside_bar.SetDefaultColor(Color.MAGENTA);
inside_bar.SetLineWeight(1);
input Color_Candles_within_MTF_InsideBars = yes;
assignpriceColor(if [B]Color_Candles_within_MTF_InsideBars and[/B] insidebar then color.white else color.current);
/CODE]
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
How to create alerts for Outside Bars | Questions | 1 | ||
M | show which stocks trade outside the zone | Questions | 2 | |
O | Outside Bar High/Low | Questions | 4 | |
K | Full candle outside of Bollinger Band | Questions | 7 | |
D | Inside Bar OutSide Bar Clouds For ThinkOrSwim | Questions | 4 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.