Indicator example

Money Flow Indicator

Readonly source from tests/EasyLanguage/David_EasyLanguage, generated Pine Script v6, and an expiry-free example EX5.

Original EasyLanguage

  1. { Search Tag: WA-Money Flow }
  2. inputs:
  3. Length( 14 ) [
  4. DisplayName = "Length",
  5. ToolTip = "Enter number of bars over which to calculate Money Flow."],
  6. AlertLength( 14 ) [
  7. DisplayName = "AlertLength",
  8. ToolTip = "Enter number of bars over which to look for a bullish or bearish divergence."],
  9. OverSold( 20 ) [
  10. DisplayName = "OverSold",
  11. ToolTip = "Enter the level of the indicator at which you consider the market to be oversold (too low)."],
  12. OverBought( 80 ) [
  13. DisplayName = "OverBought",
  14. ToolTip = "Enter the level of the indicator at which you consider the market to be overbought (too high)."],
  15. OverSColor( MyColors( "DodgerBlue" ) ) [
  16. DisplayName = "OverSColor",
  17. ToolTip = "Oversold Color. Enter the color to use when the indicator's value is below OverSold."],
  18. OverBColor( Red ) [
  19. DisplayName = "OverBColor",
  20. ToolTip = "Overbought Color. Enter the color to use when the indicator's value is above OverBought."];
  21. variables:
  22. MoneyFlowValue( 0 );
  23. MoneyFlowValue = MoneyFlow( Length );
  24. Plot1( MoneyFlowValue, !( "MoneyFlow" ) );
  25. Plot2( OverBought, !( "OverBot" ) );
  26. Plot3( OverSold, !( "OverSld" ) );
  27. { color criteria }
  28. if MoneyFlowValue > OverBought then
  29. SetPlotColor( 1, OverBColor )
  30. else if MoneyFlowValue < OverSold then
  31. SetPlotColor( 1, OverSColor );
  32. { alert criteria }
  33. if AlertEnabled then
  34. begin
  35. if LowestBar( C, AlertLength ) = 0
  36. and LowestBar( MoneyFlowValue, AlertLength ) > 0 then
  37. begin
  38. Alert( !( "Bullish divergence - new low not confirmed" ) );
  39. end
  40. else if HighestBar( C, AlertLength ) = 0
  41. and HighestBar( MoneyFlowValue, AlertLength ) > 0 then
  42. begin
  43. Alert( !( "Bearish divergence - new high not confirmed" ) );
  44. end;
  45. end;
  46. { ** Copyright © TradeStation Technologies, Inc. All Rights Reserved **
  47. ** TradeStation reserves the right to modify or overwrite this analysis technique
  48. with each release. ** }

Generated Pine Script v6

  1. //@version=6
  2. indicator("MoneyFlowIndicator", overlay=true)
  3. length = input.float(14.0, "length")
  4. alertlength = input.float(14.0, "alertlength")
  5. oversold = input.float(20.0, "oversold")
  6. overbought = input.float(80.0, "overbought")
  7. overscolor = input.color(color.rgb(30, 144, 255), "overscolor")
  8. color overbcolor = color.red
  9. var float moneyflowvalue = 0
  10. float __el_plot1 = na
  11. color __el_plot1_color = color.blue
  12. float __el_plot2 = na
  13. color __el_plot2_color = color.blue
  14. float __el_plot3 = na
  15. color __el_plot3_color = color.blue
  16. __el_call1 = ta.mfi(hlc3, int(length))
  17. __el_call2 = ta.lowestbars(close, int(alertlength))
  18. __el_call3 = ta.lowestbars(moneyflowvalue, int(alertlength))
  19. __el_call4 = ta.highestbars(close, int(alertlength))
  20. __el_call5 = ta.highestbars(moneyflowvalue, int(alertlength))
  21. if bar_index >= 13
  22. moneyflowvalue := __el_call1
  23. __el_plot1 := moneyflowvalue
  24. __el_plot2 := overbought
  25. __el_plot3 := oversold
  26. if moneyflowvalue > overbought
  27. __el_plot1_color := overbcolor
  28. else
  29. if moneyflowvalue < oversold
  30. __el_plot1_color := overscolor
  31. if true
  32. if __el_call2 == 0 and __el_call3 > 0
  33. alert("Bullish divergence - new low not confirmed", alert.freq_once_per_bar)
  34. else
  35. if __el_call4 == 0 and __el_call5 > 0
  36. alert("Bearish divergence - new high not confirmed", alert.freq_once_per_bar)
  37. plot(__el_plot1, title="MoneyFlow", color=__el_plot1_color)
  38. plot(__el_plot2, title="OverBot", color=__el_plot2_color)
  39. plot(__el_plot3, title="OverSld", color=__el_plot3_color)

Compiled MetaTrader 5 example

The EX5 uses the original script filename stem and has no PineAnywhere expiration guard.

Download MoneyFlowIndicator.ex5
An unexpected error occurred. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.