Faith Indicator [Mod by Sam4Cok] for ThinkOrSwim
- added trigger candle, trend line modified the hist to be colored.
Creator message:
This indicator compares buyers demand with sellers supply volumes and calculates which prevails. Therefore it only works if volume is published. Buyers demand is assumed for a period in which a higher high is reached with more volume . Sellers supply is recognized by a lower low combined with more volume .
The average of sellers supplies is subtracted from buyers demand, the result is graded because a statement like “The faith in this period was ## percent” has no meaning. We can conclude to more faith and less faith but not represent it in some exact number.
This indicator assigns the following grades:
Very high faith graduated as 8
High faith as 6
Good faith as 4
Some Faith as 2
Little Faith as 1
Neither Faith nor Distrust as zero
Self Protection Distrust graduated as -8
Fear Distrust as -6
Anxiety Distrust as -4
Suspicion Distrust as -2
Doubt Distrust as -1
It is presented as a histogram with blue staves pointing up (meaning faith) and red staves pointing down (meaning distrust)
The background is colored using the Hull Agreement Indicator (Hullag), which I published before. Hullag graduates price movements in five grades to which it assigns a background color. These are as follows:
grade 2: blue, clear upward movement
grade 1: green, some upward movement
grade 0: silver , neither upward nor downward movement
grade -1: maroon, some downward movement
grad -2: red, clear downward movement.
Use of the Faith Indicator:
The indicator shows price action/momentum as a background color and volume action analyzed as a grade of faith in the form of a histogram. Usually faith comes together with rising prices (blue/green background) and distrust with lowering prices (red/maroon background), however contrarian situations occur, e.g. lowering prices while the market has good faith. These can be explained by minority sellers who act contrary to the feelings in the market. You can then decide that this might be an unsustainable move of the quotes.
If the faith indicator confirms the price movement, you might assume that the move is meaningful and will go further. Also if you see faith diminishing you might assume that the move is coming to an end and the tide is going to turn.
- added trigger candle, trend line modified the hist to be colored.
Creator message:
This indicator compares buyers demand with sellers supply volumes and calculates which prevails. Therefore it only works if volume is published. Buyers demand is assumed for a period in which a higher high is reached with more volume . Sellers supply is recognized by a lower low combined with more volume .
The average of sellers supplies is subtracted from buyers demand, the result is graded because a statement like “The faith in this period was ## percent” has no meaning. We can conclude to more faith and less faith but not represent it in some exact number.
This indicator assigns the following grades:
Very high faith graduated as 8
High faith as 6
Good faith as 4
Some Faith as 2
Little Faith as 1
Neither Faith nor Distrust as zero
Self Protection Distrust graduated as -8
Fear Distrust as -6
Anxiety Distrust as -4
Suspicion Distrust as -2
Doubt Distrust as -1
It is presented as a histogram with blue staves pointing up (meaning faith) and red staves pointing down (meaning distrust)
The background is colored using the Hull Agreement Indicator (Hullag), which I published before. Hullag graduates price movements in five grades to which it assigns a background color. These are as follows:
grade 2: blue, clear upward movement
grade 1: green, some upward movement
grade 0: silver , neither upward nor downward movement
grade -1: maroon, some downward movement
grad -2: red, clear downward movement.
Use of the Faith Indicator:
The indicator shows price action/momentum as a background color and volume action analyzed as a grade of faith in the form of a histogram. Usually faith comes together with rising prices (blue/green background) and distrust with lowering prices (red/maroon background), however contrarian situations occur, e.g. lowering prices while the market has good faith. These can be explained by minority sellers who act contrary to the feelings in the market. You can then decide that this might be an unsustainable move of the quotes.
If the faith indicator confirms the price movement, you might assume that the move is meaningful and will go further. Also if you see faith diminishing you might assume that the move is coming to an end and the tide is going to turn.
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at #https://mozilla.org/MPL/2.0/
#// © eykpunter
#//@version=4
#study(title="Faith Indicator", shorttitle="Faith")
# Converted and mod by Sam4Cok@Samer800 - 09/2022
declare lower;
input ColorTriggerBar = yes;
input Background = yes;
input ColorHistogram = yes;
input FaithLength = 15; # "periods for averaging"
input Sensitivity = 0.1; # "Minimum ATR difference required to call a trend"
input FastLength = 20; # "Fast Trend Length
input SlowLength = 25; # "Slow Trend Length
input atrLength = 30; # "Atr periods for trend Ind.
input ShowMomLine = yes;
input MomLength = 100; # "Momentum Length"
input SmoothMom = 2.0; # "Smooth Momentum"
input rsiLength = 10; # "RSI Length"
# ///=========================================================
def na = Double.NaN;
#//========== Color Palette= =================================
DefineGlobalColor("bg2" , CreateColor(10, 110, 189)); # blue
DefineGlobalColor("bg1" , CreateColor(53, 122, 56)); # green
DefineGlobalColor("bg0" , Color.GRAY); # silver
DefineGlobalColor("bgm1" , Color.DARK_RED); # maroon
DefineGlobalColor("bgm2" , CreateColor(255, 108, 108)); # red
#=============================================================
DefineGlobalColor("bg22" , CreateColor(57, 161, 244)); # blue
DefineGlobalColor("bg21" , CreateColor(63, 160, 68)); # green
DefineGlobalColor("bgm21" , CreateColor(136, 14, 79)); # maroon
DefineGlobalColor("bgm22" , CreateColor(255, 31, 31)); # red
#//===========================================================
def up = high > high[1] and volume > volume[1];
def down = low < low[1] and volume > volume[1];
def vproc = volume / Highest(volume, 30) * 200;
def volup = if up then vproc else 0;
def voldown = if down then vproc else 0;
def maup = SimpleMovingAvg(volup, FaithLength);
def madown = SimpleMovingAvg(voldown, FaithLength);
def difvol = maup - madown;# buyers dominate the volume or sellers dominate it
def u1 = if difvol > 60 then 8 else 0;# Very high faith graduated as 8
def u2 = if difvol > 40 and difvol <= 60 then 6 else 0;# High faith as 6
def u3 = if difvol > 20 and difvol <= 40 then 4 else 0;# Good faith as 4
def u4 = if difvol > 10 and difvol <= 20 then 2 else 0;# Some Faith as 2
def u5 = if difvol > 0 and difvol <= 10 then 1 else 0;# Little Faith as 1
def d1 = if difvol < -60 then -8 else 0;# Very High mistrust graduated as -8
def d2 = if difvol < -40 and difvol >= -60 then -6 else 0;# High Mistrust as -6
def d3 = if difvol < -20 and difvol >= -40 then -4 else 0;# Bad Mistrust as -4
def d4 = if difvol < -10 and difvol >= -20 then -2 else 0;# Some Mistrust as -2
def d5 = if difvol < 0 and difvol >= -10 then -1 else 0;# Little Mistrust as -1
def dif = u1 + u2 + u3 + u4 + u5 + d1 + d2 + d3 + d4 + d5;
#//Backgroud colors taken from Hull Moving Average Agreement Indicator (Hullag)
def istrend = Sensitivity * ATR(length = atrLength);
def fh = HullMovingAvg(close, FastLength);# fast Hull Moving Average
def fangle = fh - fh[1];
def ftrend;
ftrend = if IsNaN(ftrend[1]) then 0 else
if fangle > istrend then 1 else
if fangle < -istrend then -1 else 0;# fast trend uptrend, no trend, down trend
def sh = HullMovingAvg(close, SlowLength);# slow Hull Moving Average
def sangle = sh - sh[1];# angle of slow hull slope as a kind of tangent
def strend;
strend = if IsNaN(strend[1]) then 0 else
if sangle > istrend then 1 else
if sangle < -istrend then -1 else 0;# slow trend uptrend, no trend, down trend
def hullag = ftrend + strend;# possible graduations are 2, 1, 0, -1, -2
#// Range Filter ===========
############
script nz {
input data = 0;
input data1 = 0;
def ret_val = if isNaN(data) then data1 else data;
plot return = ret_val;
}
#// Smooth Average Range
#smoothrng(x, t, m)
script smoothrng {
input src = close;
input per = 100;
input mult = 3;
def wper = per * 2 - 1;
def avrng = ExpAverage(AbsValue(src - src[1]), per);
def smoothrng = ExpAverage(avrng, wper) * mult;
plot result = smoothrng;
}
#rngfilt(x, r) =>
script rngfilt {
input x = close;
input r = 0;
def rngfilt = if x > nz(rngfilt[1]) then
if (x - r) < nz(rngfilt[1]) then nz(rngfilt[1]) else (x - r) else
if (x + r) > nz(rngfilt[1]) then nz(rngfilt[1]) else (x + r);
plot result = rngfilt;
}
def smrng = smoothrng(hl2, MomLength, SmoothMom);
def filt = rngfilt(hl2, smrng);
#// Filter Direction
def upward = if filt > filt[1] then nz(upward[1]) + 1 else
if filt < filt[1] then 0 else nz(upward[1]);
def downward = if filt < filt[1] then nz(downward[1]) + 1 else
if filt > filt[1] then 0 else nz(downward[1]);
#########
def Exup = upward>0 and (hullag == 2 and hullag[1] < 2) and dif > 0 and RSI(rsiLength)>=51;
def Exdn = downward>0 and (hullag ==-2 and hullag[1] >-2) and dif < 0 and RSI(rsiLength)<=49;
#==========================================================================
plot Sig = if Exup or Exdn then 0 else na;
Sig.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Sig.AssignValueColor(if Exup then Color.GREEN else Color.MAGENTA);
Sig.SetLineWeight(3);
plot zero = if IsNaN(close) then na else if !Exup then 0 else na;
zero.SetStyle(Curve.FIRM);
zero.SetHiding(!ShowMomLine);
zero.SetLineWeight(2);
zero.AssignValueColor( if upward>0 then Color.GREEN else
if downward>0 then Color.RED else GlobalColor("bg0") );
#//=========== Ploting =====================================///
plot Faith = dif; #"Grade of Faith Fast"
Faith.SetHiding(ColorHistogram);
Faith.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Faith.AssignValueColor( if dif > 0 then GlobalColor("bg22") else
GlobalColor("bgm22"));
Faith.SetLineWeight(3);
AddChart(high = if ColorHistogram then if hullag == 2 then if dif > 0 then dif else 0 else na else na,
low = if hullag == 2 then if dif < 0 then dif else 0 else na,
open = if hullag == 2 then if dif > 0 then dif else 0 else na,
close = if hullag == 2 then if dif < 0 then dif else 0 else na,
type = ChartType.CANDLE, growcolor = GlobalColor("bg22"));
AddChart(high = if ColorHistogram then if hullag == -2 then if dif > 0 then dif else 0 else na else na,
low = if hullag == -2 then if dif < 0 then dif else 0 else na,
open = if hullag == -2 then if dif > 0 then dif else 0 else na,
close = if hullag == -2 then if dif < 0 then dif else 0 else na,
type = ChartType.CANDLE, growcolor = GlobalColor("bgm22"));
AddChart(high = if ColorHistogram then if hullag == 1 then if dif > 0 then dif else 0 else na else na,
low = if hullag == 1 then if dif < 0 then dif else 0 else na,
open = if hullag == 1 then if dif > 0 then dif else 0 else na,
close = if hullag == 1 then if dif < 0 then dif else 0 else na,
type = ChartType.CANDLE, growcolor = GlobalColor("bg21"));
AddChart(high = if ColorHistogram then if hullag == -1 then if dif > 0 then dif else 0 else na else na,
low = if hullag == -1 then if dif < 0 then dif else 0 else na,
open = if hullag == -1 then if dif > 0 then dif else 0 else na,
close = if hullag == -1 then if dif < 0 then dif else 0 else na,
type = ChartType.CANDLE, growcolor = GlobalColor("bgm21"));
AddChart(high = if ColorHistogram then if hullag == 0 then if dif > 0 then dif else 0 else na else na,
low = if hullag == 0 then if dif < 0 then dif else 0 else na,
open = if hullag == 0 then if dif > 0 then dif else 0 else na,
close = if hullag == 0 then if dif < 0 then dif else 0 else na,
type = ChartType.CANDLE, growcolor = GlobalColor("bg0"));
#==========================================================================
AssignPriceColor(if ColorTriggerBar then
if Exup then Color.BLUE else if Exdn then Color.MAGENTA
else Color.CURRENT else Color.CURRENT);
#### Background
AddCloud(if Background then
if hullag == 2 then Double.POSITIVE_INFINITY else
if hullag == -2 then Double.NEGATIVE_INFINITY else na else na,
if hullag == 2 then Double.NEGATIVE_INFINITY else
if hullag == -2 then Double.POSITIVE_INFINITY else na,
GlobalColor("bg2"), GlobalColor("bgm2"));
AddCloud(if Background then
if hullag == 1 then Double.POSITIVE_INFINITY else
if hullag == -1 then Double.NEGATIVE_INFINITY else na else na,
if hullag == 1 then Double.NEGATIVE_INFINITY else
if hullag == -1 then Double.POSITIVE_INFINITY else na,
GlobalColor("bg1"), GlobalColor("bgm1"));
AddCloud(if Background then
if hullag == 0 then Double.POSITIVE_INFINITY else na else na,
if hullag == 0 then Double.NEGATIVE_INFINITY else na,
GlobalColor("bg0"), GlobalColor("bg0"));
### END
Last edited by a moderator: