Bitcoin Margin Call Envelopes [saraphig & alexgrover]
"Bitcoin Margin Call Envelopes [saraphig & alexgrover]" by alexgrover, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Bitcoin Margin Call Envelopes [saraphig & alexgrover] (v1.0), read 2026-10-12T15:58:05.101Z; source language v4.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
Bitcoin Margin Call Envelopes [saraphig & alexgrover] by alexgrover, ported from Pine v4. Overlay indicator with 6 plots, drawings and 6 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © saraphig & alexgrover
// ------------------------------------------------------------------------------------------------
// Original author: alexgrover
// Original title: Bitcoin Margin Call Envelopes [saraphig & alexgrover]
// Licence: MPL-2.0 (the header above is the original notice, kept verbatim)
// Pine version: 4
// Fetched: 2026-10-12
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
// Converted by the FloScript converter from a Pine-compatible v4 source.
indicator("Bitcoin Margin Call Envelopes [saraphig & alexgrover]", "BMCE", true)
length = input(100, "MA Length")
source = input(open)
matype = input.string("VWMA", options=["SMA", "VWMA", "KAMA"])
lv1 = input(25, "Leverage 1")
lv2 = input(15, "Leverage 2")
lv3 = input(10, "Leverage 3")
//----
src = 0.
if syminfo.ticker != "BTCUSD"
txt = label.new(bar_index, low, text="Wrong Symbol! Use BTCUSD", color=color.white, style=label.style_label_left, textcolor=#ff1100, size=size.large)
label.delete(txt[1])
src := na
else
src := source
//----
er = math.abs(ta.change(src, length)) / math.sum(math.abs(ta.change(src)), length)
kama = 0.
kama := nz(kama[1], src) + er * nz(src - kama[1])
ma = matype == "VWMA" ? ta.vwma(src, length) : matype == "KAMA" ? kama : ta.sma(src, length)
//----
up(x) => ma / x * (x + 1 - x * 0.005)
dn(x) => ma * x / (x + 1 - x * 0.005)
up3 = up(lv3)
up2 = up(lv2)
up1 = up(lv1)
dn3 = dn(lv3)
dn2 = dn(lv2)
dn1 = dn(lv1)
//----
plot(up3, "Up3", color.new(#2196f3, 0), 2)
plot(up2, "Up2", color.new(#2196f3, 0), 2)
plot(up1, "Up1", color.new(#2196f3, 0), 2)
plot(dn1, "Dn1", color.new(#ff1100, 0), 2)
plot(dn2, "Dn2", color.new(#ff1100, 0), 2)
plot(dn3, "Dn3", color.new(#ff1100, 0), 2)
This file is under the Mozilla Public License 2.0; it is a port of the original by alexgrover, with the original licence header kept and the changes made for FloScript noted in the file.
- v2
Library refresh 2026-10-14
- v1
Library refresh 2026-10-12
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.