Bar color not based on daily change
Author: cmm2391
Creation Date: 2/9/2020 3:03 PM
profile picture

cmm2391

#1
Hi,

Just did some searching for past threads on this subject but didn't have any luck. Surely it was covered somewhere but I couldn't find.

I wrote code that recognizes CANSLIM distribution days such that they're marked on charts and I can look at them in-depth. In looking at some distribution days in 2007, I noticed that for days where price opens up, but closes down from the open, BUT higher than the close the day before, the candle is colored red for a down day. The open-close is negative indicating the actual day was down, but the close today - close yesterday is positive, indicating a day up.

10/26/2007 was up 1.94% from the previous day, but closed down 2 points from the open, and is marked as a down day via color.

Just curious if there is any preference I can change in order to have this colored as an up day rather than a down day?

Thanks!
profile picture

Eugene

#2
Hi,

What you're looking for is this:

OHLC colors: Open/Close vs Close/Close

P.S. The topic title "Bar color based on change from last week rather than daily change" was rather misleading as your question has nothing to do with weekly scale. Renamed.
profile picture

cmm2391

#3
Thanks Eugene!
profile picture

Eugene

#4
My pleasure.
profile picture

cmm2391

#5
Eugene,

Quick follow-up question. I was able to just write some code to crunch close prices and set the bar color appropriately. However, this just sets bars to solid red or solid green. I'm curious if there's a way to set hollow candlesticks such that:
- close higher than open and higher than close yesterday: solid green
- close lower than open but higher than close yesterday: hollow green
- close lower than open and lower than close yesterday: solid red
- close higher than open but lower than close yesterday: hollow red

Did some more searching on keywords like fill, hollow, etc. and didn't see anything pop up in the thread search.

Thanks again.
profile picture

Eugene

#6
That sounds like the job for a ChartStyle which is a full-fledged solution that requires development. As the poor man's version you could imitate it with DrawPolygon() like this:

CODE:
Please log in to see this code.
profile picture

vk

#7
@cmm2391
I like the way you are thinking. There is an extension that lets you do something really interesting, it changes the weeks starting and ending day. Some 30 years ago I developed a FOREX system for a client that was using it. The week started on Tuesday and ended on Monday. This little tweak did wonders on a weekly system. Since then I have never seen anyone using this method.

VK
profile picture

Eugene

#8
QUOTE:
There is an extension that lets you do something really interesting, it changes the weeks starting and ending day.

That's Robert's EOD Scaling Provider.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).