I have 2 studies that are basically the same but the variables within the studies are changed. Essentially the first study is painting every bar orange that is greater than 1x the average range of the last 10 bars, while the other is painting bars yellow that are greater than 1.5x the average range of the last 10 bars. I cant run them together because any bar qualifying as 1.5x will just be painted orange by default. Im wondering if I can combine them to have both orange and yellow paint bars that meet the criteria on my chart as well as bars over 2.0x average of last 10 bars to be painted as well. Sleepyz helped me greatly on the initial code.
plot Data = close;def Bull =
close > open and
open - low > high - open;
def Bear =
close < open and
high - open > open - low
;
#assignPriceColor(
# if Bull then Color.dark_green
# else if Bear then Color.dark_red
# else Color.Current
#);
input factor = 1;#Hint factor: limited to 1.49
input length = 10;
def cond = (high - low) > Average((high - low), length) * min(factor, 1.49);
input usepricecolor = yes;
AssignPriceColor(if !usepricecolor
then Color.CURRENT else
if cond then Color.orange
else if Bull then Color.DARK_GREEN
else if Bear then Color.DARK_RED
else Color.CURRENT);
input test = yes;
AddChartBubble(test, low * .9994, "C " + cond + "\nHL " + (high - low) + "\nA " + (Average((high - low), length) * Min(factor, 1)) + "\nF " + Min(factor, 1), if cond then Color.orange
else Color.GRAY, no);
Ruby:def Bull = close > open and open - low > high - open; def Bear = close < open and high - open > open - low ; #assignPriceColor( # if Bull then Color.dark_green # else if Bear then Color.dark_red # else Color.Current #); input factor = 1;#Hint factor: limited to 1.49 input length = 10; def cond1 = (high - low) > Average((high - low), length) * 1; def cond2 = (high - low) > Average((high - low), length) * 1.5; def cond3 = (high - low) > Average((high - low), length) * 2; input usepricecolor = yes; AssignPriceColor(if !usepricecolor then Color.CURRENT else if cond3 then Color.WHITE else if cond2 then Color.YELLOW else if cond1 then Color.MAGENTA else if Bull then Color.DARK_GREEN else if Bear then Color.DARK_RED else Color.CURRENT); input test = no; AddChartBubble(test, low * .9994, "C 3: " + cond3 + "\n 2: " + cond2 + "\n 1: " + cond1 + "\nHL " + (high - low) + "\nA " + (Average((high - low), length) * Min(factor, 1)) + "\nF " + Min(factor, 1), if cond3 then color.white else if cond2 then color.yellow else if cond1 then color.magenta else Color.GRAY, no);
Hey @Joshua Im looking to add a wrinkle to this code you provided me a while back. Basically I want to paint every bull bar closing below its midpoint as a bear bar and every bear bar closing above its midpoint as a bull bar. Thanks so muchTry these, the top one follows what you said. If that's not what you actually meant, try the bottom one.
Ruby:def Bull = Close > Open and Open - Low > Close - Open; def Bear = Close < Open and High - Open > Open - Close ; assignPriceColor( if Bull then Color.Dark_Green else if Bear then Color.Plum else Color.Current );
Ruby:def Bull = Close > Open and Open - Low > High - Open; def Bear = Close < Open and High - Open > Open - Low ; assignPriceColor( if Bull then Color.Dark_Green else if Bear then Color.Plum else Color.Current );
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Fractal Pivots Indicator - Need help adding signal | Questions | 1 | ||
C | Simple MACD + RSI Indicator | Questions | 1 | |
Adding a moving average to the ADX indicator | Questions | 1 | ||
S | Close Above High / Low Indicator | Questions | 1 | |
A | Accumulation/Distribution increasing indicator | Questions | 1 |
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.