Skip to content

Instantly share code, notes, and snippets.

@PlanetRoast
Last active April 1, 2020 12:46
Show Gist options
  • Save PlanetRoast/0f9401561203fa938ca39d247179630d to your computer and use it in GitHub Desktop.
Save PlanetRoast/0f9401561203fa938ca39d247179630d to your computer and use it in GitHub Desktop.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © planetroast
//@version=4
study("JMC Indicators")
// -----------------------------------------------------------------------------
// Indicator # 1 (aka 'JMC')
// -----------------------------------------------------------------------------
// Note that the value of this number can vary wildly depnding on which chart
// you apply it to. Some charts will have ranges of -5 to +5, some others will
// stretch into the millions. Some charts don't display this indicatior at all
// and just say "n/a" (presumably because the value is out of range?)
// -----------------------------------------------------------------------------
jmcGain = input(title="JMC Gain", type=input.integer, defval=1000000)
closeMinusLow = close - low
closeMinusHigh = close - high
jmc = (closeMinusLow + closeMinusHigh) / (volume / jmcGain)
plot(jmc, color=color.lime, title="JMC")
// -----------------------------------------------------------------------------
// CAKE
// -----------------------------------------------------------------------------
// This figure has an option available in the chart's settings allowing it to be
// 'inverted'. When this option is enabled the order in which the volume and vma
// are switched around.
cakeLength = input(title="CAKE Length", type=input.integer, defval=8)
invertCake = input(title="Invert Cake", type=input.bool, defval=false)
vma = sma(volume, cakeLength)
cake = if invertCake
jmc * (vma / volume) // Inverted
else
jmc * (volume / vma) // Not inverted
plot(cake, title="CAKE")
// -----------------------------------------------------------------------------
// Indicator # 3 (aka 'SLC')
// -----------------------------------------------------------------------------
slcLength = input(title="SLC Length", type=input.integer, defval=72)
historicSlc = cake[slcLength]
slc = cake - historicSlc
plot(slc, color=color.teal, title="SLC")
// -----------------------------------------------------------------------------
// Objects
// -----------------------------------------------------------------------------
hline(0, color=color.white, linestyle=hline.style_solid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment