Logistic RSI STOCH ROC AO [DGT] For ThinkOrSwim

Author states: Experimental attempt of applying Logistic Map Equation for some of widely used indicators.
With this study "Awesome Oscillator (AO)", "Rate of Change (ROC)", "Relative Strength Index (RSI)", "Stochastic (STOCH)" and a custom interpretation of Logistic Map Equation is presented

Calculations with Logistic Map Equation makes sense when the calculated results are iterated many times within the same equation.

Here is the Logistic Map Equation : Xn+1 = r * Xn * (1 - Xn)

Where, the value of r is the key for this equation which changes amazingly the behaviour of the Logistic Map.

The value we have assigned for r is less then 1 and greater than 0 ( 0 < r < 1) with many iterations.

Complete explanation and the original Tradingview code:
https://www.tradingview.com/script/NioHIxY1-Logistic-RSI-STOCH-ROC-AO-by-DGT/
The new ToS code can be found in the next post.

BAN2i7m.png
 
Last edited by a moderator:

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

Greetings,

Would love it if someone could port this lovely indicator into Thinkorswim.

Logistic-RSI-STOCH-ROC-AO [DGT]
https://www.tradingview.com/script/NioHIxY1-Logistic-RSI-STOCH-ROC-AO-by-DGT/


Thank you!
check the below:

CSS:
# Indicator for TOS
#//# * Reference   : https://www.tradingview.com/script/jUuBT0bO-Logistic-EMA-w-Signals-by-DGT/
#study("Logistic RSI, STOCH, ROC, AO, ... by DGT", "LOGISTIC ?? DGT ??", max_labels_count = 500)//, resolution="")
# Converted by Sam4Cok@Samer800    - 09/2024

declare lower;
input showPlot   = {"Standart Deviation Line Alone",Default "Indicator Alone", "Indicator & Std Dev."};
input SelectIndicator = {"Awesome Oscillator (AO)", default "Logistic Dominance", "Rate of Change (ROC)", "Relative Strength Index (RSI)", "Stochastic (STOCH)"};    # "Select Indicator"
input source     = close;                        # "Source"
input LogisticMapLength = 13;                    # "Logistic Map Length"
input LogisticDominanceLength = 5;               # "Length : Logistic Dominance"
input RateOfChangeLength      = 9;               # "Length : Rate of Change (ROC)"
input rsiLength        = 14;# "Length : Relative Strength Index (RSI)"
input StochasticLength = 14;# "Length : Stochastic (STOCH)"


def na = Double.NaN;
def last = isNaN(close);
def lenLD = LogisticDominanceLength;
def lenROC = RateOfChangeLength;
#-- Colode
DefineGlobalColor("up", Color.DARK_GREEN); #CreateColor(76, 175,80));
DefineGlobalColor("dn", Color.DARK_RED); #CreateColor(255, 82,82));
# stoch(source, high, low, length) =>
script stoch {
    input src = close;
    input h = high;
    input l = low;
    input len = 14;
    def hh = Highest(h, len);
    def ll = Lowest(l, len);
    def c1 = src - ll;
    def c2 = hh - ll;
    def stoch = if c2 != 0 then c1 / c2 * 100 else 0;
    plot return = stoch;
}
#f_logmap(_s, _r, _l)
script f_logmap {
    input _s = close;
    input _r = 1;
    input _l = 14;
    def hh = Highest(high, _l);
    def f_logmap = _r * _s / hh * (1 - _s / hh);
    plot out = f_logmap;
}
Script f_map {
input mapeq = close;
input _r = close;
input i = 1;
    def lmap = _r * AbsValue(mapeq[i]) * (1 - mapeq[i]);
    plot out = if isNaN(lmap) then 0 else lmap * 100000000;
    }
def r;
Switch (SelectIndicator) {
Case "Awesome Oscillator (AO)": r = Average(hl2, 5) / Average(hl2, 34) - 1;
Case "Logistic Dominance":      r = -f_logmap(-source, (source - source[lenLD]) / source[lenLD], lenLD)
                                    -f_logmap(source, (source - source[lenLD]) / source[lenLD], lenLD);
Case "Rate of Change (ROC)":    r = (source - source[lenROC]) / source[lenROC];
Case "Relative Strength Index (RSI)": r = rsi(Price = source,Length = rsiLength) / 100 - .5;
Case "Stochastic (STOCH)":     r = stoch(source, high, low, StochasticLength) / 100 - .5;
}

def mapeq = f_logmap(source, r, LogisticMapLength);
def val0  = f_map(mapeq, r, 29);
def val1  = f_map(mapeq, r, 0);
def val2  = f_map(mapeq, r, 1);
def val3  = f_map(mapeq, r, 2);
def val4  = f_map(mapeq, r, 3);
def val5  = f_map(mapeq, r, 4);
def val6  = f_map(mapeq, r, 5);
def val7  = f_map(mapeq, r, 6);
def val8  = f_map(mapeq, r, 7);
def val9  = f_map(mapeq, r, 8);
def val10 = f_map(mapeq, r, 9);
def val11 = f_map(mapeq, r, 10);
def val12 = f_map(mapeq, r, 11);
def val13 = f_map(mapeq, r, 12);
def val14 = f_map(mapeq, r, 13);
def val15 = f_map(mapeq, r, 14);
def val16 = f_map(mapeq, r, 15);
def val17 = f_map(mapeq, r, 16);
def val18 = f_map(mapeq, r, 17);
def val19 = f_map(mapeq, r, 18);
def val20 = f_map(mapeq, r, 19);
def val21 = f_map(mapeq, r, 20);
def val22 = f_map(mapeq, r, 21);
def val23 = f_map(mapeq, r, 22);
def val24 = f_map(mapeq, r, 23);
def val25 = f_map(mapeq, r, 24);
def val26 = f_map(mapeq, r, 25);
def val27 = f_map(mapeq, r, 26);
def val28 = f_map(mapeq, r, 27);
def val29 = f_map(mapeq, r, 28);

