when I click on buy/sell button I need to show an arrow on the on last candle when the button was clicked
here is the view of my chart

I need something like this but in amcharts version 5

I have tried to implement the following but it is giving errors as chart is not defined or createChild is not a function etc it is not working at all.
function addArrow() {
var candlestick = mainPane.plotContainer.dataItems.getIndex(0);
var arrow = candlestick.createChild(am5xy.Line);
arrow.stroke = am5.color("red");
arrow.strokeOpacity = 1;
arrow.strokeWidth = 2;
arrow.path = "M0,0 L10,10 M0,10 L10,0"; // Adjust the arrow shape as needed
arrow.x = 100; // Adjust the X-coordinate of the arrow
arrow.y = 100; // Adjust the Y-coordinate of the arrow
}