RSI IFT (Inverse Fisher Transform)

cos251

Well-known member
Sharing this version of the RSI Inverse Fisher Transform - Inverse of arctanh(x). If this was previously posted, my apologies. I searched and did not find a copy other than the one I shared to be included on a different indicator.

This RSI IFT gives buy and sell signals (although the sell signals are a little late). This can be used stand alone or with other indicators to add additional confirmation in either direction.

Of course, feel free to modify as you wish.

KMnErKV.png


Quick Notes
  1. Calculation is based on 5 period RSI then an average
  2. Candle color option is included and takes into account if instrument is in a squeeze or not
    1. On/off setting
Reference Material
https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
https://www.mql5.com/en/articles/303


Code:
# RSI_IFT (smoothed Inverse Fisher Transform RSI)
# Change Log
# 2021.01.29    v1.0    @cos251    -    Intial Script; takes smoothed 5 period RSI and puts it #                                       through Inverse arctanh(x) forumla
#
#CREDITS
# - https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
# - https://www.mql5.com/en/articles/303

declare lower;

#--- Inputs
input length = 5;
def over_Bought = .5;
def over_Sold = -.5;
input paintbars = no;
input showVerticalLines = yes;
#--- End Inputs


#--- RSI and Smoothed Inverse RSI Calculation
def R = reference RSI(length, close) - 50;
def AvgRSI = MovingAverage(AverageType.Exponential,R,9);
def iRSI = (Power(Double.E, 2 * AvgRSI) - 1) / (Power(Double.E, 2 * AvgRSI) + 1);
plot Inverse_RSI = iRSI;
#AddLabel(yes,iRSI);
Inverse_RSI.SetDefaultColor(Color.DARK_GRAY);
Inverse_RSI.AssignValueColor(if Inverse_RSI > .5 then Color.GREEN else if Inverse_RSI < -.5 then Color.RED else Color.Current);
#--- End RSI and Smoothed Calculation


#--- OB/OS
plot ob = over_Bought;
plot os = over_Sold;
ob.SetDefaultColor(Color.DARK_GRAY);
os.SetDefaultColor(Color.DARK_GRAY);
#--- End OB/OS

#--- Add VerticalLine
def sqzAlert = reference TTM_Squeeze().SqueezeAlert; #Hint -Used for candle price color
AddVerticalLine(showVerticalLines and (iRSI > 0) and (iRSI[1] < 0), "Entry BUY", Color.GRAY);
AddVerticalLine(showVerticalLines and (iRSI[1] > 0) and (iRSI < 0), "Entry SELL", Color.YELLOW);
AssignPriceColor(if paintbars and iRSI > 0 and sqzAlert == 1 then Color.GREEN else if paintbars and iRSI < 0 and sqzAlert == 1 then Color.RED else if paintbars and sqzAlert == 0 then Color.GRAY else Color.Current);



UPDATE!!!!!!!!!!
Upper Strategy Indicator v1.0

Per request - here is a strategy version of the RSI_IFT. I've included the following
  1. Selection between
    1. Long trade
    2. Short trade
  2. Price bar color per trade selection
    1. Green for long or both
    2. Red for short or both
  3. Vertical Lines for RSI_IFT Signal for visual effect

Please remember to save as a strategy and not study!

Thx!

O7Tc812.jpg


Ruby:
# RSI_IFT_Strat (smoothed Inverse Fisher Transform RSI)
# Change Log
# 2021.08.20    v1.0    @cos251    -    Intial Script; takes smoothed 5 period RSI and puts it #
#                                       through Inverse arctanh(x) forumla; converted to strategy for
#                                       back testing purposes
#
# Removing the header credits and description is not permitted, any modification needs to be shared.
#
#CREDITS
# - https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
# - https://www.mql5.com/en/articles/303

declare upper;

#--- Inputs
input length = 5;
input tradetype = { default "long", "short", "both" };
input paintbars = yes;
input showVerticalLines = yes;
#--- End Inputs


#--- RSI and Smoothed Inverse RSI Calculation
def R = reference RSI(length, close) - 50;
def AvgRSI = MovingAverage(AverageType.Exponential,R,9);
def iRSI = (Power(Double.E, 2 * AvgRSI) - 1) / (Power(Double.E, 2 * AvgRSI) + 1);
def Inverse_RSI = iRSI;
#--- End RSI and Smoothed Calculation

#--- Add VerticalLine
def sqzAlert = reference TTM_Squeeze().SqueezeAlert; #Hint -Used for candle price color
# and sqzAlert == 1
AddVerticalLine(showVerticalLines and (tradetype == tradetype.long or tradetype == tradetype.both) and (iRSI > 0) and (iRSI[1] < 0), "Entry BUY", Color.GRAY);
AddVerticalLine(showVerticalLines and (tradetype == tradetype.short or tradetype == tradetype.both) and (iRSI[1] > 0) and (iRSI < 0), "Entry SELL", Color.YELLOW);
AssignPriceColor(if paintbars and (tradetype == tradetype.long or tradetype == tradetype.both) and iRSI > 0  then Color.GREEN else if paintbars and (tradetype == tradetype.short or tradetype == tradetype.both) and iRSI < 0 then Color.RED else if paintbars  then Color.GRAY else Color.Current);


AddOrder(OrderType.BUY_TO_OPEN, iRSI > 0 and iRSI[1] < 0 and (tradetype == tradetype.long or tradetype == tradetype.both), open, tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "LONG");
AddOrder(OrderType.SELL_TO_CLOSE, iRSI < 0 and iRSI[1] > 0 and (tradetype == tradetype.long or tradetype == tradetype.both),open, tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "LONG_EXIT");

AddOrder(OrderType.SELL_TO_OPEN,iRSI < 0 and iRSI[1] > 0 and (tradetype == tradetype.short or tradetype == tradetype.both),open, tickcolor = GetColor(8), arrowcolor = GetColor(8), name = "SHORT" );
AddOrder(OrderType.BUY_TO_CLOSE, iRSI > 0 and iRSI[1] < 0 and (tradetype == tradetype.short or tradetype == tradetype.both),open, tickcolor = GetColor(8), arrowcolor = GetColor(8), name = "SHORT_EXIT");
 
Last edited:

horserider

Well-known member
VIP
Had this from long ago. Just a different presentation. Cross zero or color change for signals. Red/green OS/OB
Code:
declare lower;

def e = 2.318281828;
input length = 10;
def overbought = 0.7;
def oversold = -0.7;

def diff = if close > close[1] then close - close[1] else 0;
def diff2 = if close < close[1] then close[1] - close else 0;

rec avg = compoundValue(1, 2 / (length + 1) * diff + (length - 1) / (length + 1) * avg[1], diff * 2 / (length + 1));
rec avg2 = compoundValue(1, 2 / (length + 1) * diff2 + (length - 1) / (length + 1) * avg2[1], diff2 * 2 / (length + 1));

def value = if avg2 != 0 then 100 - 100 / (1 + avg / avg2) else 0;
def Value1 = 0.1 * (value - 50);
def Value2 = wma(Value1, 9);
def IFish = (Power(e, (2 * Value2)) - 1) / (Power(e, (2 * Value2)) + 1 );

plot plot2 = 0.7;
plot plot3 = -0.7;
plot zero = 0;

Plot plot1 = IFish;
plot1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
plot1.SetLineWeight(2);
#plot1.DefineColor("Up", Color.UPTICK);
#plot1.DefineColor("Down", Color.DOWNTICK);
#plot1.AssignValueColor(if plot1 > plot1[1] then plot1.color("Up") else if plot1 < plot1[1] then #plot1.color("Down") else GetColor(1));

plot1.DefineColor("OverBought", Color.dark_green);
plot1.DefineColor("Normalpos", Color.dark_orange);
plot1.DefineColor("Normalneg", Color.dark_orange);
plot1.DefineColor("OverSold", Color.dark_red);
plot1.AssignValueColor(if plot1 > overBought then plot1.color("OverBought") else if plot1 < overSold then plot1.color("OverSold") else if plot1 < 0.5 then plot1.color("Normalneg") else plot1.color("Normalpos"));
 

s1111

Active member
Very nice touch, I like the adjustment. Makes for a safer signal and helps align with other indicators.
I saw tsla got sell signal at 5:58 am "west coast time" premarket and buy signal at 8:54am . Wow I would have been " I'm Rich Bitch" day lol.
 

cos251

Well-known member
Had this from long ago. Just a different presentation. Cross zero or color change for signals. Red/green OS/OB
Code:
declare lower;

def e = 2.318281828;
input length = 10;
def overbought = 0.7;
def oversold = -0.7;

def diff = if close > close[1] then close - close[1] else 0;
def diff2 = if close < close[1] then close[1] - close else 0;

