Fibonacci Colored Candles

rivera1239

New member
How can I get this to work: What I'm trying to do is to change the candle colors to red if the price is below the retracement level and green if it's above with arrows to indicate when the price crosses the retracement level. I can't get this to run

# Fibonacci Candles

input price = close;
input retraceType = {default Fibonacci, Alternate};
input retraceLevel = {default 23.6, 38.2, 50, 61.8, 100};
input PaintBars = yes;

def highest = Highest(price, lookBackLength);
def lowest = Lowest(price, lookBackLength);
def retrace = (highest - lowest) * retraceLevel / 100 + lowest;

plot retraceLevel = retrace;
retraceLevel.SetDefaultColor(GetColor(5));
retraceLevel.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

AssignPriceColor(if PaintBars and price < retrace then CreateColor(204, 0, 51) else Color.GREEN);

plot ArrowDown = price crosses above retraceLevel;
ArrowDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ArrowDown.SetDefaultColor(Color.RED);
ArrowDown.SetLineWeight(3);

plot ArrowUp = price crosses below retraceLevel;
ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowUp.SetDefaultColor(Color.GREEN);
ArrowUp.SetLineWeight(3);

# End Code for Fibonacci Candles


Any help would be appreciated. Thanks
 
Solution
How can I get this to work: What I'm trying to do is to change the candle colors to red if the price is below the retracement level and green if it's above with arrows to indicate when the price crosses the retracement level. I can't get this to run

# Fibonacci Candles

input price = close;
input retraceType = {default Fibonacci, Alternate};
input retraceLevel = {default 23.6, 38.2, 50, 61.8, 100};
input PaintBars = yes;

def highest = Highest(price, lookBackLength);
def lowest = Lowest(price, lookBackLength);
def retrace = (highest - lowest) * retraceLevel / 100 + lowest;

plot retraceLevel = retrace;
retraceLevel.SetDefaultColor(GetColor(5));
retraceLevel.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

AssignPriceColor(if...
How can I get this to work: What I'm trying to do is to change the candle colors to red if the price is below the retracement level and green if it's above with arrows to indicate when the price crosses the retracement level. I can't get this to run

# Fibonacci Candles

input price = close;
input retraceType = {default Fibonacci, Alternate};
input retraceLevel = {default 23.6, 38.2, 50, 61.8, 100};
input PaintBars = yes;

def highest = Highest(price, lookBackLength);
def lowest = Lowest(price, lookBackLength);
def retrace = (highest - lowest) * retraceLevel / 100 + lowest;

plot retraceLevel = retrace;
retraceLevel.SetDefaultColor(GetColor(5));
retraceLevel.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

AssignPriceColor(if PaintBars and price < retrace then CreateColor(204, 0, 51) else Color.GREEN);

plot ArrowDown = price crosses above retraceLevel;
ArrowDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ArrowDown.SetDefaultColor(Color.RED);
ArrowDown.SetLineWeight(3);

plot ArrowUp = price crosses below retraceLevel;
ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowUp.SetDefaultColor(Color.GREEN);
ArrowUp.SetLineWeight(3);

# End Code for Fibonacci Candles


Any help would be appreciated. Thanks

A few mods were made to at least get this to display.

1. input retraceLevel = {default "23.6", "38.2", "50", "61.8", "100"}; needed parenthesis
2. input lookbacklength = 10; missing
3. Name changed as it was named same as #1. above

Image displayed at 61.8 retracement

Screenshot-2023-02-10-090946.png

Code:
# Fibonacci Candles

input price = close;
input retraceType = {default Fibonacci, Alternate};
input retraceLevel = {default "23.6", "38.2", "50", "61.8", "100"};
input lookbacklength = 10;
input PaintBars = yes;

def highest = Highest(price, lookbacklength);
def lowest = Lowest(price, lookbacklength);
def retrace = (highest - lowest) * retraceLevel / 100 + lowest;

plot retracement = retrace;
retracement.SetDefaultColor(GetColor(5));
retracement.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);

AssignPriceColor(if PaintBars and price < retrace then CreateColor(204, 0, 51) else Color.GREEN);

plot ArrowDown = price crosses above retrace;
ArrowDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ArrowDown.SetDefaultColor(Color.RED);
ArrowDown.SetLineWeight(3);

plot ArrowUp = price crosses below retrace;
ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowUp.SetDefaultColor(Color.GREEN);
ArrowUp.SetLineWeight(3);

# End Code for Fibonacci Candles
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

A few mods were made to at least get this to display.

1. input retraceLevel = {default "23.6", "38.2", "50", "61.8", "100"}; needed parenthesis
2. input lookbacklength = 10; missing
3. Name changed as it was named same as #1. above


I think I managed to make it run, what I want to try to do is that bars doesn't change colors after a big retracement candle, it doesnt matter the count, as soon as that bar is not broken, candles will stay the same color.


input price = close;
input retraceType = {default "Fibonacci", "Alternate"};
input retraceLevel = {default "23.6", "38.2", "50", "61.8", "100"};
input PaintBars = yes;
input lookbackLength = 10;

def barIndex = BarIndex();
def highest;
def lowest;
def retrace;

if barIndex > lookbackLength {
highest = Highest(price, lookbackLength);
lowest = Lowest(price, lookbackLength);
retrace = (highest - lowest) * (retraceLevel / 100) + lowest;
}

plot retracePlot = retrace;
retracePlot.SetDefaultColor(GetColor(5));
retracePlot.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

AssignPriceColor(if PaintBars and price < retrace then CreateColor(204, 0, 51) else Color.GREEN);

plot ArrowDown = price crosses above retracePlot;
ArrowDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ArrowDown.SetDefaultColor(Color.RED);
ArrowDown.SetLineWeight(3);

plot ArrowUp = price crosses below retracePlot;
ArrowUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowUp.SetDefaultColor(Color.GREEN);
ArrowUp.SetLineWeight(3);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
523 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top