0
votes

I'm still a newbie at pine script, I have an indicator in version 5, which places a buy arrow marker at a bar that meets my criteria to buy at that point. I then have some criteria that place a sell arrow at a bar that meets those. I would like to keep track of the buy bar id, so I could add a condition to my sell criteria if the current price drops below the buy price. I am not using Trading View to trade, just to give me these marks. A follow up question: how could I get the exact price and record it, at which my buy bar generated the buy signal, as obviously it may have been a long bar, and at some point in it my conditions for buy signal were met. In this way I could just use the drop in price from my buy signal as one of the conditions to sell.

Hope this makes sense, and thank you in advance for any help

1
Please share your code so we can help you. - vitruvius

1 Answers

0
votes

To track the entry price you can use the following built in:

strategy.position_avg_price

which will return the price that the current order filled at.

Cheers and best of luck