The Tenkan-sen is a component of the Ichimoku Kinko Hyo, a versatile indicator in technical analysis that provides insights into the direction, momentum, and potential areas of support and resistance in the market. The Tenkan-sen is also known as the Conversion Line.
It is calculated as the average of the highest high and the lowest low over a specific period, typically the last 9 periods, but can be adjusted depending on the trader's preference and the timeframe being analyzed.
The formula for calculating the Tenkan-sen is straightforward:
Tenkan−sen=Highest High+Lowest Low2Tenkan-sen = \frac{Highest \: High + Lowest \: Low}{2}
Where:
- Highest HighHighest \: High is the highest high price over the specified period.
- Lowest LowLowest \: Low is the lowest low price over the specified period.
Here's a Python function to calculate the Tenkan-sen:
def tenkan_sen(high_prices, low_prices):
tenkan_sen_values = []
for i in range(len(high_prices)):
highest_high = max(high_prices[max(0, i - 8):i + 1])
lowest_low = min(low_prices[max(0, i - 8):i + 1])
tenkan_sen_values.append((highest_high + lowest_low) / 2)
return tenkan_sen_values
In this function:
high_prices
is a list of highest high prices over the specified period.low_prices
is a list of lowest low prices over the specified period.
You can then use the tenkan_sen
function to calculate the Tenkan-sen for a given dataset of high and low prices over a specified period.