TradingView
PapaAlan
4 sep 2022 10:45

MTF Fair Value Gap Indicator ULTRA 

Tesla, Inc.NASDAQ

Beskrivning

FVG Fair Value Gap Indicator

FVG's commonly known as Fair Value Gaps are mostly in use for forex trading, however it’s been widely used in price action trading, even on regular large cap stocks. Think of it as an imbalance area where the price of the stock may actually be under/over valued due to many orders being injected in a short amount of time, ie . a gap caused by an impulse created by the speed of the price movement. In essence, the FVG can become a kind of magnet drawing the price back to that level to attempt to balance out the orders (when? we don't know). Please do research to understand the concept of FVG's.

You can look for an opportunity as price approaches the FVG for entry either long/short because after all, it is an "Area of Interest" so the price will either bounce or blow through the area. No indicator works 100% of the time so take in context as just another indicator. It tends work on larger time frames best.

IMPORTANT TV RELATED LIMITATIONS: You should take the time to understand the following. A MAXIMUM of 500 boxes and labels are allowed, thus if you elect to display many different time frames of FVGs and/or select to not auto delete old Daily FVGs, the oldest FVGs will be deleted and not be seen. Additionally if you are on a smaller chart time frame (1 min), you may not see older FVGs such as Daily ones that occurred and still exist from long ago. This is due to TV limitation of 20,000 candles of history in each chart timeframe. Example: A 1 minute chart supports approximately 14 days worth of data so looking for Daily FVGs would only go back that far, whereas if your chart was set to 5 minutes you'd be able to see 5 times as many, ie . 60 days worth of Daily FVG's. Obviously setting your chart and looking for Daily FVG's would support up to 20,000 days worth.

The Indicator Provides many different features:

*Creation of FVG's for all hours or just during market hours. Currently you can enable FVG’s for the following timeframes: Current chart timeframe, 5Min, 10Min, 15Min, 1Hr, 4Hr, 8Hr, Daily, Weekly, Monthly.

*Text label displays overlaying FVG bands including creation timestamps.

* Bands reflecting FVG's in action (created/deleted) for the current chart time frame, 15min, 1hr, 4hr, 8hr and daily time frames. The FVG's will be overlayed on the chart if enabled.

*Mitigation Action - Normal - When FVG is balanced out by price action, the FVG will disappear. Dynamic - The FVG band will decrease as the price movement eats into it thus only showing the remaining imbalance. None - For those that wish to retain FVG's even if they were mitigated. Half - FVG’s disappear when the price intrudes 50% of the overall FVG band zone.

*Mitigation Type - The elimination or balancing of the FVG is caused by either the candle wick or body passing completely through the FVG.

*Maximum FVGs - A maximum number of FVGs are created for each different enabled time frame (be aware setting a large number could impact system performance).

*All FVG band colors can be customized by the user.

* All FVG bands auto extend to the right.

* Intrusion Alerts - Trading View alerts are supported. You can use the indicator settings to enable an alert if the price intrudes into the FVG zone by a certain percentage. This is not related to mitigation or removal of the FVG, just a warning that price has reached the area of interest.

Versionsinformation

Updated to provide more accurate price incursion into enabled FVG timeframe bands and also correct actual incursion alert reporting.

Again, incursion means the price enters an FVG area (band). Before setting any alert for this, make sure you go to the indicator settings and select the amount (percentage) of penetration of the price into the FVG band that you desire. Incursion alerts are unique so be sure you go to the chart settings and select to set Add an Alert and this indicator name in the Condition Box. Then select "Any alert() function call and press the Create button.

This is different than setting an alert for the creation of a new FVG for the enabled timeframes. For that type of alert (less commonly used), you perform the same steps as above but do NOT select "Any alert()", instead click the drop down arrow and choose either "Bear FVG Creation", "Both Bull or Bear FVG Creations" or "Bull FVG creation" and the press the Create button.

Updated to provide support for requested 30 minute timeframe.

