Buy Sell Magical Trend

Category: Indicators By: Nicolas Created: April 17, 2023, 9:00 AM
April 17, 2023, 9:00 AM
Indicators
21 Comments

The Buy Sell Magical Trend indicator is a “trailing stop” style indicator made of trend inversion obtained with Bollinger Bands. SignalPeriod is the period of the Bollinger bands and ArrowPeriod the standard deviation applied to it.
The arrows are painted on the breakthrough of the other side band with segments connecting the 2 most recent arrows.

//PRC_BuySell Magic | indicator
//17.04.23
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- settings 
SignalPeriod = 12
ArrowPeriod = 2
// --- end of settings 

bbup = average[signalperiod]+std[signalperiod]*arrowperiod
bbdn = average[signalperiod]-std[signalperiod]*arrowperiod

if ts=0 then
if close crosses over bbup then
ts=bbdn
trend=1
elsif close crosses under bbdn then
ts=bbup
trend=-1
endif
endif

if trend=1 then
ts=max(ts,bbdn)
elsif trend=-1 then
ts=min(ts,bbup)
endif

if trend=1 and close crosses under ts then
trend=-1
ts=bbup
r=255
g=0
drawarrowdown(barindex,ts) coloured("red")
drawsegment(startbar,startts,barindex,ts) style(dottedline2) coloured("blue")
startbar=barindex
startts=ts
endif

if trend=-1 and close crosses over ts then
trend=1
ts=bbdn
r=0
g=255
drawarrowup(barindex,ts) coloured("lime")
drawsegment(startbar,startts,barindex,ts) style(dottedline2) coloured("blue")
startbar=barindex
startts=ts
endif

return ts coloured(r,g,0) style(dottedline,2)

Download
Filename: PRC_BuySell-Magical-Trend.itf
Downloads: 836
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...