Watchlist Time Stamp


Category:
0
0

How can you add a timestamp in your watch list – So you know when the new high was and then you could sort by timestamp.  Thank you

Marked as spam
Posted by (Questions: 2, Answers: 0)
Asked on December 27, 2017 3:38 pm
419 views
0
Private answer

Best solution here is to create a counter and display that value in the watchlist column. In order to get and display the actual time requires we convert that to a string. Once we do so, the sort function fails to work as expected. So we can do this with five lines of code.

First to detect when a new trading day has begun:
def newDay = GetDay() <> GetDay()[1];
Second to track the daily high:
rec dailyHigh = if newDay then high else if high > dailyHigh[1] then high else dailyHigh[1];
Third to detect when a new high has been made:
def newDailyHigh = !newDay and high > dailyHigh[1];
Fourth to count the number of bars since the new high:
rec counter = if newDay then 0 else if newDailyHigh then 1 else if counter[1] > 0 then counter[1] + 1 else 0;
A final line to print the result to the watchlist column:
plot data = counter;

Attached screenshot shows the resulting code in a watchlist.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4117)
Answered on December 27, 2017 6:11 pm