# Fibonacci Moving Average

#### SleepyZ

##### Moderator - Expert
VIP
Fibonacci Moving Average
Code:
``````#Fibonacci Moving Average
script fib{
input d     = close;
def ema2    = ExpAverage(d, 2);
def ema3    = ExpAverage(d, 3);
def ema5    = ExpAverage(d, 5);
def ema8    = ExpAverage(d, 8);
def ema13   = ExpAverage(d, 13);
def ema21   = ExpAverage(d, 21);
def ema34   = ExpAverage(d, 34);
def ema55   = ExpAverage(d, 55);
def ema89   = ExpAverage(d, 89);
def ema144  = ExpAverage(d, 144);
def ema233  = ExpAverage(d, 233);
def ema377  = ExpAverage(d, 377);
def ema610  = ExpAverage(d, 610);
def ema987  = ExpAverage(d, 987);
def ema1597 = ExpAverage(d, 1597);
def sumema  = ema2 + ema3 + ema5 + ema8 + ema13 + ema21 + ema34 + ema55 + ema89 + ema144 + ema233 + ema377 + ema610 + ema987 + ema1597;
plot fibavg = sumema / 15;
}
plot fibma_close = fib(close);
plot fibma_high  = fib(high);
plot fibma_low   = fib(low);``````

Last edited by a moderator:
Was wondering if anyone would be interested in looking into this?...Thanks in advance!

Creating a Fibonacci Moving Average to Assist in Trend Direction.

FMA: "This indicator will do the same job as a normal moving average but with improved reactivity and faster response to market moves as well as a better support and resistance level."

Here is the link to the article:

⚠ edited by moderator. Shared media blocked.
**Images, Videos, Media content from commercial websites can NOT be shared on this forum. The Internet is not in and of itself public domain. Most commercial material is protected by copyright.

Last edited by a moderator:
Thanks @SleepyZ appreciate your help and input, I'll check it out and get back to you!

It looks pretty darn good on the daily chart...any feedback or input is greatly appreciated!!

Last edited:
Interesting idea...I like how the FibMAs creates a "zone" of support, as opposed to a traditional MA providing just a "line"...

Thanks to @Joseph Patrick 18 for the documentation and @SleepyZ for the initial coding...Just added a little more color to the end result...

Code:
``````#Fibonacci Moving Average
script fib{
input d     = close;
def ema2    = ExpAverage(d, 2);
def ema3    = ExpAverage(d, 3);
def ema5    = ExpAverage(d, 5);
def ema8    = ExpAverage(d, 8);
def ema13   = ExpAverage(d, 13);
def ema21   = ExpAverage(d, 21);
def ema34   = ExpAverage(d, 34);
def ema55   = ExpAverage(d, 55);
def ema89   = ExpAverage(d, 89);
def ema144  = ExpAverage(d, 144);
def ema233  = ExpAverage(d, 233);
def ema377  = ExpAverage(d, 377);
def ema610  = ExpAverage(d, 610);
def ema987  = ExpAverage(d, 987);
def ema1597 = ExpAverage(d, 1597);
def sumema  = ema2 + ema3 + ema5 + ema8 + ema13 + ema21 + ema34 + ema55 + ema89 + ema144 + ema233 + ema377 + ema610 + ema987 + ema1597;
plot fibavg = sumema / 15;
fibavg.hide();
}

plot fibma_close = fib(close);
fibma_close.hide();

plot fibma_high  = fib(high);
fibma_high.SetDefaultColor(Color.GREEN);
fibma_high.SetLineWeight(3);

plot fibma_low   = fib(low);
fibma_low.SetDefaultColor(Color.RED);
fibma_low.SetLineWeight(3);

Interesting idea...I like how the FibMAs creates a "zone" of support, as opposed to a traditional MA providing just a "line"...

Thanks to @Joseph Patrick 18 for the documentation and @SleepyZ for the initial coding...Just added a little more color to the end result...

