OPEN-SOURCE SCRIPT

Price DEFI Categories against BTC & ETH

Updated
/* Work in progress. The indicator is not finished. *\

The indicator shows the pricing of 3 DEFI categories against 2 possible baselines, BTC and ETH.

To do:
* Make a simple array in the source code to enter and remove new projects to the category. -> Maybe can also make it so that the source code does not have to be altered (projects can be added through input etc.)
* Adjust weightings depending on project data but this is not as important since weightings are being priced in by the market.
* Try to find a way to update input to string instead of booleans. As of currently, I could not seem to use input strings into plot functions because of an error.
* and more. Leave some feedback, that would be highly appreciated!
Release Notes
V1.1

- Updated the title -> "DEFI against Majors" -> D.A.M 1.1
- Added subcategory 'Derivatives'
- Changed transparency (from 20 to 80) of the plot backgrounds
Release Notes
- Changed baseline default value to Ethereum
- Changed boolean input for baseline to choice between strings.
Release Notes
V1.2

- Updated user input. Added boolean (true/false) to give the option to disable certain categories.
- Added comments to the source code so it is easier to read for people that want to mess around with it.
Release Notes
V1.3

* Eco system mode
- Added most of the big DEFI projects from two spaces: Ethereum & Solana. I used the maps that can be found here: (https:// pentacle .ai)
- I chose to leave some out of the equation due to maturity of the chart; I can't really average a chart on 30 day lookback if it has just been listed 14 days capiche?

ETH DEFI SUPPORTED PROJECTS:
Compound, Harvest Finance, Yearn Finance, 0x, Aave, Badger DAO, Alpha Finance, Bancor Network, Curve Finance, Maker, Numeraire

SOL DEFI SUPPORTED PROJECTS:
Bonfida, Serum, Hxro


* Changed user input:
- Added seperators for convencience of sight/vision. Still debating whether I should leave or delete again.
- Added lookback (in days) as a reference point. Minimum value of 1 and maximum value of 30 days. On a lookback of 1 it is quite hard to react but you can spot new trends faster. Choose 30 lookback for a good overview of the last month. I advise to use inbetween 7 and 14 for optimal results.
- Added eco system mode which can be toggled on or off. Default value is off. What do you think? Should the indicator work from categories as a base or ecosystem as a base?
Release Notes
- Added new category 'liquid staking' containing LDO, FFXS, AANKR, RPL & STAFI
- Added ALPACA to the 'lending/borrowing' category
- Added GMX and DDYDX to the 'derivatives' category
- Added gradient coloring for better aesthetics :-)
- Fixed a bug where you could not disable single categories
Release Notes
  • Added a new function: In the newer version of the code, a new function named getSecurityData was added. This function takes two parameters, base and quote, and calculates the percentage change of the security (price) based on the provided parameters. This function is used to abstract away some of the repetitive code in the category calculations.
  • Modified baseline calculation: The baseline calculation was simplified by using the getSecurityData function for ETH against BTC and USD pairs. Previously, the calculation was done manually using security calls, but now it's done more efficiently with the new function.
  • Modified category calculations: The category calculations (e.g., Oracles, DEX, Lending/Borrowing, Derivatives, Liquid Staking) were updated to use the getSecurityData function instead of the previous security calls. This change reduced code duplication and made it easier to add new projects.
  • Refactored color handling in f_c_gradientAdvDec: The function f_c_gradientAdvDec now uses a new function f_colorNew to handle color and transparency calculations. This simplifies the code and improves readability.
  • Removed Eco mode related code: The older version of the code had an "Eco mode" option for showing the ecosystem plots. However, in the newer version, the "Eco mode" related code was removed, and only the ETH DEFI and SOL DEFI ecosystem calculations remain.
  • Updated plot visibility condition: The visibility conditions for each plot have been updated. In the newer version, plots are shown only when the corresponding category is enabled and the category_mode is also true. This allows users to toggle the visibility of individual categories.
  • Updated version number: The version number in the code has been updated to VERSION 1.5.
  • Updated comments and notes: The comments and notes were updated to reflect the changes and provide better clarity and instructions.


Overall, the newer version of the code introduces more abstraction through functions and improves the flexibility and maintainability of the indicator by allowing easier addition of new projects and better control over category visibility.
Release Notes

  • Upgraded to Pine Script v5: The script now takes advantage of the latest Pine Script features.
  • Baseline Security: The previous version only allowed for ETH or BTC as baseline securities. Now you can input any security as a baseline for comparison.
  • User-Selectable Categories: Enhanced user control over which categories to display. You can now toggle individual categories like Oracles, DEX, Lending/Borrowing, Derivatives, and Liquid Staking.
Bitcoin (Cryptocurrency)BTCdecentralizedfinanceDEFIETHEthereum (Cryptocurrency)SOLsolanaTrend Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Also on:

Disclaimer