Changing background color to show new Day High – 2-Day High


Category:
0
0

What I want to know how to do is, “create a custom watchlist coulomb, so that the background color changes when the current price creates a new daily high, and changes to a different color when the last price creates a new 2-day high”.

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on April 14, 2017 12:39 pm
378 views
0
Private answer

Finally getting around to working this out. This sounds like a pretty simple request but the code requires several complex elements to get the details straight. I added a special touch just to see if I could do it. Which is to have the text in the custom column change to display which condition is present. Here is the code, attached screenshot shows how it looks.

input price = close;
def newDay = GetDay() != GetDay()[1];
def currentDay = GetDay() == GetLastDay();
rec dailyHigh = if newDay then high else if high > dailyHigh[1] then high else dailyHigh[1];
rec priorDailyHigh = if newDay and currentDay then dailyHigh[1] else priorDailyHigh[1];
def currentDailyHigh = if newDay then high else dailyHigh[1];
def newDailyHigh = price < priorDailyHigh and price > currentDailyHigh;
def newTwoDayHigh = if currentDay then price > priorDailyHigh and price > currentDailyHigh else 0;
def text = {default "Daily High", "Two Day High", "n/a"};
text = if newDailyHigh then text."Daily High" else if newTwoDayHigh then text."Two Day High" else text."n/a";
AddLabel(yes, if newDailyHigh == 1 then "DailyHigh" else if newTwoDayHigh then "2DayHigh" else "n/a", Color.BLACK);
AssignBackgroundColor(if newDailyHigh then Color.Blue else if newTwoDayHigh then Color.CYAN else Color.BLACK);

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on April 17, 2017 9:10 am
0
Hello Pete, The scan you made for me a while back is working great. I often check into the forums and noticed this one. It seems the AddLabel command is not valid. Is there a workaround? Thanks https://www.dropbox.com/s/7bl56euijz0r31f/Screenshot%202018-07-07%2019.13.43.png?dl=0
( at July 7, 2018 4:12 pm)
0

I just copy and pasted this code and tested it. Working fine on my end.

( at July 7, 2018 4:16 pm)
0
Private answer

I just copied & pasted the code into one of the 19 custom indicators. I then placed that indicator into a watchlist. No matter what I do so far, all that comes up is “everything is showing black; no new daily high, and no new 2-day high”. Can you help me find what I’m doing wrong, or why this isn’t working. Thanks.

Marked as spam
Posted by (Questions: 0, Answers: 1)
Answered on May 4, 2017 12:42 pm
0

Make sure you have set the aggregation period to intraday. in the example I demonstrated in the screenshot the aggregation period was set to 15 min and did not include extended hours data.

( at May 4, 2017 2:53 pm)
0
Private answer

Hi Pete thanks for your codes it has been very useful.

I want to know if you can create a code to add background color on the w/l that indicates new high of intraday from previous lows intraday (1min chart) for spotting a shift in momentum heading towards new high of day from opening bell dips.

Picture included marks previous lows followed by new highs

I’m going to donate If such a code exists and works as expected.  Thanks in advance.

 

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 1)
Answered on May 11, 2017 9:05 am
0

This will need to be submitted as a new question to assist other visitors in searching for and finding your post and it’s solution. When you post this, be sure to explain exactly how you want the lows to be included in the logic. It is not apparent from your description or the screenshot. To me, it looks like you simply want to track each time a new intraday high is achieved. Which is something I’m pretty sure we’ve already covered elsewhere.

( at May 11, 2017 10:36 am)