Logic for FVG creation changed to provide more confirmation before creation. This is more in line with the actual definition of an FVG creation instead of displaying a FVG band that may change one candle too early and then disappear.

Versionsinformation

Fixed bug causing occasional duplicate FVG creation.

Added tips for Incursion Alerts, see indicator settings information icon for that area.

Don't forget you can change the FVG fill colors to be more transparent if your chart gets too busy.

This may do it for this indicator as things are pretty busy for me for some time to come. However, if something serious comes up, please let me know.

Thanks to all for the support!

Versionsinformation

Final Corrections, bug causing FVG creation alerts not to work. Fixed. Thanks to Kell81 for pointing it out.

Versionsinformation

v 1.14 06/23/2023 Update required. PineScript changed and broke indicator request.security area, rewrote some lines near end of script to request timeframe high,low etc. differently.
Also implemented 12hr fvg support.

Versionsinformation

IMPORTANT NOTE: Apparently pinescript server platform has been changed to enforce a memory limitation during Replay Mode that didn't used to be there. I've found no way yet around this so this indicator "as is" will not work in the Replay Stepping mode.

Added requested feature option to have fvg boxes display on right side of chart with adjustable widths.
Added requested feature to only draw discovered FVG's that have a height greater than a user input minimum PIP value 0.0001 x user input. ie. don't show FVG's that have a tiny height
Changed UI to attempt better performance for replay mode. However, still getting exceeding max memory error after server platform changes, added warning message to user on settings page top area about this.

Versionsinformation

Fix Bug related to max number of FVG's per timeframe enabled.
Added feature "View Only Last x number of Fvgs" (see settings panel) for short term traders/scalpers.

Versionsinformation


  1. Hopefully final version except for addressing any reported bugs. My time has become much more limited to continue advancing this indicator.
  2. Revamped code to allow replay mode to run without max memory exceeded error (hopefully).
  3. Revamp of Menu settings.
  4. You now have six possible timeframes to set for fvg creations.
  5. Timeframe ranges have expanded and you can set to other timeframes rather than just those provided before.
  6. You can set different fill colors for each timeframe now.
  7. Added option to show only last “x” number of fvgs for each time frame. “View Only Last x Number of Fvgs”.
  8. Added option to display abbreviated fvg boxes showing them on right side of chart along with a width input. “Show FVGs on Right => Box Width”.
  9. You can now enable a mid line to be drawn on each fvg box along with a thickness, style and colors (bull/bear).
  10. Added a simple average true range formula for a “Momentum Filter”. This was added to allow only stronger price movements during an fvg creation to be shown. ie. it prevents smaller fvgs from being drawn. The larger the factor input the more momentum is required to draw an fvg. Number of bars for the formula can be adjusted as a Length field as well.
  11. Can now enable a minimum number of pips for the price movement during the fvg detection such that it must be at least that number of pips for the fvg to be drawn.
  12. Confirm mitigation of fvgs can be enabled to be delayed to the end of the current bar.
  13. Mitigation Actions have a new selected called “Touch”. When this option is selected, an existing fvg box will be mitigated (disappear) when the price touches either the top (for bullish fvg) or bottom (for bearish fvg).

Versionsinformation

Cosmetic correction to last release.

Versionsinformation

Obviously not final version, this release is a bug fix for wrong timeframe labels on fvgs being displayed, had forgotten to incorporate fix code in previous release.

Versionsinformation

Mitigation bug fixes
New at bottom of settings, option to show mitigated fair value gap boxes for a user defined number of candles before they are removed.

Versionsinformation

Add requested option to Mitigation section of settings "Use Timeframes" that allows user ot enable mitigation of fvg's whereby instead of using the current charts timeframe as the source price for mitigation of all enabled fvg timeframes, instead mitigation will use the associated time frame of each fvg (close) to determine the mitigation of fvg's. ie. if chart is on 5min timeframe and 1hr fvg timeframe enabled, an fvg only mitigated if price action from 1hr meets the criteria instead of the price action from the 5min chart itself.

Versionsinformation

Oops, reset default of new setting mitigation "Use Timeframes" to OFF.