rec avg = compoundValue(1, 2 / (length + 1) * diff + (length - 1) / (length + 1) * avg[1], diff * 2 / (length + 1));
rec avg2 = compoundValue(1, 2 / (length + 1) * diff2 + (length - 1) / (length + 1) * avg2[1], diff2 * 2 / (length + 1));

def value = if avg2 != 0 then 100 - 100 / (1 + avg / avg2) else 0;
def Value1 = 0.1 * (value - 50);
def Value2 = wma(Value1, 9);
def IFish = (Power(e, (2 * Value2)) - 1) / (Power(e, (2 * Value2)) + 1 );

plot plot2 = 0.7;
plot plot3 = -0.7;
plot zero = 0;

Plot plot1 = IFish;
plot1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
plot1.SetLineWeight(2);
#plot1.DefineColor("Up", Color.UPTICK);
#plot1.DefineColor("Down", Color.DOWNTICK);
#plot1.AssignValueColor(if plot1 > plot1[1] then plot1.color("Up") else if plot1 < plot1[1] then #plot1.color("Down") else GetColor(1));

plot1.DefineColor("OverBought", Color.dark_green);
plot1.DefineColor("Normalpos", Color.dark_orange);
plot1.DefineColor("Normalneg", Color.dark_orange);
plot1.DefineColor("OverSold", Color.dark_red);
plot1.AssignValueColor(if plot1 > overBought then plot1.color("OverBought") else if plot1 < overSold then plot1.color("OverSold") else if plot1 < 0.5 then plot1.color("Normalneg") else plot1.color("Normalpos"));
Thanks for sharing @horserider. This provides good anticipation to change in direction.
 

QUIKTDR1

Member
VIP
Sharing this version of the RSI Inverse Fisher Transform - Inverse of arctanh(x). If this was previously posted, my apologies. I searched and did not find a copy other than the one I shared to be included on a different indicator.

This RSI IFT gives buy and sell signals (although the sell signals are a little late). This can be used stand alone or with other indicators to add additional confirmation in either direction.

Of course, feel free to modify as you wish.

KMnErKV.png


Quick Notes
  1. Calculation is based on 5 period RSI then an average
  2. Candle color option is included and takes into account if instrument is in a squeeze or not
    1. On/off setting
Reference Material
https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
https://www.mql5.com/en/articles/303


Code:
# RSI_IFT (smoothed Inverse Fisher Transform RSI)
# Change Log
# 2021.01.29    v1.0    @cos251    -    Intial Script; takes smoothed 5 period RSI and puts it #                                       through Inverse arctanh(x) forumla
#
#CREDITS
# - https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
# - https://www.mql5.com/en/articles/303

declare lower;

#--- Inputs
input length = 5;
def over_Bought = .5;
def over_Sold = -.5;
input paintbars = no;
input showVerticalLines = yes;
#--- End Inputs


#--- RSI and Smoothed Inverse RSI Calculation
def R = reference RSI(length, close) - 50;
def AvgRSI = MovingAverage(AverageType.Exponential,R,9);
def iRSI = (Power(Double.E, 2 * AvgRSI) - 1) / (Power(Double.E, 2 * AvgRSI) + 1);
plot Inverse_RSI = iRSI;
#AddLabel(yes,iRSI);
Inverse_RSI.SetDefaultColor(Color.DARK_GRAY);
Inverse_RSI.AssignValueColor(if Inverse_RSI > .5 then Color.GREEN else if Inverse_RSI < -.5 then Color.RED else Color.Current);
#--- End RSI and Smoothed Calculation


#--- OB/OS
plot ob = over_Bought;
plot os = over_Sold;
ob.SetDefaultColor(Color.DARK_GRAY);
os.SetDefaultColor(Color.DARK_GRAY);
#--- End OB/OS

#--- Add VerticalLine
def sqzAlert = reference TTM_Squeeze().SqueezeAlert; #Hint -Used for candle price color
AddVerticalLine(showVerticalLines and (iRSI > 0) and (iRSI[1] < 0), "Entry BUY", Color.GRAY);
AddVerticalLine(showVerticalLines and (iRSI[1] > 0) and (iRSI < 0), "Entry SELL", Color.YELLOW);
AssignPriceColor(if paintbars and iRSI > 0 and sqzAlert == 1 then Color.GREEN else if paintbars and iRSI < 0 and sqzAlert == 1 then Color.RED else if paintbars and sqzAlert == 0 then Color.GRAY else Color.Current);
Very interesting! How do you add a P&L report to this in order to backtest strategy?
Thank you in advance!
 

QUIKTDR1

Member
VIP
Very interesting! How do you add a P&L report to this in order to backtest strategy?
Thank you in advance!
I added this
AddOrder(OrderType.BUY_AUTO, inverseRSI[1] < 0 );
AddOrder(OrderType.Sell_AUTO, ); (inverseRSI[1] > 0) ;

to end of strategy in order to generate a P &L report but no go ! Any ideas on how to correct will be appreciated.
 

cos251

Well-known member
The lines of code you added will add the basic components of the P&L. It will produce the buy/sell signals, initiate a trade (on chart only that is) and close the trade based on your conditions. Then what you do is right click the buy or sell order and select Show Report (I think that is what it is called). And it will show you a report of the mock, back tested trades. YOu can also add the default P&L indicator to the lower chart area.
 

QUIKTDR1

Member
VIP
The lines of code you added will add the basic components of the P&L. It will produce the buy/sell signals, initiate a trade (on chart only that is) and close the trade based on your conditions. Then what you do is right click the buy or sell order and select Show Report (I think that is what it is called). And it will show you a report of the mock, back tested trades. YOu can also add the default P&L indicator to the lower chart area.
when I add those lines of code to strategy it deletes the signal from chart even though I mirrored the instructions, as well as moving code to strategy section. Any ideas?

Thank you in advance!
 

Gymini

New member
Sharing this version of the RSI Inverse Fisher Transform - Inverse of arctanh(x). If this was previously posted, my apologies. I searched and did not find a copy other than the one I shared to be included on a different indicator.

This RSI IFT gives buy and sell signals (although the sell signals are a little late). This can be used stand alone or with other indicators to add additional confirmation in either direction.

Of course, feel free to modify as you wish.

KMnErKV.png


Quick Notes
  1. Calculation is based on 5 period RSI then an average
  2. Candle color option is included and takes into account if instrument is in a squeeze or not
    1. On/off setting
Reference Material
https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
https://www.mql5.com/en/articles/303


Code:
# RSI_IFT (smoothed Inverse Fisher Transform RSI)
# Change Log
# 2021.01.29    v1.0    @cos251    -    Intial Script; takes smoothed 5 period RSI and puts it #                                       through Inverse arctanh(x) forumla
#
#CREDITS
# - https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
# - https://www.mql5.com/en/articles/303

declare lower;

#--- Inputs
input length = 5;
def over_Bought = .5;
def over_Sold = -.5;
input paintbars = no;
input showVerticalLines = yes;
#--- End Inputs


#--- RSI and Smoothed Inverse RSI Calculation
def R = reference RSI(length, close) - 50;
def AvgRSI = MovingAverage(AverageType.Exponential,R,9);
def iRSI = (Power(Double.E, 2 * AvgRSI) - 1) / (Power(Double.E, 2 * AvgRSI) + 1);
plot Inverse_RSI = iRSI;
#AddLabel(yes,iRSI);
Inverse_RSI.SetDefaultColor(Color.DARK_GRAY);
Inverse_RSI.AssignValueColor(if Inverse_RSI > .5 then Color.GREEN else if Inverse_RSI < -.5 then Color.RED else Color.Current);
#--- End RSI and Smoothed Calculation


#--- OB/OS
plot ob = over_Bought;
plot os = over_Sold;
ob.SetDefaultColor(Color.DARK_GRAY);
os.SetDefaultColor(Color.DARK_GRAY);
#--- End OB/OS

#--- Add VerticalLine
def sqzAlert = reference TTM_Squeeze().SqueezeAlert; #Hint -Used for candle price color
AddVerticalLine(showVerticalLines and (iRSI > 0) and (iRSI[1] < 0), "Entry BUY", Color.GRAY);
AddVerticalLine(showVerticalLines and (iRSI[1] > 0) and (iRSI < 0), "Entry SELL", Color.YELLOW);
AssignPriceColor(if paintbars and iRSI > 0 and sqzAlert == 1 then Color.GREEN else if paintbars and iRSI < 0 and sqzAlert == 1 then Color.RED else if paintbars and sqzAlert == 0 then Color.GRAY else Color.Current);



UPDATE!!!!!!!!!!
Upper Strategy Indicator v1.0

Per request - here is a strategy version of the RSI_IFT. I've included the following
  1. Selection between
    1. Long trade
    2. Short trade
  2. Price bar color per trade selection
    1. Green for long or both
    2. Red for short or both
  3. Vertical Lines for RSI_IFT Signal for visual effect
