零点课堂 | How To Create TA Indicators on TradingView(7)

Typically, an asset may be considered oversold if it has a score less than or equal to 30, and it could be overbought with a score greater or equal to 70.

If you head to New > RSI Strategy, you can see this for yourself. RSI is generally measured over periods of 14 (i.e., 14 hours or 14 days), but you’re free to tweak that setting to suit your own strategy.

Add this to the chart. You should see a few arrows displayed now (defined by the strategy.entry() function in the code). RsiLE indicates a potential opportunity to long the asset as it may be oversold. RsiSE highlights possible points at which to short the asset when it’s overbought. Note that, as with all indicators, you shouldn’t necessarily rely on these as foolproof evidence that prices will decrease/increase.

Backtesting

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")

Here we’ve defined entry and exit as variables – both are inputs, meaning that we can change them on the chart later. We also set up the price variable, which takes the close for each period. Then, we have some logic in the form of if statements. If the part in brackets is true, then the indented block beneath it will be run. Otherwise, it will be skipped.

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.

声明:本文由 Binance撰写,零点财经收录,观点仅代表作者本人,绝不代表零点财经赞同其观点或证实其描述。

本文由 零点财经 作者:tao 发表,其版权均为 零点财经 所有,文章内容系作者个人观点,不代表 零点财经 对观点赞同或支持。如需转载,请注明文章来源。
分享生成图片
62

发表回复

零点课堂 | How To Create TA Indicators on TradingView(7)

2021-03-26 9:44:25

Typically, an asset may be considered oversold if it has a score less than or equal to 30, and it could be overbought with a score greater or equal to 70.

If you head to New > RSI Strategy, you can see this for yourself. RSI is generally measured over periods of 14 (i.e., 14 hours or 14 days), but you’re free to tweak that setting to suit your own strategy.

Add this to the chart. You should see a few arrows displayed now (defined by the strategy.entry() function in the code). RsiLE indicates a potential opportunity to long the asset as it may be oversold. RsiSE highlights possible points at which to short the asset when it’s overbought. Note that, as with all indicators, you shouldn’t necessarily rely on these as foolproof evidence that prices will decrease/increase.

Backtesting

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")

Here we’ve defined entry and exit as variables – both are inputs, meaning that we can change them on the chart later. We also set up the price variable, which takes the close for each period. Then, we have some logic in the form of if statements. If the part in brackets is true, then the indented block beneath it will be run. Otherwise, it will be skipped.

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.

声明:本文由 Binance撰写,零点财经收录,观点仅代表作者本人,绝不代表零点财经赞同其观点或证实其描述。