Help converting “Logistic RSI” Indicator from Trading View
Forums › ProRealTime English forum › ProBuilder support › Help converting “Logistic RSI” Indicator from Trading View
- This topic has 4 replies, 2 voices, and was last updated 3 years ago by Nicolas.
-
-
03/07/2021 at 9:43 AM #163355
Please help converting this indicator.
(https://www.tradingview.com/script/NioHIxY1-Logistic-RSI-STOCH-ROC-AO-by-DGT/)According to the author “The logistic map connects fluid convection, neuron firing, the Mandelbrot set and so much more.”
(https://www.tradingview.com/script/jUuBT0bO-Logistic-EMA-w-Signals-by-DGT/)The original code includes RSI, Stochastics, ROC and OA (Awesome Oscillator) options. As the indicator name is not formalised it could be called the Logistic RSI for RSI version etc but if a more appropriate name can be proposed that’s fine. However it would be nice to have the other indicators as well. Maybe separate indicators or all in one with a generic name?
Several display options are available (see Attachments). I would prefer the contour-type of display.
Usage: Main form of usage is cross of the zero lie. Also possibly divergence.
Thank you.
Logistic RSI123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © dgtrd//@version=4study("Logistic RSI, STOCH, ROC, AO, ... by DGT", shorttitle="LOGISTIC by DGT")//, resolution="")ti = input("Logistic Dominance", "Select Indicator", options = ["Awesome Oscillator (AO)", "Logistic Dominance", "Rate of Change (ROC)", "Relative Strength Index (RSI)", "Stochastic (STOCH)"])source = input(close, "Source", input.source)length = input(13, "Logistic Length", minval = 1)d = input(false, "Only Standart Deviation Line of Array's Elements")style = input(false, "Enable Line Plotting Style")uC = input(color.green, "Bullish Color", input.color)dC = input(color.red , "Bearish Color", input.color)isBackTest = input(false, "═══════ ═ Backtest On/Off ═ ═══════")dasCapital = input(1000., "Initial Capital")lenBckTst = input(1, "Backtest Period (Year)", step = .25)lblInOutSL = input(true, "Show Entry/Take Profit(Exit)/Stop Loss Labels")dummy = input(true, "═══════ ═ Optimization ═ ═══════")srcInOut = input(close, "Source : Entry/Exit Price Assumption")stopLoss = input(1., "Stop Loss %", step=.1, minval = 0) / 100lenLD = input(5, "Length : Logistic Dominance", minval = 1)lenROC = input(9, "Length : Rate of Change (ROC)", minval = 1)lenRSI = input(14, "Length : Relative Strength Index (RSI)", minval = 1)lenSTO = input(14, "Length : Stochastic (STOCH)", minval = 1)// Functions ════════════════════════════════════════════════════════════════════════════════════ //f_logmap(_s, _r, _l) => _r * _s / highest(_l) * (1 - _s / highest(_l))f_map(_s, _r, _v) =>mapeq = f_logmap(_s, _r, length)lmap = mapeqfor i = 0 to 29array.push(_v,lmap)lmap := _r * abs(mapeq[i]) * (1 - mapeq[i])lmap// -Calculations ════════════════════════════════════════════════════════════════════════════════ //r = if ti == "Awesome Oscillator (AO)"sma(hl2, 5) / sma(hl2, 34) - 1else if ti == "Logistic Dominance"-f_logmap(-source, change(source, lenLD) / source[lenLD], lenLD) - f_logmap(source, change(source, lenLD) / source[lenLD], lenLD)else if ti == "Rate of Change (ROC)"change(source, lenROC) / source[lenROC]else if ti == "Relative Strength Index (RSI)"rsi(source, lenRSI) / 100 - .5else if ti == "Stochastic (STOCH)"stoch(source, high, low, lenSTO) / 100 - .5var v = array.new_float(0)val = f_map(source, r, v)s = style ? 2 : 3// -Plotting ════════════════════════════════════════════════════════════════════════════════════ //plot(d ? na : val , "Last Iteration", val >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,1 ), "2nd Iteration" , array.get(v,1 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,2 ), "3rd Iteration" , array.get(v,2 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,3 ), "4th Iteration" , array.get(v,3 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,4 ), "5th Iteration" , array.get(v,4 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,5 ), "6th Iteration" , array.get(v,5 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,6 ), "7th Iteration" , array.get(v,6 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,7 ), "8th Iteration" , array.get(v,7 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,8 ), "9th Iteration" , array.get(v,8 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,9 ), "10th Iteration", array.get(v,9 ) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,10), "11th Iteration", array.get(v,10) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,11), "12th Iteration", array.get(v,11) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,12), "13th Iteration", array.get(v,12) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,13), "14th Iteration", array.get(v,13) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,14), "15th Iteration", array.get(v,14) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,15), "16th Iteration", array.get(v,15) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,16), "17th Iteration", array.get(v,16) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,17), "18th Iteration", array.get(v,17) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,18), "19th Iteration", array.get(v,18) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,19), "20th Iteration", array.get(v,19) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,20), "21st Iteration", array.get(v,20) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,21), "22nd Iteration", array.get(v,21) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,22), "23rd Iteration", array.get(v,22) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,23), "24th Iteration", array.get(v,23) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,24), "25th Iteration", array.get(v,24) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,25), "26th Iteration", array.get(v,25) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,26), "27th Iteration", array.get(v,26) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,27), "28th Iteration", array.get(v,27) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,28), "29th Iteration", array.get(v,28) >= 0 ? uC : dC, 1, s)plot(d ? na : array.get(v,29), "30th Iteration", array.get(v,29) >= 0 ? uC : dC, 1, s)array.remove(v, 0)aStDev = sign(array.avg(v)) * array.stdev(v)plot(aStDev, "Standard Deviation of Array's Elements", array.avg(v) >= 0 ? #006400 : #910000, 2)array.clear(v)// -BackTest ════════════════════════════════════════════════════════════════════════════════════ //startBckTst = time > timenow - lenBckTst * 31556952000var inTrade = falseif isBackTestvar capital = dasCapitalvar entryPrice = 0.var exitPrice = 0.var trades = 0var win = 0var loss = 0crossover = crossover (aStDev, 0)crossunder = crossunder(aStDev, 0)longCondition = barstate.islast ? crossover [1] : crossovershortCondition = barstate.islast ? crossunder[1] : crossunderstopLossCondition = inTrade ? close < entryPrice * (1 - stopLoss) : 0if startBckTst and longCondition and not inTradeentryPrice := srcInOutinTrade := truetrades := trades + 1if lblInOutSLlabel longLabel = label.new(bar_index, 0, text="L",tooltip="entry price : " + tostring(entryPrice) + "\nentry value : " + tostring(capital, "#.##"),color=color.green, style=label.style_label_up, textcolor=color.white, textalign=text.align_center, size=size.tiny)if (shortCondition or stopLossCondition) and inTradeexitPrice := srcInOutinTrade := falsecapital := capital * (exitPrice / entryPrice)if exitPrice > entryPricewin := win + 1elseloss := loss + 1if lblInOutSLtxt = stopLossCondition ? "SL" : "TP"label shortLabel = label.new(bar_index, 0, text=txt,tooltip="change .......... : " + tostring((exitPrice / entryPrice - 1) * 100, "#.##") + "%\nentry/exit price : " + tostring(entryPrice) + " / " + tostring(exitPrice) + "\nnew capital ..... : " + tostring(capital, "#.##"),color=color.red, style=label.style_label_down, textcolor=color.white, textalign=text.align_center, size=size.tiny)var years = (timenow - time) / 31556952000var yearsTxt = ""var remarks = ""if years < lenBckTstlenBckTst := yearsyearsTxt := tostring(lenBckTst, "#.##") + " Years***"remarks := "\n\n*longs only\n**final value, if trade active displays estimated final value\n***max available data for selected timeframe : # of bars - " + tostring(bar_index)elseyearsTxt := tostring(lenBckTst, "#.##") + " Year(s)"remarks := "\n\n*longs only\n**final value, if trade open displies estimated final value"inTradeTxt = inTrade ? "inTrade" : "not inTrade"estimated = inTrade ? capital * (close / entryPrice) : capitalentryTxt = inTrade ? tostring(entryPrice) : "not inTrade"lastTrdTxt = inTrade ? ", Gain/Loss " + tostring((estimated/capital - 1) * 100, "#.##") + "%, Stop Loss " + tostring(entryPrice * (1 - stopLoss)) : ""tooltipTxt = "entires/exits are calculated based on standard deviation value of array's elements (aStDev)\n -long entry, when aStDev > 0\n -take profit, when aStDev < 0\n -stop loss if last value falls by " + tostring(stopLoss * 100) + "% of entry price" + remarkslabel indiLabel = label.new(time, 0,text="☼ Trade Statistics*, Trade Period - " + yearsTxt +"\nSelected Indicator -> " + ti +"\n═════════════════════════════════════" +"\nSuccess Ratio ...... : " + tostring((win/trades)*100, "#") + "%" + ", # of Trades - " + tostring(trades) + ", Win/Loss - " + tostring(win) + "/" + tostring(loss) +"\nGain/Loss % ........ : " + tostring((estimated/dasCapital - 1) * 100, "#") + "%" + ", Initial/Final Value** - " + tostring(dasCapital) + " / " + tostring(estimated, "#") +"\n\nCurrent TradeStatus - " + inTradeTxt + lastTrdTxt +"\n═════════════════════════════════════" +"\nEntry Price/Value . : " + entryTxt + " / " + tostring(capital, "#.##") + " " + inTradeTxt +"\nLast Price/Value ... : " + tostring(close) + " / " + tostring(estimated , "#.##") + " " + inTradeTxt,tooltip=tooltipTxt,color=inTrade ? estimated/dasCapital > 1 ? color.teal : color.maroon : color.gray, xloc=xloc.bar_time, style=label.style_label_left, textcolor=color.white, textalign=text.align_left)label.set_x(indiLabel, label.get_x(indiLabel) + round(change(time)*3))label.delete(indiLabel[1])bgcolor(isBackTest and startBckTst and startBckTst != startBckTst[1] ? color.blue : na)03/08/2021 at 10:24 AM #16342203/09/2021 at 3:15 PM #163618Here is a first draft version that use only the Awesome Oscillator as entry:
1234567891011121314151617181920212223242526272829303132333435363738394041ti = 0 //0=Awesome Oscillator (AO),1=Logistic Dominance,2=Rate of Change (ROC),3=Relative Strength Index (RSI),4= Stochastic (STOCH)length = 13// ---source = customclosed = 0//input(false, "Only Standart Deviation Line of Array's Elements")if ti = 0 thenrr = average[5](medianprice)/average[34](medianprice)-1endif//f_map(source, rr, v)//f_map(_s, _r, _v) =>//mapeq = f_logmap(_s, _r, length)//f_logmap(_s, _r, _l) => _r * _s / highest(_l) * (1 - _s / highest(_l))mapeq = rr*source / highest[length](high)*(1-source/highest[length](high))lmap = mapeq*1000000sum = 0for i = 1 to 30lmap = (rr * abs(mapeq[i]) * (1 - mapeq[i]))*1000000sum=sum+lmap$v[i]=lmapnextavg = sum/30ens=0for j = 1 to 30if avg>0 thenr=0g=255elser=255g=0endifdrawtext("*",barindex,$v[j],dialog,bold,12) coloured(r,g,0)//drawtext("#j#",barindex,$v[j],dialog,bold,12) coloured(r,g,0)ens=ens+square($v[j]-avg)nextsd = sqrt(ens/30)astdev = avg*sdreturn 0 coloured(100,100,100,0),lmap coloured(100,100,100,0),avg,astdev03/09/2021 at 5:37 PM #16364403/15/2021 at 1:11 PM #164218I made a more complete version (with other oscillators), you can now find it here: Logistic Oscillators
-
AuthorPosts
Find exclusive trading pro-tools on