Author

Topic: [GUIDE] create your TA Indicators {TradingView} (Read 60 times)

legendary
Activity: 1596
Merit: 1288
September 25, 2021, 09:12:58 AM
#1
Table of contents

      1. What is TradingView?
      2. How Does TradingView Work?
      3. What is Pine Script?
      4. The Pine Editor
      5. “study” vs “strategy”
      6. Plotting (RSI) indicator

What is TradingView?

TradingView is cloud-based go-to charting and social-networking platform for both beginner and advanced active investment traders for tracking movements in the Forex, traditional stock markets and cryptocurrency.

TradingView have some features:

  • HTML5 Charts
  • Server-Side Alerts
  • Trading
  • Social Community of Active Traders
  • publish trading ideas within its social network


How Does TradingView Work?

When you log-in for a free account, you'll have access to the TradingView community and basic features.
You get one chart per layout and one alert with three indicators to use on one device.

we will work on free account and when you need to add more charts you can buy Pro/Pro+ and Premium account.


What is Pine Script?


Pine Script is a scripting language that can be used to control and edit your TradingView charts.It allows users to create custom indicators and run them on our servers.
each script uses computational resources in the cloud, some limits must be imposed in order to share these resources between users.

we will use BTCUSDT trading pair. you can find it  https://www.tradingview.com/symbols/BTCUSDT/

click on full-featured chart button and down for Pine Editor



The Pine Editor

we will write some codes and then click on click on Add to Chart to see our annotations.


study("First Script")  just setting up our annotation which have a new name (First Script in our case)
plot() gives us a line chart
overlay=true adds the indicator to the existing chart
now you can use some of TA indicators as moving averages, simple moving average (SMA), exponential moving average (EMA)


Code:
plotcandle(sma(open, 7))
EMA = (Close - Previous Day’s EMA) * Multiplier - Previous Day’s EMA
Multiplier = 2 / (Length of EMA + 1)


Example of a Pine script
Code:
//@version=4
study("MACD")
fast = 12, slow = 26
fastMA = ema(close, fast)
slowMA = ema(close, slow)
macd = fastMA - slowMA
signal = sma(macd, 9)
plot(macd, color=color.blue)
plot(signal, color=color.orange)

Source: https://www.tradingview.com/pine-script-docs/en/v4/Quickstart_guide.html


“study” vs “strategy”

Pine strategies: used to run backtests and normal script calculations, they also contain strategy.*() calls to send buy and sell orders. see https://www.tradingview.com/pine-script-docs/en/v4/essential/Strategies.html

Pine studies: cannot be used in backtesting. Because they do not make use of the broker emulator, they use less resources and will run faster.

Code:
study(title="New Script", overlay=true)
emaLength = input(title="EMA Length", type=input.integer, defval=20, minval=0)
emaVal = ema(close, emaLength)


Plotting (RSI) indicator

Click on New > RSI Strategy


Code:
//@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")


you can change entry and exit variables

this the basic codes and you can change it or build your own code



Sources

Code:
https://investorjunkie.com/reviews/tradingview/
https://www.tradingview.com/pine-script-docs/en/v4/Introduction.html
https://academy.binance.com/en/articles/how-to-create-ta-indicators-on-tradingview
Jump to: