How to convert StochRSI into MTF StochRSI?

HighBredCloud

Well-known member
VIP
Can't seem to figure this out...Where would I put this line of code to turn regular StochRSI into MTF?

(period = aggregationPeriod)

Thanks in advance...

Code:
#
# 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 RSI_price = close;
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 = 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);
 
The "input RSI_price = close" try changing that to a "def RSI_price = close". The close doesn't seem to like be an input.

Code:
#
# 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);
 

MerryDay

Administrative
Staff member
Staff
VIP
@stocksniper
I set up your SVEStochRSI Watchlist but I didn't bother to do this one because a scan didn't find any stocks
that had these up or down arrows so there isn't anything to watch?

If you still want it, you can set it up, yourself, using the SVEStochRSI watchlist as your example.
The StochRSI is the exact same just replace the 'SVEStochRSI ' with 'StochRSI' .
 
Last edited:

drdDavi

New member
Hey Guys, can someone here help me with some code. I am trying to add some arrows in TOS however they are forming at the bottom of the chart. would really appreciate it.

Code:
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);
 

drdDavi

New member
@BenTen see the complete code below.

Rich (BB code):
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);
 

rad14733

Well-known member
VIP
@drdDavi The code you posted is working as expected for me...

TwEkZvi.png
 

drdDavi

New member
Actually got it to work, by changing "fish" to "low"

How could I get this code working for down arrows? Just the snippet below

Rich (BB code):
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)
 

Similar threads

Top