Versionsinformation

Last minute update.
Kommentarer
Jt0th3s
Thank you so much for this indicator, by far the best MTF FVG indicator available, really appreciate all the work!

I noticed that some FVGs get drawn too late, do you know why that could be the case? For example I am on the 5m and a 1H FVG gets drawn nearly another 1 hour after the third candle on the 1H for the FVG had already closed. Interestingly this does not happen all the time...
prasantmit2005
@PapaAlan, I have noticed this too. Also, I have noticed that this happens on lower time frame , say 15 sec and there was gap between the 15 sec candles. This might be the reason why drwaing logic for FVG might not be working.
Also, I wanted to take a moment to say special thanks to you for writing this wonderful indicator.
PapaAlan
@prasantmit2005, thank you for your comments, i have not been able to find the exact cause of this but have suspicions that it has something to do the with tv platform and that this is a more time consuming script. As it appears intermittent i'm thinking that it has to do with the datafeeds. I've spent a lot of time on this with few clues. Can you tell me, you were on 15second timeframe on chart and which fvg timeframe you set up to be active and also what symbol was on your chart? (Hoping to replicate and monitor).
prasantmit2005
@PapaAlan, Thanks a lot for responding so quickly. You are absolutely amazing. Your indicator is the best among the so many that I have come across for FVG on TV.
I was looking into "Nifty 50 index" chart in 15 sec timeframe(selected from top menu). In your indicator's settings- I was using only Timeframe1 with 15 sec. Mitigation Action was set to dynamic and mitigation type set as Wicks. Detection type was set as Body.
Another change in the settings(from default)- was the GMT timezone as 5.5. I don't think that this will impact your logic though.

Thank you for your help.
PapaAlan
@prasantmit2005, thanks for the details, so you specifically were seeing a delay in a 15sec fvg appearing with your settings on 15secs? ie. fvg should appear at end of start of latest candle assuming last three candles are a valid fvg formation. What kind of a delay were you seeing for it to appear, a few seconds, a few minutes, days (lol)?
BTW- What exactly did you mean when you said "there was a gap between the 15 sec candle"? Also, your inquiry into this made me find a bug and fix it for dynamic miti action and also text display so thanks. haven't published it yet pending your issue and one other person who has not responded to me.
prasantmit2005
@PapaAlan, Yes. Correct. I noticed fvg not being created at all. The issue was that there was gap between the 15sec candles (blank gap)- suggesting that no buy & sell happened at those points between those candles. Hence, when you are calculating the fvg between 2 different candles "bodies"- the blank gaps may be causing an issue with the fvg calculation. In my opinion these blank gaps are a type of fvg, as market did not provide any opportunity to either buyer or seller(both parties) - hence market inefficiency created. In typical fvg- the opprtunity has been provided only to one party viz. buyer /seller and other party must be offered the opportunity.
The text display issue that I had noticed but did not mention was about 'm' being added to 15sec on label of fvg creation time. It was displaying 15sm instead of 15s . It wasn't much of an issue anyway. I am assuming you have fixed this.
I am happy to speak with you if you would like to do so. I am not sure though, how we can do it on TV.
Thanks again for the help.
manpat_finance
Thank you very much for this indicator. It's the best one I have FVG indicator I have used.

Is there anyway you can plot FVG type FVG TF, FVG High Low and Midline Prices, etc? I wanted to include this data inside an alert message when alerts are triggered.

Thank you again for making such an incredible indicator and sharing it with the community. Thank you!
zereng3
By far the best FVG indi Ive seen so far, I have one humble request, if possible: An Option to set a minimum size for the FVG (eg 6 pips or similiar) to get rid of all those tiny FVGs.

THANKS
PapaAlan
@zereng3, Wow, a whole year and i never saw your post, i'm so sorry. If you're still around, what typically do you trade? bitcoin? nyse? nasdaq futures etc.? I've got some code for that but am wondering what to set a default value for (user can still change) since so many future types etc. since pip is typically .0001 setting to 4 being .0004 that's pretty small.
Mer