How To Calculate Fibonacci Extensions using R?

by connie.heaney , in category: Technical Analysis , 5 months ago

How To Calculate Fibonacci Extensions using R?

Facebook Twitter LinkedIn Whatsapp

2 answers

Member

by stuart , 5 months ago

@connie.heaney 

To calculate Fibonacci extensions using R, you can use the following formula:


Fibonacci Extension = (Previous Swing High - Previous Swing Low) * Fibonacci Level + Previous Swing High


Here is a step-by-step guide on how to calculate Fibonacci extensions using R:

  1. First, you need to identify the previous swing high and previous swing low in the price data. These are the highest and lowest points in the price movement before the current price.
  2. Next, calculate the difference between the previous swing high and previous swing low. This will give you the price range of the previous swing.
  3. Determine the Fibonacci level you want to use for the extension. Common Fibonacci levels used for extensions are 0.618, 1.0, 1.272, 1.618, etc.
  4. Multiply the Fibonacci level by the price range of the previous swing.
  5. Add the result to the previous swing high to get the Fibonacci extension level.


Here is an example code in R to calculate Fibonacci extensions:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Define the previous swing high and low
previous_swing_high <- 100
previous_swing_low <- 80

# Calculate the price range of the previous swing
price_range <- previous_swing_high - previous_swing_low

# Define the Fibonacci level
fibonacci_level <- 0.618

# Calculate the Fibonacci extension
fibonacci_extension <- price_range * fibonacci_level + previous_swing_high

# Print the Fibonacci extension
print(fibonacci_extension)


In this example, the Fibonacci extension is calculated using a previous swing high of 100, a previous swing low of 80, and a Fibonacci level of 0.618. The Fibonacci extension is then printed out.


You can modify the code to input your own values for the previous swing high, previous swing low, and Fibonacci level to calculate Fibonacci extensions for your specific data.

Member

by coleman , 2 months ago

@connie.heaney 

Here is an example code snippet to calculate Fibonacci extensions in R:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Define the previous swing high and low
previous_swing_high <- 100
previous_swing_low <- 80

# Calculate the price range of the previous swing
price_range <- previous_swing_high - previous_swing_low

# Define the Fibonacci level
fibonacci_level <- 0.618

# Calculate the Fibonacci extension
fibonacci_extension <- price_range * fibonacci_level + previous_swing_high

# Print the Fibonacci extension
print(paste("Fibonacci Extension at", fibonacci_level, "level is:", fibonacci_extension))


You can modify the previous_swing_high, previous_swing_low, and fibonacci_level variables with your own values in the code above to calculate Fibonacci extensions specific to your price data. Just replace the values of previous_swing_high, previous_swing_low, and fibonacci_level with the values you want to use, and run the code to get the Fibonacci extension level calculated based on the formula provided.