Is there a way to circumvent the array stuff here ?
https://www.tradingview.com/script/TnJMMEJI-RSI-Primed-ChartPrime/
https://www.tradingview.com/script/TnJMMEJI-RSI-Primed-ChartPrime/
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
check the below. May not give exact results but pretty close.Is there a way to circumvent the array stuff here ?
https://www.tradingview.com/script/TnJMMEJI-RSI-Primed-ChartPrime/
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © ChartPrime
#indicator("RSI Primed [ChartPrime]")
# Converted by Sam4Cok@Samer800 - 11/2023 - Not Exact Conv.
# minor bug fix
declare lower;
input colorBars = no;
input style = {"Candle", default "Candle With Patterns", "Heikin Ashi", "Line"};# "Style"
input colorRsiLine = no;
input length = 24; # "Length"
input smoothing = 3; # "Smoothing"
input autoMovAvg = yes; # "Auto MA"
input movAvgMultiplier = 1;#, "", 1, inline = "MA")
def na = Double.NaN;
def last = isNaN(close);
def not_line = style != style."Line";
script nz {
input data = close;
input repl = 0.0001;
def ret_val = if isNaN(data) then repl else data;
plot return = ret_val;
}
#mamaPeriod(float src, int dynLow, int dynHigh) =>
script mamaPeriod {
input src = close;
input dynLow = 0.5;
input dynHigh = 0.05;
def pi = Double.Pi;
def period;# = 0.0
def C1 = 0.0962;
def C2 = 0.5769;
def C3 = 0.075 * nz(period[1]) + 0.54;
def smooth = (4 * src + 3 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 10;
def detrend = C3 * (C1 * smooth + C2 * nz(smooth[2]) - C2 * nz(smooth[4]) - C1 * nz(smooth[6]));
# // Compute InPhase and Quadrature components
def Q1 = C3 * (C1 * detrend + C2 * nz(detrend[2]) - C2 * nz(detrend[4]) - C1 * nz(detrend[6]));
def I1 = nz(detrend[3]);
# // Advance Phase of I1 and Q1 by 90 degrees
def jI = C3 * (C1 * I1 + C2 * nz(I1[2]) - C2 * nz(I1[4]) - C1 * nz(I1[6]));
def jQ = C3 * (C1 * Q1 + C2 * nz(Q1[2]) - C2 * nz(Q1[4]) - C1 * nz(Q1[6]));
# // Phasor addition for 3 bar averaging
def I2_ = I1 - jQ;
def Q2_ = Q1 + jI;
# // Smooth I and Q components before applying discriminator
def I2 = 0.2 * I2_ + 0.8 * (I2[1]);
def Q2 = 0.2 * Q2_ + 0.8 * (Q2[1]);
# // Extract Homodyne Discriminator
def Re_ = I2 * nz(I2[1]) + Q2 * nz(Q2[1]);
def Im_ = I2 * nz(Q2[1]) - Q2 * nz(I2[1]);
def Re = 0.2*Re_ + 0.8 * (Re[1]);
def Im = 0.2*Im_ + 0.8 * (Im[1]);
def period1 = if (Re != 0 and Im != 0) then 2 * pi / atan(Im/Re) else 0;
def period2 = min(min(period1, 1.5 * period[1]), period1);
def period3 = max(max(period2, (2/3) * period[1]), period2);
def period4 = min(max(period3, dynLow), dynHigh);
period = period4 * 0.2 + period[1] *0.8;
plot out = period;
}
#double_exponential_moving_average(source)=>
script DMA {
input source = close;
def ema1;
def ema2;
def count;
if close == close {
count = count[1] + 1;
ema1 = (1.0 - 2.0 / (count + 1)) * ema1[1] + 2.0 / (count + 1) * source;
ema2 = (1.0 - 2.0 / (count + 1)) * ema2[1] + 2.0 / (count + 1) * ema1;
} else {
ema1 = ema1[1];
ema2 = ema2[1];
count = 0;
}
def DMA = 2 * ema1 - ema2;
plot out = DMA;
}
#patterns(Open, High, Low, Close, OHLC4, ma)=>
script patterns {
input Op = open;
input Hi = high;
input Lo = low;
input Cl = close;
input ohlc = OHLC4;
input ma = close;
def c_down_trend = ohlc < ma;
def c_up_trend = ohlc > ma;
def rsi_low = Hi < 40;
def rsi_high = Lo > 60;
def c_body_hi = Max(Cl, Op);
def c_body_lo = Min(Cl, Op);
def c_body = c_body_hi - c_body_lo;
def c_body_avg = DMA(c_body);
def c_body_middle = c_body / 2 + c_body_lo;
def c_small_body = c_body < c_body_avg;
def c_long_body = c_body > c_body_avg;
def c_white_body = Op < Cl;
def c_black_body = Op > Cl;
def c_engulfing_bearish = c_up_trend and c_black_body and c_long_body and c_white_body[1] and
c_small_body[1] and Cl <= Op[1] and Op >= Cl[1] and (Cl < Op[1] or Op > Cl[1]) and rsi_high;
def c_engulfing_bullish = c_down_trend and c_white_body and c_long_body and c_black_body[1] and
c_small_body[1] and Cl >= Op[1] and Op <= Cl[1] and (Cl > Op[1] or Op < Cl[1]) and rsi_low;
def c_morning_star_bullish;
if c_long_body[2] and c_small_body[1] and c_long_body {
c_morning_star_bullish = if c_down_trend and c_black_body[2] and c_body_hi[1] < c_body_lo[2] and
c_white_body and c_body_hi >= c_body_middle[2] and c_body_hi < c_body_hi[2] and
c_body_hi[1] < c_body_lo then yes else c_morning_star_bullish[1];
} else {
c_morning_star_bullish = no;
}
def c_evening_star_bearish;
if c_long_body[2] and c_small_body[1] and c_long_body {
c_evening_star_bearish = if c_up_trend and c_white_body[2] and c_body_lo[1] > c_body_hi[2] and
c_black_body and c_body_lo <= c_body_middle[2] and c_body_lo > c_body_lo[2] and
c_body_lo[1] > c_body_hi then yes else c_evening_star_bearish[1];
} else {
c_evening_star_bearish = no;
}
plot engBear = c_engulfing_bearish;
plot engBull = c_engulfing_bullish;
plot starBull = c_morning_star_bullish;
plot starBear = c_evening_star_bearish;
}
#// Custom cosh function
#cosh(float x) =>
script cosh {
input x = 0;
def cosh = (Exp(x) + Exp(-x)) / 2;
plot out = cosh;
}
#// Custom sinh function
#sinh(float x) =>
script sinh {
input x = 0;
def sinh = (Exp(x) - Exp(-x)) / 2;
plot out = sinh;
}
#// Custom asinh function
#asinh(float x) =>
script asinh {
input x = 0;
def asinh = Log(x + Sqrt(x * x + 1));
plot out = asinh;
}
#// Custom acosh function
Script acosh {
input x = 0;
def acosh = if x < 1 then 1 else log(x + sqrt(x * x - 1));
plot out = acosh;
}
#atan2(y, x) =>
script atan2 {
input y = 0;
input x = 0;
def pi = Double.Pi;
def angle;
if x > 0 {
angle = ATan(y / x);
} else
if x < 0 and y >= 0 {
angle = ATan(y / x) + pi;
} else
if x < 0 and y < 0 {
angle = ATan(y / x) - pi;
} else
if x == 0 and y > 0 {
angle = pi / 2;
} else
if x == 0 and y < 0 {
angle = - pi / 2;
} else {
angle = angle[1];
}
plot out = if isNaN(angle) then 0 else angle;
}
#// Chebyshev Type I Moving Average
#chebyshevI(float src, float len, float ripple) =>
script chebyshevI {
input src = close;
input len = 24;
input ripple = 0.5;
def alpha = 1 / len;
def acoshRi = 1 / (1 - ripple);
def asinhRi = 1 / ripple;
def acosh = acosh(acoshRi);
def asinh = asinh(asinhRi);
def a = cosh(alpha * acosh);
def b = sinh(alpha * asinh);
def g = (a - b) / (a + b);
def chebyshev = (1 - g) * src + g * chebyshev[1];
plot out = chebyshev;
}
#ema(source)=>
script ema {
input source = close;
def count = count[1] + 1;
def ema = (1 - 2 / (count + 1.0)) * ema[1] + 2 / (count + 1) * source;
plot out = ema;
}
#trend_angle(source, length, smoothing_length, smoothing_ripple) =>
script trend_angle {
input source = close;
input length = 24;
input smoothing_length = 2;
input smoothing_ripple = 0.5;
def pi = Double.Pi;
def hh = Highest(source, length);
def ll = Lowest(source, length);
def atr = ema(hh - ll);
def slope = (source - source[length]) / (atr / length * length);
def angle_rad = atan2(slope, 1);
def deg = angle_rad * 180 / pi;
def degrees = chebyshevI(deg, smoothing_length, smoothing_ripple);
def normalized = Floor((90 + degrees) / 180 * 39);
plot out = if isNaN(normalized) then 0 else normalized;
}
#length(source, harmonic)=>
script length {
input source = close;
input harmonic = 1;
def mama = mamaPeriod(source[1], 1, 2048);
def cycle = Round(mama, 0);
def cycles = if isNaN(cycle) then 1 else cycle;
def max_cycle = (cycles + 1) * harmonic;
plot len = max_cycle;
}
#rsi(source = close, length = 14, smoothing = 3)=>
script nRSI {
input source = close;
input length = 14;
input smoothing = 3;
def close_filtered = chebyshevI(source, smoothing, 0.5);
def change = close_filtered - close_filtered[1];
def up = Max(change, 0);
def dn = - Min(change, 0);
def up_filtered = chebyshevI(up, length, 0.5);
def dn_filtered = chebyshevI(dn, length, 0.5);
def nRSI = if dn_filtered == 0 then 100 else
if up_filtered == 0 then 0 else 100 - (100 / (1 + up_filtered / dn_filtered));
plot out = nRSI;
}
def rsi_open = nrsi(open, length, smoothing);
def rsi_high = nrsi(high, length, smoothing);
def rsi_low = nrsi(low, length, smoothing);
def rsi_close = nrsi(close,length, smoothing);
def haClose = (rsi_open + rsi_high + rsi_low + rsi_close) / 4;
def haOpen = if !haOpen[1] then (rsi_open + rsi_close) / 2 else
(haOpen[1] + haClose[1]) / 2;
def haHigh = Max(rsi_high, Max(haOpen, haClose));
def haLow = Min(rsi_low, Min(haOpen, haClose));
def ha_close;
def ha_open;
def ha_high;
def ha_low;
Switch (style) {
Case "Candle" :
ha_close = rsi_close;
ha_open = rsi_open;
ha_high = rsi_high;
ha_low = rsi_low;
Case"Heikin Ashi" :
ha_close = haClose;
ha_open = haOpen;
ha_high = haHigh;
ha_low = haLow;
Case "Line" :
ha_close = rsi_close;
ha_open = rsi_open;
ha_high = rsi_high;
ha_low = rsi_low;
Default :
ha_close = rsi_close;
ha_open = rsi_open;
ha_high = rsi_high;
ha_low = rsi_low;
}
def OHLC = (ha_close + ha_open + ha_high + ha_low) / 4;
def ma_length = length(OHLC, movAvgMultiplier);
def aemaP = chebyshevI(OHLC, ma_length, 0.05);
def aema = if aemaP > 100 then OHLC else if aemaP < 0 then OHLC else aemaP;
def engulfing_bearish = patterns(ha_open, ha_high, ha_low, ha_close, OHLC, aema).engBear;
def engulfing_bullish = patterns(ha_open, ha_high, ha_low, ha_close, OHLC, aema).engBull;
def morning_star_bullish = patterns(ha_open, ha_high, ha_low, ha_close, OHLC, aema).starBull;
def evening_star_bearish = patterns(ha_open, ha_high, ha_low, ha_close, OHLC, aema).starBear;
def engBull = if engulfing_bullish and style == style."Candle With Patterns" then -20 else na;#
def starBull = if morning_star_bullish and style == style."Candle With Patterns" then -20 else na;
def engBear = if engulfing_bearish and style == style."Candle With Patterns" then 120 else na;#
def starBear = if evening_star_bearish and style == style."Candle With Patterns" then 120 else na;#
# Plot the new Chart
def up = not_line and ha_close > ha_open;
def dn = not_line and !(ha_close > ha_open);
AddChart(high = if up then ha_high else na , low = ha_low , open = ha_close, close = ha_open,
type = ChartType.CANDLE, growcolor = CreateColor(38,166,154));
AddChart(high = if dn then ha_high else na, low = ha_low , open = ha_open, close = ha_close,
type = ChartType.CANDLE, growcolor = CreateColor(239,83,80));
def col = if OHLC > 65 then 255 else
if OHLC < 35 then 0 else OHLC * 2.55;
plot RSILine = if !not_line then OHLC else na;#, "RSI Line", color_candles ? grad_100 : #7352FF, 2)
plot maLine = if autoMovAvg then aema else na;#, "MA", aema_colour, 2)
RSILine.SetLineWeight(2);
RSILine.AssignValueColor(if !colorRsiLine then Color.MAGENTA else CreateColor(255 - col, col, 0));
maLine.AssignValueColor(CreateColor(255 - col, col, 0));
plot top = if last then na else 70;
plot med = if last then na else 50;
plot bot = if last then na else 30;
top.SetDefaultColor(Color.GRAY);
med.SetDefaultColor(Color.GRAY);
bot.SetDefaultColor(Color.GRAY);
top.SetStyle(Curve.SHORT_DASH);
med.SetStyle(Curve.SHORT_DASH);
bot.SetStyle(Curve.SHORT_DASH);
AddVerticalLine(engulfing_bullish, "Eng", Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(morning_star_bullish,"Star", Color.CYAN, Curve.SHORT_DASH);
AddVerticalLine(engulfing_bearish, "Eng", Color.RED, Curve.SHORT_DASH);
AddVerticalLine(evening_star_bearish, "Star", Color.MAGENTA, Curve.SHORT_DASH);
#-- Bar Color
AssignPriceColor(if !colorBars then Color.CURRENT else CreateColor(255 - col, col, 0));
#-- END of CODE
I updated the code with minor bug fix. pls try and let me know.@samer800, just started to play and noticed the distortion you can see in the 6 month chart of TQQQ lower left. Link attached to make it easier to check. Is this situation a consequence of the lack of the array stuff?
Interestingly if the chart spans 1 year, it looks "normal"
http://tos.mx/8jhUTcL
View attachment 20191
apparently now it is fine. I will further test it and if any other issue cames will let you know. thanks so much!I updated the code with minor bug fix. pls try and let me know.
There is no FNG, the ENG vertical line is alerting to the presence of an engulfing candle.Very nice indicator ! Love your work Samer800. What are the vertical dashed lines, green and red, that appear to script "ENG" and/or "FNG" indicating ?
This one does repaint a bit- basically the upper/mid/lower lines do(i think). Had a candle print below the midline today, two candles later it was moved above the midline as candles were pushing lower.
This is awesome @samer800 , how can I make it so that it alerts me on the ENG lines? Im very basic in coding, and if its not my own work, I struggle.... thanks in advance mate!check the below. May not give exact results but pretty close.
CSS:#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ #// © ChartPrime #indicator("RSI Primed [ChartPrime]") # Converted by Sam4Cok@Samer800 - 11/2023 - Not Exact Conv. # minor bug fix declare lower; input colorBars = no; input style = {"Candle", default "Candle With Patterns", "Heikin Ashi", "Line"};# "Style" input colorRsiLine = no; input length = 24; # "Length" input smoothing = 3; # "Smoothing" input autoMovAvg = yes; # "Auto MA" input movAvgMultiplier = 1;#, "", 1, inline = "MA") def na = Double.NaN; def last = isNaN(close); def not_line = style != style."Line"; script nz { input data = close; input repl = 0.0001; def ret_val = if isNaN(data) then repl else data; plot return = ret_val; } #mamaPeriod(float src, int dynLow, int dynHigh) => script mamaPeriod { input src = close; input dynLow = 0.5; input dynHigh = 0.05; def pi = Double.Pi; def period;# = 0.0 def C1 = 0.0962; def C2 = 0.5769; def C3 = 0.075 * nz(period[1]) + 0.54; def smooth = (4 * src + 3 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 10; def detrend = C3 * (C1 * smooth + C2 * nz(smooth[2]) - C2 * nz(smooth[4]) - C1 * nz(smooth[6])); # // Compute InPhase and Quadrature components def Q1 = C3 * (C1 * detrend + C2 * nz(detrend[2]) - C2 * nz(detrend[4]) - C1 * nz(detrend[6])); def I1 = nz(detrend[3]); # // Advance Phase of I1 and Q1 by 90 degrees def jI = C3 * (C1 * I1 + C2 * nz(I1[2]) - C2 * nz(I1[4]) - C1 * nz(I1[6])); def jQ = C3 * (C1 * Q1 + C2 * nz(Q1[2]) - C2 * nz(Q1[4]) - C1 * nz(Q1[6])); # // Phasor addition for 3 bar averaging def I2_ = I1 - jQ; def Q2_ = Q1 + jI; # // Smooth I and Q components before applying discriminator def I2 = 0.2 * I2_ + 0.8 * (I2[1]); def Q2 = 0.2 * Q2_ + 0.8 * (Q2[1]); # // Extract Homodyne Discriminator def Re_ = I2 * nz(I2[1]) + Q2 * nz(Q2[1]); def Im_ = I2 * nz(Q2[1]) - Q2 * nz(I2[1]); def Re = 0.2*Re_ + 0.8 * (Re[1]); def Im = 0.2*Im_ + 0.8 * (Im[1]); def period1 = if (Re != 0 and Im != 0) then 2 * pi / atan(Im/Re) else 0; def period2 = min(min(period1, 1.5 * period[1]), period1); def period3 = max(max(period2, (2/3) * period[1]), period2); def period4 = min(max(period3, dynLow), dynHigh); period = period4 * 0.2 + period[1] *0.8; plot out = period; } #double_exponential_moving_average(source)=> script DMA { input source = close; def ema1; def ema2; def count; if close == close { count = count[1] + 1; ema1 = (1.0 - 2.0 / (count + 1)) * ema1[1] + 2.0 / (count + 1) * source; ema2 = (1.0 - 2.0 / (count + 1)) * ema2[1] + 2.0 / (count + 1) * ema1; } else { ema1 = ema1[1]; ema2 = ema2[1]; count = 0; } def DMA = 2 * ema1 - ema2; plot out = DMA; } #patterns(Open, High, Low, Close, OHLC4, ma)=> script patterns { input Op = open; input Hi = high; input Lo = low; input Cl = close; input ohlc = OHLC4; input ma = close; def c_down_trend = ohlc < ma; def c_up_trend = ohlc > ma; def rsi_low = Hi < 40; def rsi_high = Lo > 60; def c_body_hi = Max(Cl, Op); def c_body_lo = Min(Cl, Op); def c_body = c_body_hi - c_body_lo; def c_body_avg = DMA(c_body); def c_body_middle = c_body / 2 + c_body_lo; def c_small_body = c_body < c_body_avg; def c_long_body = c_body > c_body_avg; def c_white_body = Op < Cl; def c_black_body = Op > Cl; def c_engulfing_bearish = c_up_trend and c_black_body and c_long_body and c_white_body[1] and c_small_body[1] and Cl <= Op[1] and Op >= Cl[1] and (Cl < Op[1] or Op > Cl[1]) and rsi_high; def c_engulfing_bullish = c_down_trend and c_white_body and c_long_body and c_black_body[1] and c_small_body[1] and Cl >= Op[1] and Op <= Cl[1] and (Cl > Op[1] or Op < Cl[1]) and rsi_low; def c_morning_star_bullish; if c_long_body[2] and c_small_body[1] and c_long_body { c_morning_star_bullish = if c_down_trend and c_black_body[2] and c_body_hi[1] < c_body_lo[2] and c_white_body and c_body_hi >= c_body_middle[2] and c_body_hi < c_body_hi[2] and c_body_hi[1] < c_body_lo then yes else c_morning_star_bullish[1]; } else { c_morning_star_bullish = no; } def c_evening_star_bearish; if c_long_body[2] and c_small_body[1] and c_long_body { c_evening_star_bearish = if c_up_trend and c_white_body[2] and c_body_lo[1] > c_body_hi[2] and c_black_body and c_body_lo <= c_body_middle[2] and c_body_lo > c_body_lo[2] and c_body_lo[1] > c_body_hi then yes else c_evening_star_bearish[1]; } else { c_evening_star_bearish = no; } plot engBear = c_engulfing_bearish; plot engBull = c_engulfing_bullish; plot starBull = c_morning_star_bullish; plot starBear = c_evening_star_bearish; } #// Custom cosh function #cosh(float x) => script cosh { input x = 0; def cosh = (Exp(x) + Exp(-x)) / 2; plot out = cosh; } #// Custom sinh function #sinh(float x) => script sinh { input x = 0; def sinh = (Exp(x) - Exp(-x)) / 2; plot out = sinh; } #// Custom asinh function #asinh(float x) => script asinh { input x = 0; def asinh = Log(x + Sqrt(x * x + 1)); plot out = asinh; } #// Custom acosh function Script acosh { input x = 0; def acosh = if x < 1 then 1 else log(x + sqrt(x * x - 1)); plot out = acosh; } #atan2(y, x) => script atan2 { input y = 0; input x = 0; def pi = Double.Pi; def angle; if x > 0 { angle = ATan(y / x); } else if x < 0 and y >= 0 { angle = ATan(y / x) + pi; } else if x < 0 and y < 0 { angle = ATan(y / x) - pi; } else if x == 0 and y > 0 { angle = pi / 2; } else if x == 0 and y < 0 { angle = - pi / 2; } else { angle = angle[1]; } plot out = if isNaN(angle) then 0 else angle; } #// Chebyshev Type I Moving Average #chebyshevI(float src, float len, float ripple) => script chebyshevI { input src = close; input len = 24; input ripple = 0.5; def alpha = 1 / len; def acoshRi = 1 / (1 - ripple); def asinhRi = 1 / ripple; def acosh = acosh(acoshRi); def asinh = asinh(asinhRi); def a = cosh(alpha * acosh); def b = sinh(alpha * asinh); def g = (a - b) / (a + b); def chebyshev = (1 - g) * src + g * chebyshev[1]; plot out = chebyshev; } #ema(source)=> script ema { input source = close; def count = count[1] + 1; def ema = (1 - 2 / (count + 1.0)) * ema[1] + 2 / (count + 1) * source; plot out = ema; } #trend_angle(source, length, smoothing_length, smoothing_ripple) => script trend_angle { input source = close; input length = 24; input smoothing_length = 2; input smoothing_ripple = 0.5; def pi = Double.Pi; def hh = Highest(source, length); def ll = Lowest(source, length); def atr = ema(hh - ll); def slope = (source - source[length]) / (atr / length * length); def angle_rad = atan2(slope, 1); def deg = angle_rad * 180 / pi; def degrees = chebyshevI(deg, smoothing_length, smoothing_ripple); def normalized = Floor((90 + degrees) / 180 * 39); plot out = if isNaN(normalized) then 0 else normalized; } #length(source, harmonic)=> script length { input source = close; input harmonic = 1; def mama = mamaPeriod(source[1], 1, 2048); def cycle = Round(mama, 0); def cycles = if isNaN(cycle) then 1 else cycle; def max_cycle = (cycles + 1) * harmonic; plot len = max_cycle; } #rsi(source = close, length = 14, smoothing = 3)=> script nRSI { input source = close; input length = 14; input smoothing = 3; def close_filtered = chebyshevI(source, smoothing, 0.5); def change = close_filtered - close_filtered[1]; def up = Max(change, 0); def dn = - Min(change, 0); def up_filtered = chebyshevI(up, length, 0.5); def dn_filtered = chebyshevI(dn, length, 0.5); def nRSI = if dn_filtered == 0 then 100 else if up_filtered == 0 then 0 else 100 - (100 / (1 + up_filtered / dn_filtered)); plot out = nRSI; } def rsi_open = nrsi(open, length, smoothing); def rsi_high = nrsi(high, length, smoothing); def rsi_low = nrsi(low, length, smoothing); def rsi_close = nrsi(close,length, smoothing); def haClose = (rsi_open + rsi_high + rsi_low + rsi_close) / 4; def haOpen = if !haOpen[1] then (rsi_open + rsi_close) / 2 else (haOpen[1] + haClose[1]) / 2; def haHigh = Max(rsi_high, Max(haOpen, haClose)); def haLow = Min(rsi_low, Min(haOpen, haClose)); def ha_close; def ha_open; def ha_high; def ha_low; Switch (style) { Case "Candle" : ha_close = rsi_close; ha_open = rsi_open; ha_high = rsi_high; ha_low = rsi_low; Case"Heikin Ashi" : ha_close = haClose; ha_open = haOpen; ha_high = haHigh; ha_low = haLow; Case "Line" : ha_close = rsi_close; ha_open = rsi_open; ha_high = rsi_high; ha_low = rsi_low; Default : ha_close = rsi_close; ha_open = rsi_open; ha_high = rsi_high; ha_low = rsi_low; } def OHLC = (ha_close + ha_open + ha_high + ha_low) / 4; def ma_length = length(OHLC, movAvgMultiplier); def aemaP = chebyshevI(OHLC, ma_length, 0.05); def aema = if aemaP > 100 then OHLC else if aemaP < 0 then OHLC else aemaP; def engulfing_bearish = patterns(ha_open, ha_high, ha_low, ha_close, OHLC, aema).engBear; def engulfing_bullish = patterns(ha_open, ha_high, ha_low, ha_close, OHLC, aema).engBull; def morning_star_bullish = patterns(ha_open, ha_high, ha_low, ha_close, OHLC, aema).starBull; def evening_star_bearish = patterns(ha_open, ha_high, ha_low, ha_close, OHLC, aema).starBear; def engBull = if engulfing_bullish and style == style."Candle With Patterns" then -20 else na;# def starBull = if morning_star_bullish and style == style."Candle With Patterns" then -20 else na; def engBear = if engulfing_bearish and style == style."Candle With Patterns" then 120 else na;# def starBear = if evening_star_bearish and style == style."Candle With Patterns" then 120 else na;# # Plot the new Chart def up = not_line and ha_close > ha_open; def dn = not_line and !(ha_close > ha_open); AddChart(high = if up then ha_high else na , low = ha_low , open = ha_close, close = ha_open, type = ChartType.CANDLE, growcolor = CreateColor(38,166,154)); AddChart(high = if dn then ha_high else na, low = ha_low , open = ha_open, close = ha_close, type = ChartType.CANDLE, growcolor = CreateColor(239,83,80)); def col = if OHLC > 65 then 255 else if OHLC < 35 then 0 else OHLC * 2.55; plot RSILine = if !not_line then OHLC else na;#, "RSI Line", color_candles ? grad_100 : #7352FF, 2) plot maLine = if autoMovAvg then aema else na;#, "MA", aema_colour, 2) RSILine.SetLineWeight(2); RSILine.AssignValueColor(if !colorRsiLine then Color.MAGENTA else CreateColor(255 - col, col, 0)); maLine.AssignValueColor(CreateColor(255 - col, col, 0)); plot top = if last then na else 70; plot med = if last then na else 50; plot bot = if last then na else 30; top.SetDefaultColor(Color.GRAY); med.SetDefaultColor(Color.GRAY); bot.SetDefaultColor(Color.GRAY); top.SetStyle(Curve.SHORT_DASH); med.SetStyle(Curve.SHORT_DASH); bot.SetStyle(Curve.SHORT_DASH); AddVerticalLine(engulfing_bullish, "Eng", Color.GREEN, Curve.SHORT_DASH); AddVerticalLine(morning_star_bullish,"Star", Color.CYAN, Curve.SHORT_DASH); AddVerticalLine(engulfing_bearish, "Eng", Color.RED, Curve.SHORT_DASH); AddVerticalLine(evening_star_bearish, "Star", Color.MAGENTA, Curve.SHORT_DASH); #-- Bar Color AssignPriceColor(if !colorBars then Color.CURRENT else CreateColor(255 - col, col, 0)); #-- END of CODE
yes, it repaints. I checked with the ondemand feature and results are different, though apparently not by a huge difference but needs further checking.thank you for the heads up.
Yes, the Tradingview comments section reveals other comments that it does indeed repaint.
Which is understandable, most of the harmonics repaint.
The repaint prefix has been added to this indicator.
I had it on a 10 minute chart and a two minute chart. Watching it over the last several days I didn't notice any repainting at all on the 10 minute, and it doesn't seem to happen a lot on the two minute- perhaps mostly on lower time frame charts and when prices are most volatile like I witnessed on SPY open today? That said, we have a lot of choices on the board. I also watched ZScore Heikin Ashi and Matrix Series alongside RSI primed and they seemed pretty comparable as candle momentum oscillators.yes, it repaints. I checked with the ondemand feature and results are different, though apparently not by a huge difference but needs further checking
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
![]() |
Dynamic Volume RSI (DVRSI) [QuantAlgo] for Thinkorswim | Custom | 6 | |
B | TKP RSI Bar Color For ThinkOrSwim | Custom | 5 | |
M | Repaints Stochastic RSI with Divergences For ThinkOrSwim | Custom | 3 | |
C | RSI Based Automatic Supply and Demand For ThinkOrSwim | Custom | 4 | |
R | Dynamic Sentiment RSI For ThinkOrSwim | Custom | 5 |
Start a new thread and receive assistance from our community.
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.
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.