'Indicator for current price in Pine Script

Is there a way to create an indicator which reflects the current price of a stock in Pine Script? I need this indicator because I need to enter an order before the candle closes (when there is a specific crossover) and the data for back testing is provided bar by bar. I think an indicator can allow me to do this and if not is there another way to tackle this.

I am not an experienced pine scripter and any help will be greatly appreciated:) Thanks,



Solution 1:[1]

The close during the unconfirmed bar represents the current price of the asset.

However, Tradingview's backtesting engine will execute the order only on the next candle. See here why - https://www.tradingview.com/pine-script-docs/en/v4/language/Execution_model.html#execution-model

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1