Thx!

O7Tc812.jpg


Ruby:
# RSI_IFT_Strat (smoothed Inverse Fisher Transform RSI)
# Change Log
# 2021.08.20    v1.0    @cos251    -    Intial Script; takes smoothed 5 period RSI and puts it #
#                                       through Inverse arctanh(x) forumla; converted to strategy for
#                                       back testing purposes
#
# Removing the header credits and description is not permitted, any modification needs to be shared.
#
#CREDITS
# - https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
# - https://www.mql5.com/en/articles/303

declare upper;

#--- Inputs
input length = 5;
input tradetype = { default "long", "short", "both" };
input paintbars = yes;
input showVerticalLines = yes;
#--- End Inputs


#--- RSI and Smoothed Inverse RSI Calculation
def R = reference RSI(length, close) - 50;
def AvgRSI = MovingAverage(AverageType.Exponential,R,9);
def iRSI = (Power(Double.E, 2 * AvgRSI) - 1) / (Power(Double.E, 2 * AvgRSI) + 1);
def Inverse_RSI = iRSI;
#--- End RSI and Smoothed Calculation

#--- Add VerticalLine
def sqzAlert = reference TTM_Squeeze().SqueezeAlert; #Hint -Used for candle price color
# and sqzAlert == 1
AddVerticalLine(showVerticalLines and (tradetype == tradetype.long or tradetype == tradetype.both) and (iRSI > 0) and (iRSI[1] < 0), "Entry BUY", Color.GRAY);
AddVerticalLine(showVerticalLines and (tradetype == tradetype.short or tradetype == tradetype.both) and (iRSI[1] > 0) and (iRSI < 0), "Entry SELL", Color.YELLOW);
AssignPriceColor(if paintbars and (tradetype == tradetype.long or tradetype == tradetype.both) and iRSI > 0  then Color.GREEN else if paintbars and (tradetype == tradetype.short or tradetype == tradetype.both) and iRSI < 0 then Color.RED else if paintbars  then Color.GRAY else Color.Current);


AddOrder(OrderType.BUY_TO_OPEN, iRSI > 0 and iRSI[1] < 0 and (tradetype == tradetype.long or tradetype == tradetype.both), open, tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "LONG");
AddOrder(OrderType.SELL_TO_CLOSE, iRSI < 0 and iRSI[1] > 0 and (tradetype == tradetype.long or tradetype == tradetype.both),open, tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "LONG_EXIT");

AddOrder(OrderType.SELL_TO_OPEN,iRSI < 0 and iRSI[1] > 0 and (tradetype == tradetype.short or tradetype == tradetype.both),open, tickcolor = GetColor(8), arrowcolor = GetColor(8), name = "SHORT" );
AddOrder(OrderType.BUY_TO_CLOSE, iRSI > 0 and iRSI[1] < 0 and (tradetype == tradetype.short or tradetype == tradetype.both),open, tickcolor = GetColor(8), arrowcolor = GetColor(8), name = "SHORT_EXIT");
Hey thx for this! Also i like the way you have volume setup in the first pic- care to share code?
 

cos251

Well-known member
The volume color coding to match the candles is a result of the AssignPriceColor function in the first indicator. It will color the volume bars by default.
 

Longlifelearner

New member
VIP
good morning
i am new here.
can you help me with the upper chart
UPDATE!!!!!!!!!!
Upper Strategy Indicator v1.0
some how i cant put it on but on the let corner it said the strategy is applied but other than that i dont see anything else.

no line, not anything.

but your lower study works great.

thanks
 

s1111

Active member
good morning
i am new here.
can you help me with the upper chart
UPDATE!!!!!!!!!!
Upper Strategy Indicator v1.0
some how i cant put it on but on the let corner it said the strategy is applied but other than that i dont see anything else.

no line, not anything.

but your lower study works great.

thanks

When you create strategy you have to save it as strategy and not study.
Instead of study click the middle button which says strategy. Then click create and save your script . Hope this helps
 

MerryDay

Administrative
Staff member
Staff
VIP
@Superfast The code does not indicate anything that would cause repainting.
Be aware that the delay in the signal of loss of momentum, while not unusual in this type of indicator, does tend to give back profits which can be significant in a volatile market and result in a loss. No indicator should be used in isolation.
 
Last edited:

Similar threads

Top