Does anyone know how to make a candle change colors if its 1.5x the average size of the last 15 bars of any time denomination? I can supply the code for the average bar part. I just want all candles to turn yellow if they are 1.5 times the size
Code:def cond = (high - low) > Average((high - low), 15) * 1.5; input usepricecolor = yes; AssignPriceColor(if !usepricecolor then Color.CURRENT else if cond then Color.YELLOW else Color.CURRENT);
Does anyone know how to make a candle change colors if its 1.5x the average size of the last 15 bars of any time denomination? I can supply the code for the average bar part. I just want all candles to turn yellow if they are 1.5 times the size
Code:def cond = (high - low) > Average((high - low), 15) * 1.5; input usepricecolor = yes; AssignPriceColor(if !usepricecolor then Color.CURRENT else if cond then Color.YELLOW else Color.CURRENT);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
@SleepyZ , thanks for this. I just used your code to "color" the candles after they meet other multiple criteria. I also have two conditions and two colors. I am using a white background with "current" candles white also, so when the criteria is met, they appear and really stand out. Perfect !!
To clarify, I have two conditions, two colors, and each condition has multiple criteria.
@SleepyZ This indicator is amazing, but sometimes it doesn't activate when i open my tos platform. I have to go in and tinker with variables in the code and keep hitting apply to hope the indicator works. Sometimes i open my platform and its working fine. Do you know why I could be having these issues?
Ruby:def cond = (high - low) > Average((high - low), 15) * 1.5; input usepricecolor = yes; AssignPriceColor(if !usepricecolor then Color.CURRENT else if cond then Color.YELLOW else Color.CURRENT); input test = yes; AddChartBubble(test, low * .9994, "C " +cond + "\nHL " + (high - low) + "\nA " + (Average((high - low), 15) * 1.5), if cond then Color.YELLOW else Color.gray, no);
So have been using it on emini, so no problem with light trading there... when i changed the parameters a bit i got the bars to stop getting painted, so it could be a problem with paint function as none of the bubbles have NA in them.
http://tos.mx/KzWNosI heres link to chart.
New combined code
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 #); def cond = (high - low) > Average((high - low), 10) * 1.7; input usepricecolor = yes; AssignPriceColor(if !usepricecolor then Color.CURRENT else if cond then Color.YELLOW 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 " + cond + "\nHL " + (high - low) + "\nA " + (Average((high - low), 15) * 1.5), if cond then Color.YELLOW else Color.GRAY, no);
@SleepyZ can i add a condition in the code to cap the value to say 2.0x avg bar range of last amount of bars? so it would only paint bars between 1.5-2X avg size of last 10 bars?
Code:input factor = 1.5;#Hint factor: limited to 2.0 input length = 10; def cond = (high - low) > Average((high - low), length) * min(factor, 2.0);
Code:input factor = 1.5;#Hint factor: limited to 2.0 Assert(factor <= 2.0, "Factor cannot exceed 2.0. Enter a value less than 2.0 @ input factor"); input length = 10; def cond = (high - low) > Average((high - low), length) * factor;
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.5;#Hint factor: limited to 2.0 input length = 10; def cond = (high - low) > Average((high - low), length) * min(factor, 2.0); input usepricecolor = yes; AssignPriceColor(if !usepricecolor then Color.CURRENT else if cond then Color.YELLOW 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, 2.0)) + "\nF " + Min(factor, 2.0), if cond then Color.YELLOW else Color.GRAY, no);
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.