Here is a draft article on calculating Ethereum directional movement indicators using the Binance DMI (Directional Movement Indicator) API:
Calculating Ethereum directional movement indicators
As an investor, understanding trends and patterns in your cryptocurrency portfolio is very important. One powerful tool in this arsenal is the Directional Movement Indicator (DMI), which helps determine the direction of price movement. In this article, we will explore how to calculate DMI using the Binance API.
Understanding the 288 value
To create a 5-minute trading view for Ethereum on Binance, you need to use the 288 values: High, Open, Low, and Close. Here is a brief overview of each value:
- High
: The highest price level reached during the bar.
- Open: The lowest price level reached during the bar.
- Low: The lowest price level reached during the bar.
- Close
: The highest price level reached during the bar.
Calculating BSM (Balanced Order Signal)
Before diving into the DMI, let’s start with the Moving Average (BSM). The 12-period average of the high and low can be used to calculate the BSM. Thus:
- Retrieve the high and low of each bar using the Binance API.
- Calculate the BSM by averaging the high and low over a given period of time (e.g. 12 bars).
- Use the BSM as a filter to select only the highs, lows, and closes.
Calculating Aaron
Next, we will calculate the Average True Range (ATR) using the Alligator indicators in Alpha Vantage. This helps us determine the volatility of Ethereum’s price movements.
- Retrieve all 288 values for each bar.
- Calculate the Average True Range by taking the average of the High-Low ranges.
- Use the ATR value to filter out high highs, lows, and closes with high true range (i.e., high volatility).
Calculating the BSI (Balance Signal Indicator)
Now, let’s create a Balance Signal Indicator (BSI) by calculating the high-low ratio.
- Retrieve all 288 values for each bar.
- Calculate the high-low ratio for a given time period (e.g., 12 bars).
- Use the BSI as an indicator to signal potential buy or sell opportunities based on the high, high, low, and high close ratio.
Calculating the RSI
Finally, the Relative Strength Index (RSI) is calculated using the high and low values.
- Retrieve all 288 values for each bar.
- Calculate the Relative Strength Index by taking the average of the high-low price ratio over a given period of time (e.g. 14 days).
- Use the RSI as an additional indicator to signal potential buy or sell opportunities based on the high-low-low ratio.
Putting it all together
Create a trading view using the Binance API to retrieve the calculated values for each bar:
“javascript
const axios = require('axios');
async.function calculateDMI() {
// Retrieve all 288 values for each bar
const apiResponse = await axios.get(
if (apiResponse.status !== 200) return;
const data = apiResponse.data;
const highValues = data.highestPrices.map((value, index) => ({ value }));
const openValues = data.openPrices.map((value, index) => ({ value }));
const lowValues = data.lowestPrices.map((value, index) => ({ value }));
const closeValues = data.closePrices.map((value, index) => ({ value }));
// Calculate BSM
const bsmValues = highValues.reduce((a, b) => a + b.value, 0) / bsmValues.length;
console.log(bsmValues);
// Calculate Aro
const atrValues = closeValues.map((value, index) => {
if (index % 10 === 9 && value < lowValues[index - 1].value) return 100;
else if (index % 10 !== 0 && value > highValues[index – 1].value) return 50;
else if (index % 10 !== 9 && value < highValues[index - 1].