Fisher Transform For ThinkOrSwim
Hey! So this is a two part question.
I have found this indicator "Fisher Transform" to be very useful in certain circumstances.
1. I wanted to know if the code only initiates the green arrow upon the completion of the NEXT bar.
I see the ftonebarback but am not 100% on the situation.
2. How I can get this to work in a scan and in a watchlist. I have been trying for the scan:
Fisher_Transform(). "FSTrendIndicatorUp" is true
but that yields NO results. If I use the bigpinkup instead, it does catch some symbols, but the pink arrow lags much more than the green arrow. By then the move is underway.
I've tried using a Squeeze indicator for the watchlist and substituting the fisher transform information in, but I get an error saying the function is too complex. So I tried removing the buy zone stuff but then it says that I need to have at least one plot...
I'm kind a lost. If anyone could at least steer me in a helpful direction, I would be very grateful!
This is a picture of the Indicator if this helps
Hey! So this is a two part question.
I have found this indicator "Fisher Transform" to be very useful in certain circumstances.
Code:
declare lower;
input price = hl2;
input length = 10;
def maxHigh = Highest(price, length);
def minLow = Lowest(price, length);
def range = maxHigh - minLow;
rec value = if IsNaN(price)
then Double.NaN
else if IsNaN(range)
then value[1]
else if range == 0
then 0
else 0.66 * ((price - minLow) / range - 0.5) + 0.67 * value[1];
def truncValue = if value > 0.99 then 0.999 else if value < -0.99 then -0.999 else value;
rec fish = 0.5 * (Log((1 + truncValue) / (1 - truncValue)) + fish[1]);
#
# TD Ameritrade IP Company, Inc. (c) 2007-2019
#
plot FTOneBarBack = fish[1];
plot FT = fish;
plot ZeroLine = 0;
FTOneBarBack.SetDefaultColor(color.yellow);
FT.SetDefaultColor(GetColor(8));
ZeroLine.SetDefaultColor(GetColor(5));
input emalength = 50;
plot ema2 = ExpAverage(fish, emalength);
def bullish = if FT > ema2 then 1 else 0;
def bearish = if FT < ema2 then 1 else 0;
#####
#
# FisherTransformer Trend Up Indicator (Big Pink)
#
#
# TD Ameritrade IP Company, Inc. (c) 2017-2019
#
##### (2) Fisher Transformer setup for "FS17x5"(Big Pink) Up or Down
#Fisher_Transform_FW_Code().Scan for "FS17x5"
#The FT Code:
# Fisher Transform With First Wave (David Elliott) Signal Additions
# V01.04.2015
#
### START: FisherTransformer Initialization: Stochastic and SOAP
#
def FisherLen = 5;
def ObOs = 1.2;
def hideSoap = yes;
def h = high;
def l = low;
def c = close;
def CountChg;
def SOAPCount;
def BPmaxHigh = Highest(h, FisherLen);
def BPminLow = Lowest(l, FisherLen);
def k1v = Max(-100, Min(100, (StochasticFull(KPeriod = 5, slowing_period = 3))) - 50) / 50.01;
def k2v = Max(-100, Min(100, (StochasticFull(KPeriod = 8, slowing_period = 5))) - 50) / 50.01;
def k3v = Max(-100, Min(100, (StochasticFull(KPeriod = 17, slowing_period = 5))) - 50) / 50.01;
def R1v = Max(-100, Min(100, reference RSI(2)) - 50) / 50.01;
if k2v > 0
{
CountChg = if k1v <= k2v and k1v[1] > k2v[1] and k2v[1] > 0 then -1 else 0;
SOAPCount = CompoundValue(1, Min (0, SOAPCount[1]) + CountChg, 0);
}
else
{
CountChg = if k1v >= k2v and k1v[1] < k2v[1] and k2v[1] <= 0 then 1 else 0;
SOAPCount = CompoundValue (1, Max (0, SOAPCount[1]) + CountChg, 0);
}
def fish1 = CompoundValue(1, 0.5 * (Log((1 + k1v) / (1 - k1v)) + fish1[1]), 0);
def fish2 = CompoundValue(1, 0.5 * (Log((1 + k2v) / (1 - k2v)) + fish2[1]), 0);
def fish3 = CompoundValue(1, 0.5 * (Log((1 + k3v) / (1 - k3v)) + fish3[1]), 0);
def fish4 = CompoundValue(1, 0.5 * (Log((1 + R1v) / (1 - R1v)) + fish4[1]), 0);
def BPvalue = if BPmaxHigh - BPminLow == 0
then 0
else 0.66 * ((close - minLow) / (maxHigh - minLow) - 0.5) + 0.67 * value[1];
def BPtruncValue = if BPvalue > 0.99
then 0.999
else if BPvalue < -0.99
then -0.999
else BPvalue;
def BPfish = 0.5 * (Log((1 + BPtruncValue) / (1 - BPtruncValue)) + fish[1]);
#
### END: FisherTransformer Initialization: Stochastic and SOAP
#
### START:(2a) Fisher Transformer "FS17x5u" (Big Pink Up)is true for trade entry
#
Plot BigPinkup = if Sign (fish3 - fish3[1]) > Sign (fish3[1] - fish3[2]) then FT else Double.NaN;
BigPinkup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BigPinkup.AssignValueColor(Color.pink);
Def BuySignal = if Sign (fish3 - fish3[1]) > Sign (fish3[1] - fish3[2])then 1 else 0;
#
# FisherTransform Trend Up Indicator
#
plot FSTrendIndicatorUp = if FT[-1] > FT and FT < FT[1] then FT else Double.NaN;
FSTrendIndicatorUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
FSTrendIndicatorUp.AssignValueColor(Color.Green);
#
# FisherTransform Trend Down Indicator
#
plot FSTrendIndicatorDown = if FT[-1] < FT and FT > FT[1] then FT else Double.NaN;
FSTrendIndicatorDown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
FSTrendIndicatorDown.AssignValueColor(Color.RED);
#END CODE
1. I wanted to know if the code only initiates the green arrow upon the completion of the NEXT bar.
I see the ftonebarback but am not 100% on the situation.
2. How I can get this to work in a scan and in a watchlist. I have been trying for the scan:
Fisher_Transform(). "FSTrendIndicatorUp" is true
but that yields NO results. If I use the bigpinkup instead, it does catch some symbols, but the pink arrow lags much more than the green arrow. By then the move is underway.
I've tried using a Squeeze indicator for the watchlist and substituting the fisher transform information in, but I get an error saying the function is too complex. So I tried removing the buy zone stuff but then it says that I need to have at least one plot...
Code:
def sqz = !TTM_Squeeze().SqueezeAlert;
def direction = TTM_Squeeze()>TTM_Squeeze()[1];
def count = if sqz and !sqz[1] then 1 else count[1]+1;
def isFired = if !sqz and sqz[1] then 1 else 0;
def firedCount = if isFired then 1 else firedCount[1]+1;
def firedDirection = if isFired then direction else firedDirection[1];
def sumIsFired = sum(isFired,5);
def isFiredDir = sumIsFired && firedDirection;
# look for close buy zone
def ema8 = reference movAvgExponential(length=8);
def ema21 = reference movAvgExponential(length=21);
def currPrice = close();
def highVal = Max(ema8, ema21);
def lowVal = Min(ema8, ema21);
def inBuyZone = currPrice >= lowVal && currPrice <= highVal;
def sqzBuy = sqz && inBuyZone;
def sqzNoBuy = sqz && !inBuyZone;
addLabel(yes, Concat(if sqzBuy then "Buy " else "", if sqz then "" + count else if sumIsFired then “” + firedCount + if firedDirection then ” Long” else ” Short” else “ ”), if sqzBuy then color.black else color.black);
AssignBackgroundColor(if sqzNoBuy then color.red else if sqzBuy then color.cyan else if sumIsFired then color.green else color.black);
I'm kind a lost. If anyone could at least steer me in a helpful direction, I would be very grateful!
This is a picture of the Indicator if this helps
Last edited by a moderator: