There is a way for us to test our custom indicators. Though past performance is no guarantee of future results, backtesting our scripts can give us an idea of how effective they are at picking up signals.
We’ll give an example of a simple script below. We’re going to create a straightforward strategy that enters a long position when the BTC price falls below $11,000 and exits the position when the price exceeds $11,300. We can then see how profitable this strategy would have been historically.
//@version=4
strategy("ToDaMoon", overlay=true)
enter = input(11000)
exit = input(11300)
price = close
if (price <= enter)
strategy.entry("BuyTheDip", strategy.long, comment="BuyTheDip")
if (price >= exit)
strategy.close_all(comment="SellTheNews")
So, if the price is less than or equal to our desired entry, the first expression evaluates as true, and we’ll open a long position. Once the price equals or exceeds the desired exit, the second block will be triggered, closing all open positions.
You can now see the indicators on the chart. You might need to zoom out.
Positions we’ve entered and exited.