No idea where to start with this one - I am a trader and would love to copy the date/time to clipboard when the mouse is in a specific position on a chart (eg https://www.tradingview.com/chart/jkEl3KsC/?symbol=SP%3ASPX).
You can see the date/time I want, it's shown by red arrow here:
The thing is, I can't use dev tools in chrome to figure out what div or whatever to capture as the box disappears as soon as you move the crosshair/mouse off the chart.
Also - I can't code something in pinescript (tradingview charting script/code) as there's no function for locating the position of the cursor - it's not supported.
So I use AHK for other stuff and was wondering whether anyone could point me in the correct direction of how I could do this?
Any ideas? Anyone? Fry? Fry? Fry?
Get date/time value from TradingView
Re: Get date/time value from TradingView
My first thought is ctrl+A to select all, then ctrl+c to copy, then parse the results looking for text in that date/time format.
Does ctrl+a include that date in the selection? Are there other date/times that can conflict with extracting that one with the method suggested?
I think I've done sometime like this on tradingview a few years ago, but I'm not at a computer where I can test this now.
Does ctrl+a include that date in the selection? Are there other date/times that can conflict with extracting that one with the method suggested?
I think I've done sometime like this on tradingview a few years ago, but I'm not at a computer where I can test this now.
Re: Get date/time value from TradingView
Unfortunately CTRL+A CTRL+C yields nothing to the clipboard
After a bit more thinking I think I'll have to create a chrome extension that fires on a hotkey rather than use AHK. Unless anyone has any other ideas?
After a bit more thinking I think I'll have to create a chrome extension that fires on a hotkey rather than use AHK. Unless anyone has any other ideas?
Re: Get date/time value from TradingView
You could try UIA.
Re: Get date/time value from TradingView
Thanks for the helpful replies.
Apparently what I'm trying to capture is a canvas element and they're super hard to interrogate.
So at the moment I am looking at Windows Power Automate: screencap/isolate area then OCR using Powershell then go from there, so AHK/UIA can't help me unfortunately.
Apparently what I'm trying to capture is a canvas element and they're super hard to interrogate.
So at the moment I am looking at Windows Power Automate: screencap/isolate area then OCR using Powershell then go from there, so AHK/UIA can't help me unfortunately.
Re: Get date/time value from TradingView
Hi,
Did you manage to do this in the end?
If you select the Data Window on the right side that shows the date and time, and all the indicators' values, and then press Ctrl-A -> Ctrl-C, then it does go onto the clipboard.
I want to do this date-time copying thing too. I just haven't decided how much I want it.
Re: Get date/time value from TradingView
Unfortunately I did not solve it!
I just started another batch of back testing so again this would be useful. I'd rather just a single key combo to capture and convert date/time. I still think windows power automate is the only way. But bizarre there's no way to capture the raw text on the screen
I just started another batch of back testing so again this would be useful. I'd rather just a single key combo to capture and convert date/time. I still think windows power automate is the only way. But bizarre there's no way to capture the raw text on the screen
Re: Get date/time value from TradingView
WAIT A MINUTE
I did not know about this - maybe that part of the screen can be scraped?!? You may be onto something!
-
- Posts: 176
- Joined: 12 Nov 2022, 15:47
Re: Get date/time value from TradingView
I recently tried something similar to this using FindText OCR. The concept seemed the same, but when I actually tried to implement it in TradingView I kept running into brick walls. They're pretty sophisticated and I'm sure they don't like any type of automation being done on their site. For example, in the script you'll see the need for different versions of the same number or month. Also the spacing was a challenge so I took care of that at the end with some formatting. I'm using Brave browser in dark mode. Working in Chrome in dark mode as well. If FindText is unable to detect something in the date/time it will show an asterisk (*) for the missing data. Whatever is missing, just take another captured version of it and add it to the list of text images.
Code: Select all
#requires autohotkey v2
#include <FindText>
q::
{
DateTimeText:="
(
|<'>*114$4.y8bs
|<'>*123$3.wYw
|<:>*126$3.0z0U
|<:>*143$2.zkwDy
|<:>*143$2.z3ks
|<1>*168$3.oKqqo
|<2>*150$5.2nbAtaA4
|<2>*161$4.1ivBYkU
|<2>*147$4.1Cn94kU
|<2>*158$4.7AmNBkU
|<2>*140$5.0HbCNXA4
|<3>*144$5.2nb8wskA
|<3>*138$4.1AmQt0U
|<3>*158$4.7AmQv1U
|<4>*139$6.ttlV990ttU
|<4>*161$4.m89Uvc
|<4>*162$4.vAca3iU
|<5>*162$4.1r1itUU
|<5>*144$4.1r1Al1U
|<6>*160$5.nAsGCQGA
|<6>*160$4.Wr1aNUU
|<7>*146$5.1nCQnaQw
|<7>*143$4.3AaFArU
|<7>*141$5.1naAtbCQ
|<8>*189$5.WEoMiQuA
|<8>*170$4.1a06NUU
|<9>*166$5.WNlcQlaQ
|<9>*156$4.1aMCm8
|<9>*145$5.2FV0Ql6Q
|<0>*143$6.VYAAAAA4VU
|<0>*165$5.UFnbCAGA
|<Mon>*143$22.rDzzAzzsnzzWAA68aH88NAUVYkm6H393AU
|<Tue>*142$19.0DzwzzyTzz9a7YkNmM0tA7wW3yMAA
|<Wed>*143$23.CtztAnzmFDzYWMM80a6MW0Al4yNbAwniQA4
|<Thu>*141$19.07ztnzwtzyQ4nCMNbAAna6Nn1AtY4
|<Fri>*139$13.0y7z3zts04MSQDC7b3nY
|<Sat>*152$16.D32DYyEHs9BVYkk8U
|<Sun>*151$18.DA0XAAtAAsAAN8A30AU
|<Jan>*150$17.t31nmPY4r39W4H1UaU
|<Feb>*155$18.TV13AAS0CSTCTDATV1U
|<Feb>*148$18.DVU1AaD06DDaDDaDUUU
|<Mar>*161$16.AkkFt464HGFANCo4U
|<Mar>*166$18.4MM4TNFMPF3PP2/P8/U
|<Apr>*163$15.VUpgmAaE4mS6Hk6U
|<Apr>*160$15.X1V9Y9CU9oQAbkAU
|<May>*161$19.Akb2D9464WOHJANXqUvU
|<May>*148$20.4MH17mE4UY13AKEX5Y0nU
|<May>*160$19.4MH2DdYK6m8P1g8mqENU
|<Jun>*158$18.tAUtAgtAgtAg9AgXUgU
|<Jun>*151$18.sN0sNAsNAsNA89A31AU
|<Jul>*145$14.tACH3YktA2H0A2U
|<Jul>*158$14.sNC6HVYsN6qEA6U
|<Aug>*164$18.VaEZa6ga60aEC6LSEEU
|<Aug>*180$18.fik9igRig1ilQgjyUUU
|<Sep>*164$17.D30Amn05r7vYbq3VVU
|<Sep>*147$17.D114mPU0r3ta3n1UUU
|<Oct>*147$17.SEUwAZsT/kyH9YksMU
|<Nov>*158$17.4kaVABWt35m79aE
|<Nov>*166$18.6kb2aK8bGAbMCaNU
|<Dec>*150$18.CEsC6HC07A7b8bn1kkU
|<Dec>*151$18.QkkQ66Q07QDbNba3kkU
)"
Text:="|<tv_upper_left_time_region>363A45-101010$7.zzzzzzzzk"
if (ok:=FindText(&X:="wait", &Y:=-1, 49, 936, 1809, 973, 0, 0, Text,, 0))
x1 := ok[1].1
y1 := ok[1].2
x2 := x1+131
y2 := y1+21
if (ok := FindText(&X, &Y, x1, y1, x2, y2, .1, .1, DateTimeText))
Result := FindText().OCR(ok)
inputDateTime:=result.text
formatDateTime(dateTime) {
if (RegExMatch(dateTime, "\d{2}:\d{2}$")) {
formattedDateTime := SubStr(dateTime, 1, 3) . " " . SubStr(dateTime, 4, 2) . " " . SubStr(dateTime, 6, 3) . " " . SubStr(dateTime, 9, 3) . " " . SubStr(dateTime, 12)
} else {
formattedDateTime := SubStr(dateTime, 1, 3) . " " . SubStr(dateTime, 4, 2) . " " . SubStr(dateTime, 6, 3) . " " . SubStr(dateTime, 9)
}
return formattedDateTime
}
formattedDateTime := formatDateTime(inputDateTime)
a_clipboard:= formattedDateTime
MsgBox "Formatted DateTime: " formattedDateTime
}
Last edited by rockitdontstopit on 20 Jul 2024, 18:15, edited 3 times in total.
It was the best of times, it was the worst of times...
Re: Get date/time value from TradingView
Yes, exactly. That panel on the right, where the Object Tree and Data Windows is. I just tried it, it does copy the things from the Data Window there, including the date and time at the cursor’s position. It does not copy the price level though, only the data of the candle (open, high, low, close). But the price level can be copied via TradingView's right-click menu.
I just had quick look at MS Power Automate. I did not know about this, and it looks cool! I’m not sure if it could to do the job in itself, but could be useful for further processing the data.
A different approach I have been thinking of for doing backtests is putting drawings or markers on the chart at the points of interest, and then extracting the coordinates (datetime and price level) of those drawings. E.g. you could create an indicator that accesses those drawings, and extract the data through that indicator. Unfortunately, this can’t be done in TradingView as far as I know since you can’t access drawing objects from Pine Script. You can download indicator data, but indicators can’t access drawing objects. But you may be able to do it in other charting softwares. E.g. SierraChart.
Who is online
Users browsing this forum: DavidP and 79 guests