Code:
``````#Fibonacci Moving Average
script fib{
input d     = close;
def ema2    = ExpAverage(d, 2);
def ema3    = ExpAverage(d, 3);
def ema5    = ExpAverage(d, 5);
def ema8    = ExpAverage(d, 8);
def ema13   = ExpAverage(d, 13);
def ema21   = ExpAverage(d, 21);
def ema34   = ExpAverage(d, 34);
def ema55   = ExpAverage(d, 55);
def ema89   = ExpAverage(d, 89);
def ema144  = ExpAverage(d, 144);
def ema233  = ExpAverage(d, 233);
def ema377  = ExpAverage(d, 377);
def ema610  = ExpAverage(d, 610);
def ema987  = ExpAverage(d, 987);
def ema1597 = ExpAverage(d, 1597);
def sumema  = ema2 + ema3 + ema5 + ema8 + ema13 + ema21 + ema34 + ema55 + ema89 + ema144 + ema233 + ema377 + ema610 + ema987 + ema1597;
plot fibavg = sumema / 15;
fibavg.hide();
}

plot fibma_close = fib(close);
fibma_close.hide();

plot fibma_high  = fib(high);
fibma_high.SetDefaultColor(Color.GREEN);
fibma_high.SetLineWeight(3);

plot fibma_low   = fib(low);
fibma_low.SetDefaultColor(Color.RED);
fibma_low.SetLineWeight(3);

@netarchitech SWEET Thanks for your input...

Pretty sweet move to the upside today on BYND up over 4 dollars today so far...

Quick scan if anyone needs..(Pic 1) I have it set to SP 100 no other criteria and once it starts to bounce off FMA cloud and I used it in conjunction with @Chuck Balanced BB Breakout (Pic 2)

Hey @Joseph Patrick 18 @SleepyZ and @netarchitech. I was looking at this indicator and came across the MyEMA example for script(). It says,
This code defines the MyEma script where the first EMA value is calculated as SMA in contrast to the ExpAverage function whose first value is assigned the closing price. The main section of the code creates an oscillator based on the MyEMA difference for different lengths.

I left out the oscillator and I added it to your indicator and compared both:
• Blue - w/o MyEMA
• Pink - w/ MyEMA
I'm still new to thinkscript and scripting in general so be sure to review but there does seem to be a noticeable difference.

Code:
``````script MyEMA {
input data = close;
input length = 15;
def EMA = CompoundValue(1, 2 / (length + 1) * data + (length - 1) / (length + 1) * EMA[1], Average(data, length));
plot MyEma = EMA;
}

script fib{
input d     = close;
def ema2    = MyEMA(d, 2);
def ema3    = MyEMA(d, 3);
def ema5    = MyEMA(d, 5);
def ema8    = MyEMA(d, 8);
def ema13   = MyEMA(d, 13);
def ema21   = MyEMA(d, 21);
def ema34   = MyEMA(d, 34);
def ema55   = MyEMA(d, 55);
def ema89   = MyEMA(d, 89);
def ema144  = MyEMA(d, 144);
def ema233  = MyEMA(d, 233);
def ema377  = MyEMA(d, 377);
def ema610  = MyEMA(d, 610);
def ema987  = MyEMA(d, 987);
def ema1597 = MyEMA(d, 1597);
def sumema  = ema2 + ema3 + ema5 + ema8 + ema13 + ema21 + ema34 + ema55 + ema89 + ema144 + ema233 + ema377 + ema610 + ema987 + ema1597;
plot fibavg = sumema / 15;
fibavg.hide();
}

plot fibma_close = fib(close);``````

Hey @Joseph Patrick 18 @SleepyZ and @netarchitech. I was looking at this indicator and came across the MyEMA example for script(). It says,

I left out the oscillator and I added it to your indicator and compared both:
• Blue - w/o MyEMA
• Pink - w/ MyEMA
I'm still new to thinkscript and scripting in general so be sure to review but there does seem to be a noticeable difference.

