HighBredCloud
Well-known member
Can't seem to figure this out...Where would I put this line of code to turn regular StochRSI into MTF?
Last edited by a moderator:
#
# TD Ameritrade IP Company, Inc. (c) 2008-2020
#
declare lower;
input RSI_length = 14;
input over_bought = 80;
input over_sold = 20;
input RSI_average_type = AverageType.WILDERS;
input KPeriod = 14;
input DPeriod = 3;
input slowing_period = 1;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = {default "No", "On FullK", "On FullD", "On FullK & FullD"};
input aggregationPeriod = AggregationPeriod.FIFTEEN_MIN;
def RSI_price = close(period = aggregationPeriod);
def RSI = RSI(price = RSI_price, length = RSI_length, averageType = RSI_average_type);
plot FullK = StochasticFull(over_bought, over_sold, KPeriod, DPeriod, RSI, RSI, RSI, slowing_period, averageType).FullK;
plot FullD = StochasticFull(over_bought, over_sold, KPeriod, DPeriod, RSI, RSI, RSI, slowing_period, averageType).FullD;
plot OverBought = over_bought;
plot OverSold = over_sold;
def upK = FullK crosses above OverSold;
def upD = FullD crosses above OverSold;
def downK = FullK crosses below OverBought;
def downD = FullD crosses below OverBought;
plot UpSignal;
plot DownSignal;
switch (showBreakoutSignals) {
case "No":
UpSignal = Double.NaN;
DownSignal = Double.NaN;
case "On FullK":
UpSignal = if upK then OverSold else Double.NaN;
DownSignal = if downK then OverBought else Double.NaN;
case "On FullD":
UpSignal = if upD then OverSold else Double.NaN;
DownSignal = if downD then OverBought else Double.NaN;
case "On FullK & FullD":
UpSignal = if upK or upD then OverSold else Double.NaN;
DownSignal = if downK or downD then OverBought else Double.NaN;
}
UpSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
DownSignal.setHiding(showBreakoutSignals == showBreakoutSignals."No");
FullK.SetDefaultColor(GetColor(5));
FullD.SetDefaultColor(GetColor(0));
OverBought.SetDefaultColor(GetColor(1));
OverSold.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
def CountChg;
def SOAPCount;
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);
plot BigPinkup = if Sign (fish3 - fish3[1]) > Sign (fish3[1] - fish3[2]) then fish else Double.NaN;
BigPinkup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BigPinkup.AssignValueColor(Color.PINK);
declare upper;
#### Fisher Transform Inputs
input length = 10;
input volumeFastLength = 1;
input volumeSlowLength = 20;
input volumeOscThreshold = 0.5;
###################### Calculate Fisher Transform ###########################################
def maxHigh;
def minLow;
def range;
def value;
def truncValue;
def fish;
def FTUpArrow;
def FTDownArrow;
def FTOneBarBack;
maxHigh = Highest(hl2(), length);
minLow = Lowest(hl2(), length);
range = maxHigh - minLow;
value = if IsNaN(hl2()) then Double.NaN else if IsNaN(range)
then value[1] else if range == 0 then 0 else 0.66 * ((hl2() - minLow) / range - 0.5) + 0.67 * value[1];
truncValue = if value > 0.99 then 0.999 else if value < -0.99 then -0.999 else value;
fish = 0.5 * (Log((1 + truncValue) / (1 - truncValue)) + fish[1]);
FTOneBarBack = fish[1];
FTUpArrow = if (fish[1] < FTOneBarBack[1]) and (fish > FTOneBarBack) then 1 else
Double.NaN;
FTDownArrow = if (fish[1] > FTOneBarBack[1]) and (fish < FTOneBarBack) then 1 else
Double.NaN;
# Signal - Plot if FT has crossed above FTOneBarBack and CCI is greater than previous CCI
#plot FSTrendIndicatorUp = if FT[-1] > FT and FT < FT[1] then FT else Double.NaN;
plot fishUPCCIUp = if fish[-1] > fish and fish < fish[1] then fish else Double.NaN;
fishUPCCIUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
fishUPCCIUp.AssignValueColor(Color.GREEN);
plot fishDownCCIDown = if fish[-1] < fish and fish > fish[1] then fish else Double.NaN;
fishDownCCIDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
fishDownCCIDown.AssignValueColor(Color.RED);
##### SECOND RED ####################
def CountChg;
def SOAPCount;
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);
plot BigPinkup = if Sign (fish3 - fish3[1]) > Sign (fish3[1] - fish3[2]) then fish else Double.NaN;
BigPinkup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BigPinkup.AssignValueColor(Color.PINK);
plot BigPinkup = if Sign (fish3 - fish3[1]) > Sign (fish3[1] - fish3[2]) then fish else Double.NaN;
BigPinkup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BigPinkup.AssignValueColor(Color.PINK)
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.