How to plot arrows to show my buy and sell data points on TradingView using Pine Editor

Viewed 125

I have a list of datapoints (epoch time, trade price executed) generated from python e.g. buy_orders = [[1626377856, 31004.32], [1626394565, 33041.95], [1626575616, 32218.59]], and I would like to display this data on Trading View as small green arrows. Is there a way to do it? Using Pine Editor I can't seem to find a way to input custom data points.

1 Answers

You can save all timestamps and prices in an array. Then you can compare the time of each bar with array timestamps and whichever falls in between can be plotted there. Example below

//@version=5
indicator(title="Plot Trades",overlay=true)
var timestamps=array.new<int>()
var prices=array.new<float>()
array.push(timestamps,1626377856)
array.push(prices,31004.32)
array.push(timestamps,1626394565)
array.push(prices,33041.95)
array.push(timestamps,1626575616)
array.push(prices,32218.59)
plotIndex=-1
var prvtime=0
for i=0 to array.size(timestamps)-1
    if time/1000>array.get(timestamps,i) and prvtime<array.get(timestamps,i)
        plotIndex:=i
prvtime:=time/1000
plotshape(plotIndex>-1?array.get(prices,plotIndex):na,location=location.absolute,style=shape.xcross,size=size.normal)

enter image description here

Related