Code:
``````script MyEMA {
input data = close;
input length = 15;
def EMA = CompoundValue(1, 2 / (length + 1) * data + (length - 1) / (length + 1) * EMA[1], Average(data, length));
plot MyEma = EMA;
}

script fib{
input d     = close;
def ema2    = MyEMA(d, 2);
def ema3    = MyEMA(d, 3);
def ema5    = MyEMA(d, 5);
def ema8    = MyEMA(d, 8);
def ema13   = MyEMA(d, 13);
def ema21   = MyEMA(d, 21);
def ema34   = MyEMA(d, 34);
def ema55   = MyEMA(d, 55);
def ema89   = MyEMA(d, 89);
def ema144  = MyEMA(d, 144);
def ema233  = MyEMA(d, 233);
def ema377  = MyEMA(d, 377);
def ema610  = MyEMA(d, 610);
def ema987  = MyEMA(d, 987);
def ema1597 = MyEMA(d, 1597);
def sumema  = ema2 + ema3 + ema5 + ema8 + ema13 + ema21 + ema34 + ema55 + ema89 + ema144 + ema233 + ema377 + ema610 + ema987 + ema1597;
plot fibavg = sumema / 15;
fibavg.hide();
}

plot fibma_close = fib(close);``````
Okay thanks for your input and help regarding this script! I will check it out and get back to you. Thanks again

Okay thanks for your input and help regarding this script! I will check it out and get back to you. Thanks again
The image of the chart is off I believe. I didn't realize until later that Left-axis should probably be checked, when you do that, there is a large difference to both.

The image of the chart is off I believe. I didn't realize until later that Left-axis should probably be checked, when you do that, there is a large difference to both.
Ok whether I have left axis checked or unchecked on mine it doesn't change your FMA...but what does change your FMA is when you input diff time frames...Daily is normal while 1 min you see the difference of the diff FMA's...

Last edited:
I don't know why you aren't seeing anything different. Code I shared above. Blue is left-axis checked. Pink is left-axis unchecked.

Hi can you provide a pic because when I check and uncheck left axis I do not see a difference (was looking on Daily chart) thanks.
I don't know why you aren't seeing anything different. Code I shared above. Blue is left-axis checked. Pink is left-axis unchecked.

So sorry I got it now....I had left axis unchecked in main settings... I see the same exact thing....

I don't know why you aren't seeing anything different. Code I shared above. Blue is left-axis checked. Pink is left-axis unchecked.

So what's your suggestion concerning the noticible differece between the two? Thx

So what's your suggestion concerning the noticible differece between the two? Thx
I'm new to this, but I think this means you need the Left-axis checked (not being an ***) for this just because the unchecked is so low from the candlesticks. I don't know if changes to the script may change that. I just took what someone else wrote and added the MyEMA. After digging into this a little today, I'm not so sure if I know this is useful at least by itself. By the look of it (on a longer term chart), it gets progressively tighter. My guess is it becomes more useful on smaller timeframes for very specific purposes but I don't know how to test that theory properly. You gotta get one of the big boys to look into this.

I'm new to this, but I think this means you need the Left-axis checked (not being an ***) for this just because the unchecked is so low from the candlesticks. I don't know if changes to the script may change that. I just took what someone else wrote and added the MyEMA. After digging into this a little today, I'm not so sure if I know this is useful at least by itself. By the look of it (on a longer term chart), it gets progressively tighter. My guess is it becomes more useful on smaller timeframes for very specific purposes but I don't know how to test that theory properly. You gotta get one of the big boys to look into this.
Lol I'm probably more new to this or more inexperienced than you trust me....I am actually on phone with TOS Tech and he is going to look into it because it changes the Fibonacci Moving Average (pic 1 below)...He will call me back once someone has looked into why the FMA is being manipulated...my guess is because of the custom script (pic 2)...because if you use an actual TOS script like Keltner Channels it just shifts the screen slightly and not the FMA with related to price action.

