Follow Line
"Follow Line" by KivancOzbilgic, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Follow Line (v1.0), read 2026-11-15T18:41:23.333Z; source language v5.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
Follow Line by KivancOzbilgic, ported from Pine v5. Overlay indicator with 1 plot, 2 marker series, alerts and 5 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// (Notice added by FloSignals: the author's source carries none. It was published open-source on 2024-10-10; since 2019-07-26 the platform it was published on has released such a script under MPL-2.0 automatically.)
// ------------------------------------------------------------------------------------------------
// Original author: KivancOzbilgic
// Original title: Follow Line
// Licence: MPL-2.0 (the notice above was added by FloSignals; the original carries none)
// Pine version: 5
// Fetched: 2026-11-15
// 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
indicator(shorttitle='FL', title='Follow Line', overlay=true)
// --- settings
ATRperiod = input.int(defval=5, title='ATR Period', minval=1)
BBperiod = input.int(defval=21, title='Bollinger Bands Period', minval=1)
BBdeviation = input.float(defval=1.00, title='Bollinger Bands Deviation', minval=0.1, step=0.1)
UseATRfilter = input(defval=true, title='ATR Filter On/Off') // false = 0, true = 1
showsignals = input(title='Show Signals ', defval=true)
// --- end of settings
// Bollinger Bands calculation
BBUpper = ta.sma(close, BBperiod) + ta.stdev(close, BBperiod) * BBdeviation
BBLower = ta.sma(close, BBperiod) - ta.stdev(close, BBperiod) * BBdeviation
// ATR calculation
atrValue = ta.atr(ATRperiod)
// Signal initialization
var float FollowLine = na
var int BBSignal = 0
// Determine BB signal
if close > BBUpper
BBSignal := 1
else if close < BBLower
BBSignal := -1
// Buy signal logic
if BBSignal == 1
if UseATRfilter
FollowLine := low - atrValue
else
FollowLine := low
if FollowLine < nz(FollowLine[1])
FollowLine := nz(FollowLine[1])
// Sell signal logic
if BBSignal == -1
if UseATRfilter
FollowLine := high + atrValue
else
FollowLine := high
if FollowLine > nz(FollowLine[1])
FollowLine := nz(FollowLine[1])
// Trend direction determination
var int iTrend = 0
if nz(FollowLine) > nz(FollowLine[1])
iTrend := 1
else if nz(FollowLine) < nz(FollowLine[1])
iTrend := -1
// Trend line color based on trend direction
lineColor = iTrend > 0 ? color.rgb(9, 98, 232) : color.new(color.rgb(220, 20, 60), 0)
//buy & sell conditions
buy = 0.0
sell = 0.0
buy := iTrend[1] == -1 and iTrend == 1 ? 1 : na
sell := iTrend[1] == 1 and iTrend == -1 ? 1 : na
//alerts
alertcondition(sell == 1, title="Sell", message="Follow Line Sell")
alertcondition(buy == 1, title="Buy", message="Follow Line Buy")
alertcondition(buy == 1 or sell == 1, title="Signal", message="Follow Line Signal")
// Plot the trend line and signals
plot(FollowLine, color=lineColor, linewidth=2, title="Follow Line")
plotshape(buy == 1 and showsignals ? FollowLine - atrValue : na, text='BUY', style=shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0, size=size.auto)
plotshape(sell == 1 and showsignals ? FollowLine + atrValue : na, text='SELL', style=shape.labeldown, location=location.absolute, color=color.rgb(102, 15, 15), textcolor=color.white, offset=0, transp=0, size=size.auto)
This file is under the Mozilla Public License 2.0; it is a port of the original by KivancOzbilgic, with the original licence header kept and the changes made for FloScript noted in the file.
- v1
Library refresh 2026-11-15
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.