Kairi Relative Index Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
The Kairi Relative Index is a metric that traders use to to time their purchases of a stock, or to understand trends in the stock market.

A momentum oscillator measures the strength of the up or down movement of price instead of the actual price level. The harder and faster a tradable's price falls, the bigger the oscillator move. The same goes for an upward move. Once the price move slows down, so does the momentum oscillator.

RlRvltF.png


thinkScript Code

Code:
# Kairi Relative Index Leading Indicator
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/2viDaDnF-Kairi-Relative-Index/

declare lower;

input length = 100;
input src = close;

def sma = simpleMovingAvg(src, length);
def kri = 100 * (src - sma) / sma;

plot ZeroLine = 0;
plot line = kri;

line.AssignValueColor(if kri > 0 then color.green else color.red);

A few resources to help you understand more about this indicator:
 
@diazlaz Mind sharing this PNL study you are using? I just started playing with backtesting with strategies and find the default PNL study solely lacking
 
Here you go @skynetgen:

Ruby:
#FloatFLLine - Updated P&L to include additional stats label.
#Original TD Ameritrade - FloatingPL
#Updated 2019.10.20 - diazlaz - Additional Stats Label
#                             - Incorporated Nube's and JQ's BnH Logic
#

declare lower;

input ProfileLine = 1200;
input TradeSize = 1000;
input TradeAmount = 100000;
input useTradeAmount = no;
input ProfileDesc = "T";
input ShowShareCount = No;

AddLabel(yes, ProfileDesc, COLOR.ORANGE);

def TradeSize2 = CompoundValue(1, Round(TradeAmount / close, 0), 0);
AddLabel(ShowShareCount, "Number Of Shares: " +  if useTradeAmount then astext(TradeSize2) else astext(TradeSize) + " at " + AsText(close), Color.WHITE);

plot FPL = FPL();
plot ZeroLine = 0;

plot TargetLine = ProfileLine;
TargetLine.SetDefaultColor(Color.YELLOW);
TargetLine.SetLineWeight(3);

FPL.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
FPL.DefineColor("Positive and Up", Color.GREEN);
FPL.DefineColor("Positive and Down", Color.DARK_GREEN);
FPL.DefineColor("Negative and Down", Color.RED);
FPL.DefineColor("Negative and Up", Color.DARK_RED);
FPL.AssignValueColor(if FPL >= 0 then if FPL > FPL[1] then FPL.Color("Positive and Up") else FPL.Color("Positive and Down") else if FPL < FPL[1] then FPL.Color("Negative and Down") else FPL.Color("Negative and Up"));
ZeroLine.SetDefaultColor(Color.GRAY);

def ProfitState = CompoundValue(1, if FPL >= ProfileLine then 1 else ProfitState[1], 0);
def ProfitCount = CompoundValue(1, if FPL >= ProfileLine then ProfitCount[1] + 1 else ProfitCount[1], 0);
plot pLongBuy = (ProfitState[1] != ProfitState);
pLongBuy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
pLongBuy.SetDefaultColor(Color.WHITE);
pLongBuy.SetLineWeight(5);

def BnH = close - First(open);
def returnColor = if BnH crosses above BnH[1] then 1 else
                  if BnH crosses below BnH[1] then 0 else returnColor[1];
def BHPnL = TickValue() * (1 / TickSize()) * BnH;


AddLabel (yes, "Profit Touch: " + ProfitCount, Color.YELLOW);
AddLabel (yes, "P&L: " + AsDollars(FPL),
if FPL >= 0 then if FPL > FPL[1] then FPL.Color("Positive and Up") else FPL.Color("Positive and Down") else if FPL < FPL[1] then FPL.Color("Negative and Down") else FPL.Color("Negative and Up"));


AddLabel (yes, "%: " + AsPercent(FPL / TradeAmount), Color.CYAN);
AddLabel (yes, "Low: " + LowestAll(FPL), Color.Pink);
AddLabel (yes, "Max: " + HighestAll(FPL), Color.Lime);
AddLabel (yes, "Buy and Hold PL: " + AsDollars(BHPnL * TradeSize), Color.Gray);
AddLabel (yes, "BH%: " + AsPercent(BHPnL / TradeAmount), Color.Gray);

#end of FloatFLLine
 
What is beautiful about this concept is, BNF used similar strategy to make over $400 Million starting with just $6k or so. Who knows how many times he blew up, if he did, if its all true. But, this explains the concept of moving averages and their deviations from the mean.
 
What is beautiful about this concept is, BNF used similar strategy to make over $400 Million starting with just $6k or so. Who knows how many times he blew up, if he did, if its all true. But, this explains the concept of moving averages and their deviations from the mean.
If someone made this much from one technical indicator it would never go public. If it did that means the indicator is no longer that reliable and has lost its accuracy. Indicators lose their relevance once more people start to use them. There's a study that back tested many popular indicators and all of them performed below the buy and hold strategy meaning they give no edge. The only proven edge you can have with any indicator is finding its optimal parameters which is backed up by a study which tested the default setting of the MACD and the optimal parameters. The 2nd one outperformed the market.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
374 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top