def valSum = val1 + val2 + val3 + val4 + val5 + val6 + val7 + val8 + val9 + val10 +
             val11 + val12 + val13 + val14 + val15 + val16 + val17 + val18 + val19 + val20 +
             val21 + val22 + val23 + val24 + val25 + val26 + val27 + val28 + val29;
def valSqr = Sqr(val1) + Sqr(val2) + Sqr(val3) + Sqr(val4) + Sqr(val5) + Sqr(val6) + Sqr(val7) +
             Sqr(val8) + Sqr(val9) + Sqr(val10) + Sqr(val11) + Sqr(val12) + Sqr(val13) + Sqr(val14) +
             Sqr(val15) + Sqr(val16) + Sqr(val17) + Sqr(val18) + Sqr(val19) + Sqr(val20) + Sqr(val21) +
             Sqr(val22) + Sqr(val23) + Sqr(val24) + Sqr(val25) + Sqr(val26) + Sqr(val27) + Sqr(val28) + Sqr(val29);

def vAvg = valSum / 29;
def StDv1 = Sqrt((valSqr / 29) - Sqr(vAvg));
def aStDev = sign(vAvg) * StDv1;

def d;def d1;
Switch (showPlot) {
Case "Standart Deviation Line Alone" :
    d = if last then na else yes;
    d1 = if last then na else no;
Case "Indicator & Std Dev." :
    d = if last then na else no;
    d1 = if last then na else no;
Default :
    d = if last then na else no;
    d1 = if last then na else yes;
}

plot stdv = if d1 then na else aStDev;#, "Standard Deviation of Array's Elements"
stdv.SetPaintingStrategy(PaintingStrategy.SQUARES);
stdv.AssignValueColor(if vAvg>=0 then Color.CYAN else Color.MAGENTA);

plot Iteration28 = if d then na else val28; 
plot Iteration26 = if d then na else val26; 
plot Iteration25 = if d then na else val25;
plot Iteration24 = if d then na else val24;
plot Iteration23 = if d then na else val23;
plot Iteration22 = if d then na else val22;
plot Iteration21 = if d then na else val21;
plot Iteration20 = if d then na else val20;
plot Iteration19 = if d then na else val19;
plot Iteration18 = if d then na else val18;
plot Iteration17 = if d then na else val17;
plot Iteration16 = if d then na else val16;
plot Iteration15 = if d then na else val15;
plot Iteration14 = if d then na else val14;
plot Iteration13 = if d then na else val13;
plot Iteration12 = if d then na else val12;
plot Iteration11 = if d then na else val11;
plot Iteration10 = if d then na else val10;
plot Iteration9 = if d then na else val9;
plot Iteration8 = if d then na else val8;
plot Iteration7 = if d then na else val7;
plot Iteration6 = if d then na else val6;
plot Iteration5 = if d then na else val5;
plot Iteration4 = if d then na else val4;
plot Iteration3 = if d then na else val3;
plot Iteration2 = if d then na else val2;
plot Iteration1 = if d then na else val1;
plot Iteration0 = if d then na else val0;

Iteration28.AssignValueColor(if val28 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration26.AssignValueColor(if val26 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration25.AssignValueColor(if val25 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration24.AssignValueColor(if val24 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration23.AssignValueColor(if val23 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration22.AssignValueColor(if val22 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration21.AssignValueColor(if val21 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration20.AssignValueColor(if val20 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration19.AssignValueColor(if val19 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration18.AssignValueColor(if val18 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration17.AssignValueColor(if val17 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration16.AssignValueColor(if val16 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration15.AssignValueColor(if val15 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration14.AssignValueColor(if val14 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration13.AssignValueColor(if val13 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration12.AssignValueColor(if val12 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration11.AssignValueColor(if val11 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration10.AssignValueColor(if val10 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration9.AssignValueColor(if val9 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration8.AssignValueColor(if val8 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration7.AssignValueColor(if val7 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration6.AssignValueColor(if val6 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration5.AssignValueColor(if val5 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration4.AssignValueColor(if val4 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration3.AssignValueColor(if val3 >= 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration2.AssignValueColor(if val2 > 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration1.AssignValueColor(if val1 > 0 then GlobalColor("up") else GlobalColor("dn"));
Iteration0.AssignValueColor(if val0 > 0 then GlobalColor("up") else GlobalColor("dn"));


Iteration28.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration26.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration25.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration24.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration23.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration22.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration21.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration20.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration19.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration18.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration17.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration16.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration15.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration14.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration13.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration12.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration11.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration10.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration9.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration8.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration7.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration6.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration5.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration4.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration3.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration2.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration1.SetPaintingStrategy(PaintingStrategy.POINTS);
Iteration0.SetPaintingStrategy(PaintingStrategy.POINTS);

#--- END OF CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
366 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