0% found this document useful (0 votes)
145 views3 pages

LuxAlgo MA Sabres Indicator Guide

This document defines an indicator for Pine Script that plots moving average (MA) bands and signals. It allows customizing the MA type, length, and previous trend duration used to determine reversals. On bullish signals, it draws green shaded triangles pointing up from the low. On bearish signals, it draws red shaded triangles pointing down from the high. It also plots the MA and signals as circles.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views3 pages

LuxAlgo MA Sabres Indicator Guide

This document defines an indicator for Pine Script that plots moving average (MA) bands and signals. It allows customizing the MA type, length, and previous trend duration used to determine reversals. On bullish signals, it draws green shaded triangles pointing up from the low. On bearish signals, it draws red shaded triangles pointing down from the high. It also plots the MA and signals as circles.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • Indicator Settings
  • Calculations
  • Plotting
  • Execution

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.

0
International (CC BY-NC-SA 4.0) [Link]
// © LuxAlgo

//@version=5
indicator('MA Sabres [LuxAlgo]', shorttitle='LuxAlgo - MA Sabres',
max_polylines_count=100, overlay=true)

//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
type = [Link]( "TEMA" , 'MA Type' , group=
'MA'
, options = ["SMA", "EMA", "SMMA (RMA)", "HullMA", "WMA", "VWMA", "DEMA", "TEMA",
"NONE"])
len = [Link] ( 50 , 'Length' , group=
'MA' )
count = [Link] ( 20 , 'Previous Trend Duration' , group=
'MA'
, tooltip = 'Reversal after x bars in the same direction'
)
colUp = [Link] (#2962ff, 'Bullish' ,
group='Colours')
colDn = [Link] (#f23645, 'Bearish' ,
group='Colours')
colMa = [Link] (#787b86, 'MA' ,
group='Colours')

//-----------------------------------------------------------------------------}
//Method MA
//-----------------------------------------------------------------------------{
method ma(string type, int length) =>
//
ema1 = [Link](close, length)
ema2 = [Link](ema1 , length)
ema3 = [Link](ema2 , length)
//
switch type
"SMA" => [Link] (close, length)
"EMA" => ema1
"SMMA (RMA)" => [Link] (close, length)
"HullMA" => [Link] (close, length)
"WMA" => [Link] (close, length)
"VWMA" => [Link](close, length)
"DEMA" => 2 * ema1 - ema2
"TEMA" => (3 * ema1) - (3 * ema2) + ema3
=> na
//-----------------------------------------------------------------------------}
//Calculations
//-----------------------------------------------------------------------------{
ma = [Link](len)
fl = [Link](ma , count)
rs = [Link] (ma , count)
up = fl[1] and ma > ma[1]
dn = rs[1] and ma < ma[1]
atr = [Link](14)
n = bar_index

//-----------------------------------------------------------------------------}
//Execution
//-----------------------------------------------------------------------------{
if up
p = [Link]<[Link]>()
[Link]([Link].from_index(n - 1 , low [1] - atr / 15 ))
[Link]([Link].from_index(n + (len / 2 -1) , low [1] + atr / 2.5))
[Link]([Link].from_index(n + len , low [1] + atr * 2 ))
[Link]([Link].from_index(n + (len / 2 -1) , low [1] + atr / 2.5))
[Link]([Link].from_index(n - 1 , low [1] + atr / 15 ))
[Link](p
, curved = true
, closed = false
, line_color = colUp
, fill_color = [Link](colUp, 50))

if dn
p = [Link]<[Link]>()
[Link]([Link].from_index(n - 1 , high[1] + atr / 15 ))
[Link]([Link].from_index(n + (len / 2 -1) , high[1] - atr / 2.5))
[Link]([Link].from_index(n + len , high[1] - atr * 2 ))
[Link]([Link].from_index(n + (len / 2 -1) , high[1] - atr / 2.5))
[Link]([Link].from_index(n - 1 , high[1] - atr / 15 ))
[Link](p
, curved = true
, closed = false
, line_color = colDn
, fill_color = [Link](colDn, 50))

//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
plot (ma , 'MA' , color= colMa
)
plotshape(up ? low [1] : na, '', color= colUp ,
location=[Link], style=[Link], size=[Link] , offset=-1)
plotshape(up ? low [1] : na, '', color=[Link](colUp, 50),
location=[Link], style=[Link], size=[Link] , offset=-1)
plotshape(up ? low [1] : na, '', color=[Link](colUp, 65),
location=[Link], style=[Link], size=[Link], offset=-1)

plotshape(dn ? high[1] : na, '', color= colDn ,


location=[Link], style=[Link], size=[Link] , offset=-1)
plotshape(dn ? high[1] : na, '', color=[Link](colDn, 50),
location=[Link], style=[Link], size=[Link] , offset=-1)
plotshape(dn ? high[1] : na, '', color=[Link](colDn, 65),
location=[Link], style=[Link], size=[Link], offset=-1)

//-----------------------------------------------------------------------------}

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 
International (CC BY-NC-SA 4.0) https://creativeco
//-----------------------------------------------------------------------------}
//Calculations
//---------------------------
plotshape(up ? low [1] : na, '', color=          colUp     ,
location=location.absolute, style=shape.circle, size=size.tiny  

You might also like