Skip to content

Instantly share code, notes, and snippets.

@sherwind
Created May 14, 2018 04:27
Show Gist options
  • Save sherwind/7191e392bad4bffc704b2d8844bc4267 to your computer and use it in GitHub Desktop.
Save sherwind/7191e392bad4bffc704b2d8844bc4267 to your computer and use it in GitHub Desktop.
Money Flow Oscillator
//@version=3
//
// Measures buying and selling pressure over a given lookback period.
// As described at http://traders.com/Documentation/FEEDbk_docs/2015/10/TradersTips.html
//
// See also:
// - Are price updates a good proxy for actual traded volume in FX? <https://www.fxstreet.com/education/are-price-updates-a-good-proxy-for-actual-traded-201104220000>
// - Using Tick Volume in Forex: A Clear NVO Based Example <http://mechanicalforex.com/2010/08/using-tick-volume-in-forex-clear.html>
//
// -----------------------------------------------------------------------------
// Copyright 2018 sherwind
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// The GNU General Public License can be found here
// <http://www.gnu.org/licenses/>.
//
// -----------------------------------------------------------------------------
//
study("Money Flow Oscillator", shorttitle="MFO")
input_len = input(20, title="Length")
mfo(len) =>
HL1 = high - low[1]
HL2 = high[1] - low
OSC = (HL1 - HL2) / (HL1 + HL2)
MLTP = high < low[1] ? -1 : high[1] < low ? 1 : OSC
MFO = sum(MLTP * volume, len) / sum(volume, len)
plot(mfo(input_len), title="MFO", color=green, transp=0)
hline(0, title="Zero")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment