[ Beginner 1 ] Best Algo Trading Tutorial – Buffett Index​

Yaonology Algorithmic Trading
Share on facebook
Share on twitter
Share on linkedin
Share on email
Share on reddit

Algo Trading can be much easier than you think. Below all the coding is using Pine script and based on the Tradingview platform. The article will first display the full version of the strategy content and then explain it more specifically.

Background Introduction

The Buffett indicator is named after Mr. Warren Buffett, the CEO of Berkshire Hathaway. It is the entire stock market capitalization divided by gross domestic product (GDP). Warren Buffett argues that if the number is too high, it means companies aren’t producing enough to be worth their valuations on the stock market. 

The indicator can help investors assess the level of the overall market situation, especially in a bull market. When stocks overall are trading significantly below GDP, it indicates a buy signal. On the other hand, when stocks are collectively trading above GDP, it is a sell signal. Moreover, when stocks cross above GDP, it tends to be a sign that a correction is possible.

Below is the full version code:

//@version = 4



study("Yaonology Buffett Index", overlay=false)


SPX = security('TVC:SPX', "D", close)

GDP = security('FRED:GDP', "D", close)

B_index = SPX/GDP



plot(B_index, color = color.blue)

Step One: Initialization

//@version = 4

study(“Yaonology Buffett Index Tutorial“, overlay=false)

“study” is different from “strategy”. It contains calculations and may plot information on charts, but cannot be used in backtesting. 

Yaonology  defines the name as “Yaonology BUffet Index” ;

overlay: Yes – True; No – False

Step Two: Input

Part 1:

SPX = security(‘TVC:SPX’, “D”, close)

GDP = security(‘FRED:GDP’, “D”, close)

security- the function that enables to extract data from the symbol

“D”-we set the interval as each day 

“close”- we use the closing price

Part 2: Calculate the index

B_index = SPX/GDP

Step Three: Plot

plot(B_index, color = color.blue)-color for the index is set as blue

Complete Version

[ Beginner 1 ] Best Algo Trading Tutorial - Buffett Index​
Source: Yaonology

Yaonology.com

SP500 Algo Trading Strategy

Bitcoin Algo Trading Strategy

#Algorithmtradingstrategy  #Algorithm #codingtutorial #buffettindicator #buffett #economicindex

wpChatIcon

Start Free Trial

20% OFF

CODE: FOURTH20

Valid through: 7/9/2020

This website uses cookies to ensure you get the best experience on our website.

Read Privacy Policy