Initial Commit ...
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
//@version=3
|
||||
|
||||
study(title="TRIX Histogram R2.1 by JustUncleL", shorttitle="TRIXHIS R2")
|
||||
|
||||
// Author: JustUncleL
|
||||
// Revision: R2
|
||||
//
|
||||
// Description:
|
||||
// This study is an implementation of the Standard TRIX indicator, shown
|
||||
// in coloured histogram format by default, with optional Bar colouring of TRIX zero
|
||||
// and signal crossovers. Other options include showing TRIX as a linegraph instead
|
||||
// of histogram and optional TRIX signal line with difference histogram.
|
||||
// Have a look at Internet references below for some examples of how TRIX can be used.
|
||||
//
|
||||
// Candle Colouring:
|
||||
// - Aqua = TRIX zero crossing from below to above zero.
|
||||
// - Blue = TRIX zero crossing from above to below zero.
|
||||
// - Gold = TRIX signal line crossing TRIX line from above to below.
|
||||
// - Fuchsia= TRIX signal line crossing TRIX line from below to above.
|
||||
//
|
||||
// References:
|
||||
// - http://forex-indicators.net/momentum-indicators/trix
|
||||
// - http://www.dolphintrader.com/3-ma-exponential-moving-average-trix-forex-strategy/
|
||||
// - "TRIX MA" by munkeefonix
|
||||
//
|
||||
// Revisions:
|
||||
// R2 - Added Signal line crossover bar colouring and all TRIX crosses highlighted.
|
||||
// - Changed Signal line crosses to "+", instead of arrow for better visibility.
|
||||
// - Added Alerts for crossovers.
|
||||
// - Added Implied GPL Copyright notice.
|
||||
//
|
||||
// R1 - Original version.
|
||||
//
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
// Copyright 2014 munkeefonix
|
||||
// Copyright 2017,2018 JustUncleL
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// The GNU General Public License can be found here
|
||||
// <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
// --- INPUTS ---
|
||||
//
|
||||
length = input(12, minval=1, title="TRIX length")
|
||||
signallen = input(8, minval=1, title="Signal Length")
|
||||
showSignal= input(true, title="Show Signal line")
|
||||
showLine = input(false, title="Show TRIX as Line instead of Histogram")
|
||||
showZeroX = input(false, title="Show TRIX Zero cross overs")
|
||||
showTrixX = input(false, title="Show TRIX Signal cross overs")
|
||||
showBars = input(false, title="Colour Crossover Candles")
|
||||
//
|
||||
// --- /INPUTS ---
|
||||
|
||||
// --- CONSTANTS ---
|
||||
//
|
||||
BLUE = #0000FFFF
|
||||
AQUA = #00FFFFFF
|
||||
GOLD = #FFD700FF
|
||||
gold = #FFD700
|
||||
BLACK = #000000FF
|
||||
GRAY = #808080FF
|
||||
DARKGRAY= #696969FF
|
||||
PURPLE = #800080FF
|
||||
FUCHSIA = #FF00FFFF
|
||||
MAROON = #8B0000FF
|
||||
GREEN = #008000FF
|
||||
//
|
||||
scaleup = 2
|
||||
//
|
||||
// --- /CONSTANTS
|
||||
|
||||
// --- FUNCTIONS ---
|
||||
//
|
||||
// Triple EMA function
|
||||
tema(a, b)=>ema(ema(ema(a, b), b), b)
|
||||
|
||||
// TRIX function
|
||||
trix(a, b)=>
|
||||
t = tema(a,b)
|
||||
10000* ((t-t[1]) / t[1])
|
||||
|
||||
// --- /FUNCTIONS ---
|
||||
|
||||
// --- SERIES ---
|
||||
//
|
||||
TRIX = trix(close,length)
|
||||
TRIXsig = ema(TRIX,signallen)
|
||||
TRIXdiff= (TRIX - TRIXsig) * scaleup
|
||||
//
|
||||
signalX = crossover(TRIXsig,TRIX) ? -1 : crossunder(TRIXsig,TRIX) ? 1 : 0
|
||||
//
|
||||
trixZX = crossover(TRIX,0)? 1 : crossunder(TRIX,0)? -1: 0
|
||||
//
|
||||
// --- /SERIES ---
|
||||
|
||||
// --- PLOTTING
|
||||
//
|
||||
hline(0, title="Zero")
|
||||
plot(showLine?na:TRIX, title="TRIX Histogram", color = TRIX>=0 ? rising(TRIX,3)?lime:green : falling(TRIX,3)?maroon:red, style=histogram, linewidth=4, transp=10)
|
||||
plot(showLine?TRIX:na, title="TRIX Line", color = TRIX>=0 ? rising(TRIX,3)?lime:green : falling(TRIX,3)?maroon:red, style=line, linewidth=2, transp=10)
|
||||
plot(showSignal?TRIXsig:na, title="TRIX Signal", color = orange, style=circles, join=true, linewidth=2, transp=10)
|
||||
plot(showSignal?TRIXdiff:na, title="TRIX Diff", color = gray, style=area, linewidth=1, transp=70)
|
||||
|
||||
plot(showSignal and showTrixX and signalX!=0?TRIXsig:na, style=cross, title="Signal X Highlight", color=black, transp=20, linewidth=5)
|
||||
plot(showSignal and showTrixX and signalX==1?TRIXsig:na, style=cross, title="Signal X up", color=gold, transp=0, linewidth=4)
|
||||
plot(showSignal and showTrixX and signalX==-1?TRIXsig:na, style=cross, title="Signal X down", color=fuchsia, transp=20, linewidth=4)
|
||||
|
||||
plot(showZeroX and trixZX!=0?TRIX:na, style=circles, title="Zero X Highlight", color=black, transp=20, linewidth=5)
|
||||
plot(showZeroX and trixZX==1?TRIX:na, style=circles, title="Zero X up", color=aqua, transp=10, linewidth=4)
|
||||
plot(showZeroX and trixZX==-1?TRIX:na, style=circles, title="Zero X down", color=blue, transp=10, linewidth=4)
|
||||
|
||||
bclr = showZeroX? trixZX==1? AQUA: trixZX==-1? BLUE: na : na
|
||||
bclr := not na(bclr)? bclr : showSignal and showTrixX ? signalX==-1? FUCHSIA : signalX==1? GOLD : na : na
|
||||
barcolor(showBars?bclr:na,title="TRIX Zero X Bar")
|
||||
|
||||
// --- /PLOTTING ---
|
||||
|
||||
// --- ALERTING ---
|
||||
|
||||
alertcondition(trixZX==1,title="ZERO X Up Alert",message="ZERO X UP")
|
||||
alertcondition(trixZX==-1,title="ZERO X Down Alert",message="ZERO X DOWN")
|
||||
alertcondition(signalX==1,title="Signal X Up Alert",message="SIGNAL X UP")
|
||||
alertcondition(signalX==-1,title="Signal X Down Alert",message="SIGNAL X DOWN")
|
||||
|
||||
// --- /ALERTING ---
|
||||
|
||||
// eof
|
||||
Reference in New Issue
Block a user