pic 1

pic 2

I'll let you know what TOS tech sup says when they figure it out...thanks

Lol I'm probably more new to this or more inexperienced than you trust me....I am actually on phone with TOS Tech and he is going to look into it because it changes the Fibonacci Moving Average (pic 1 below)...He will call me back once someone has looked into why the FMA is being manipulated...my guess is because of the custom script (pic 2)...because if you use an actual TOS script like Keltner Channels it just shifts the screen slightly and not the FMA with related to price action.

pic 1

pic 2

I'll let you know what TOS tech sup says when they figure it out...thanks
Sometimes you just gotta do what you gotta do.

Sometimes you just gotta do what you gotta do.
I totally agree otherwise you'll always have your nose squished against the window on the outside always looking in ...thanks

Wonder if this would work in tandem well with an HMA or if it'd be "too" reactive. Either way, I'd be interested to see this come to fruition
I'm Testing with HMA using Left axis on and off as a trend reversal crossover tool.

Convert Tradingview Fibonacci Moving Average to ToS
I'm predominantly a price action trader but found code for trading View that looks pretty good.
I only care about the 8 and 21 EMA's so if whoever tries it wants a shortcut that's all I'm looking for. Pretty sure I could add any other EMA's later if I wanted. And the video in that link won't play cause they said it's too old.
I typically only trade price action and do great on weekly setups with no indicators at all but due to my job it's too hard to do intraday so trying to find something that might help spot better trades
And here is the script>

Code:
``````//@version=3
#TV 8EMA Fibo & Pivot Point Reversal

study(title="8EMA's Fibo + Pivot Reversal Strategy with Alerts - Ru++", shorttitle="8EMA's Fibo + Pivot Reversal Strategy with Alerts - Ru++", overlay = true)

EMA1 = input(8, minval=1, title="EMA1")
EMA2 = input(13, minval=1, title="EMA2"),
EMA3 = input(21, minval=1, title="EMA3")
EMA4 = input(34, minval=1, title="EMA4"),
EMA5 = input(55, minval=1, title="EMA5")
EMA6 = input(89, minval=1, title="EMA6")
EMA7 = input(144, minval=1, title="EMA7")
EMA8 = input(233, minval=1, title="EMA8")

plot(ema(close, EMA1), color=green, linewidth=2)
plot(ema(close, EMA2), color=white, linewidth=2)
plot(ema(close, EMA3), color=gray, linewidth=2)
plot(ema(close, EMA4), color=blue, linewidth=2)
plot(ema(close, EMA5), color=red, linewidth=2)
plot(ema(close, EMA6), color=orange, linewidth=2)
plot(ema(close, EMA7), color=yellow, linewidth=2)
plot(ema(close, EMA8), color=purple, linewidth=2)

leftBars = input(4)
rightBars = input(2)

swh = pivothigh(leftBars, rightBars)
swl = pivotlow(leftBars, rightBars)

swh_cond = not na(swh)

hprice = 0.0
hprice := swh_cond ? swh : hprice[1]

le = false
le := swh_cond ? true : (le[1] and high > hprice ? false : le[1])

swl_cond = not na(swl)

lprice = 0.0
lprice := swl_cond ? swl : lprice[1]

se = false
se := swl_cond ? true : (se[1] and low < lprice ? false : se[1])

// Filter out signals if opposite signal is also on
se_filtered = se and not le
le_filtered = le and not se

// Filter consecutive entries
prev = 0
prev := se_filtered ? 1 : le_filtered ? -1 : prev[1]

se_final = se_filtered and prev[1] == -1
le_final = le_filtered and prev[1] == 1

plotshape(se_final, color=green, text = "BUY", style=shape.triangleup,location=location.belowbar)
plotshape(le_final, color=red, text = "SELL", style=shape.triangledown,location=location.abovebar)

Last edited by a moderator:

87k+ Posts
326 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?