关于TradingView PineScript及嵌入图表叠加自定义订单数据的技术咨询
Question 1: Overlay Custom Order Data on TradingView Charts with PineScript
Absolutely, this is totally achievable with PineScript. The core steps involve converting your millisecond timestamps to TradingView's Unix-second format, then plotting your buy/sell points using visible markers.
Here's a working code example built specifically for your order data:
//@version=5 indicator("Custom Order History Overlay", overlay=true) // Store your order data as an array of tuples (price, order side, timestamp in ms) orderData = array.new_tuple( tuple.new(0.00002609, "buy", 1524722057851), tuple.new(0.0000261, "buy", 1524722057851) ) // Loop through each order and plot markers on matching bars for i = 0 to array.size(orderData) - 1 [price, side, ts_ms] = array.get(orderData, i) // Convert millisecond timestamp to seconds (TradingView uses Unix seconds) orderTimestamp = ts_ms / 1000 // Match the order time to the current bar's timestamp if time == orderTimestamp // Plot a green upward label for buy orders; adjust for sells if needed plotshape(series=price, title="Buy Order", location=location.belowbar, style=shape.labelup, color=color.new(color.green, 0), text="BUY", textcolor=color.white, size=size.small)
A quick breakdown of how this works:
- We group your order details into tuples so related data stays organized.
- Convert your millisecond timestamp to seconds since TradingView's
timevariable uses Unix-second formatting. - Use
plotshapeto draw clear, labeled markers on the exact bar where each order was placed. You can tweak the shape, color, and position to match your preferred visual style.
Question 2: Overlay Custom Data on Embedded TradingView Widgets
Yes, you can do this too—here are the two most straightforward approaches depending on your needs:
Option 1: Embed Your Custom PineScript Indicator
This is perfect for static historical data like your example:
- Save the PineScript code from Question 1 to your TradingView account (you can publish it as private or public, depending on who you want to access it).
- When configuring your embedded widget, use the "Add Indicator" option to select your custom order overlay script. The widget will load the indicator along with your order markers directly onto the embedded chart.
Option 2: Dynamic Data Updates (If You Need to Refresh Orders Later)
If your order data changes frequently, you’d need to use TradingView’s Custom Data Feed API to inject updated or real-time data into the widget. For static historical orders though, Option 1 is simpler and requires no additional API setup.
Just keep in mind: if your PineScript indicator is set to private, only users with access to your TradingView account (or those you share the widget link with) will see the custom order markers.
内容的提问来源于stack exchange,提问作者seregkka




