TSI convert this tradingview pine script to ctradr

Created at 02 Jun 2019
cTrader Discord
Stoplosstrader's avatar

Stoplosstrader

Joined 04.02.2019

Status

Open


Budget

30.00 USD


Payment Method

via  Freelancer

Job Description

//@version=3
study("True Strength Indicator", shorttitle="TSI")
long = input(title="Long Length", type=integer, defval=20)
short = input(title="Short Length", type=integer, defval=5)
signal = input(title="Signal Length", type=integer, defval=30)
price = close
double_smooth(src, long, short) =>
    fist_smooth = ema(src, long)
    ema(fist_smooth, short)
pc = change(price)
double_smoothed_pc = double_smooth(pc, long, short)
double_smoothed_abs_pc = double_smooth(abs(pc), long, short)
tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
plot(tsi_value, color = change(tsi_value) <= 0 ? red : lime, style=line) 
msignal = sma(tsi_value, signal)
plot(msignal, color = change(msignal) <= 0 ? red : lime, style=line) 
hline(0, title="Zero")

 

Dinput2 = tsi_value

f_top_fractal(_src)=>_src[4] < _src[2] and _src[3] < _src[2] and _src[2] > _src[1] and _src[2] > _src[0]
f_bot_fractal(_src)=>_src[4] > _src[2] and _src[3] > _src[2] and _src[2] < _src[1] and _src[2] < _src[0]
f_fractalize(_src)=>f_top_fractal(_src) ? 1 : f_bot_fractal(_src) ? -1 : 0


fractal_top2 = f_fractalize(Dinput2) > 0 ? Dinput2[2] : na
fractal_bot2 = f_fractalize(Dinput2) < 0 ? Dinput2[2] : na

high_prev2  = valuewhen(fractal_top2, Dinput2[2], 0)[2]
high_price2 = valuewhen(fractal_top2, high[2], 0)[2]
low_prev2   = valuewhen(fractal_bot2, Dinput2[2], 0)[2]
low_price2  = valuewhen(fractal_bot2, low[2], 0)[2]


regular_bearish_div2 = fractal_top2  and high[2] > high_price2 and Dinput2[2] < high_prev2
hidden_bearish_div2  = fractal_top2  and high[2] < high_price2 and Dinput2[2] > high_prev2
regular_bullish_div2 = fractal_bot2  and low[2]  < low_price2  and Dinput2[2] > low_prev2
hidden_bullish_div2  = fractal_bot2  and low[2]  > low_price2  and Dinput2[2] < low_prev2
//-------------------------


col5 = regular_bearish_div2 ? black     : na
col6 = regular_bullish_div2 ? black    : na
//col7 = regular_bearish_div2 ? red   : hidden_bearish_div2 and showhidden2 ? red : na
//col8 = regular_bullish_div2 ? green : hidden_bullish_div2 and showhidden2 ? green : na

plot(title='2 Bearish Divergences', series=fractal_top2 ? Dinput2[2] : na, color=col5, linewidth=2, offset=-2)
plot(title='2 Bullish Divergences', series=fractal_bot2 ? Dinput2[2] : na, color=col6, linewidth=2, offset=-2)
//plot(title='2 H D', series=(showdivs2 or showhidden2) and fractal_top2 ? Dinput2[2] : na, style=circles, color=col3, linewidth=3, offset=-2)
//plot(title='2 L D', series=(showdivs2 or showhidden2) and fractal_bot2 ? Dinput2[2] : na, style=circles, color=col4, linewidth=3, offset=-2)

 

 

Comments
Log in to add a comment.
dolandjosama34's avatar
dolandjosama34 · 2 years ago

Hi it will be a pleasure for me to work with you, I am a very experienced developer in MT5/MT4, cTrade, Trading View. let's discuss about your project.
Email: dolandjosama34@gmail.com
Phone/Telegram: +50938512703