Slim Ribbon Custom

barbaros

Administrator
Staff member
Platform
  1. Thinkorswim
  2. TradingView
Requested conversion by mdtn on our Discord server from Thinkscript to Pinescript for TradingView.

Original Thinkscript:
Code:
#Mr Slim Miller at askSLIM dot com
#SlimRibbonCustom_markos9-7-18

input price = close;
input superfast_length = 8;
input fast_length = 13;
input slow_length = 21;
input displace = 0;

def mov_avg8 = ExpAverage(price[-displace], superfast_length);
def mov_avg13 = ExpAverage(price[-displace], fast_length);
def mov_avg21 = ExpAverage(price[-displace], slow_length);

#moving averages
Plot Superfast = mov_avg8;
plot Fast = mov_avg13;
plot Slow = mov_avg21;

def buy = mov_avg8 > mov_avg13 and mov_avg13 > mov_avg21 and low > mov_avg8;
def stopbuy = mov_avg8 <= mov_avg13;
def buynow = !buy[1] and buy;
def buysignal = CompoundValue(1, if buynow and !stopbuy then 1 else if buysignal[1]==1 and stopbuy then 0 else buysignal[1], 0);

plot Buy_Signal = buysignal[1] == 0 and buysignal==1;
Buy_signal.setpaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Buy_signal.setdefaultColor(color.dark_GREEN);
Buy_signal.hidetitle();

plot Momentum_Down = buysignal[1] ==1 and buysignal==0;
Momentum_down.setpaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Momentum_Down.setdefaultColor(color.yellow);
Momentum_down.hidetitle();

def sell = mov_avg8 < mov_avg13 and mov_avg13 < mov_avg21 and high < mov_avg8;
def stopsell = mov_avg8 >= mov_avg13;
def sellnow = !sell[1] and sell;
def sellsignal = CompoundValue(1, if sellnow and !stopsell then 1 else if sellsignal[1]==1 and stopsell then 0 else sellsignal[1], 0);

Plot Sell_Signal = sellsignal[1] ==0 and sellsignal;
Sell_signal.setpaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
sell_signal.setDefaultColor(color.red);
Sell_signal.hidetitle();

Plot Momentum_Up = sellsignal[1]==1 and sellSignal==0;
Momentum_up.setpaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_up);
Momentum_up.setDefaultColor(color.yellow);
Momentum_up.hidetitle();

plot Colorbars = if buysignal ==1 then 1 else if sellsignal ==1 then 2 else if buysignal ==0 or sellsignal==0 then 3 else 0;
colorbars.hide();
Colorbars.definecolor("Buy_Signal_Bars", color.dark_green);
Colorbars.definecolor("Sell_Signal_Bars", color.red);
Colorbars.definecolor("Neutral", color.yellow);

AssignPriceColor(if Colorbars ==1 then colorbars.color("buy_signal_bars") else if colorbars ==2 then colorbars.color("Sell_Signal_bars") else  colorbars.color("neutral"));
 
#end

Converted to Pinescript for TradingView:
Code:
// Slim Ribbon Custom
// Free for use. Header credits must be included when any form of the code included in this package is used.
// Any indicator built on this indicator needs to attribute the original author's work
// v1.0 - barbaros - converted to pinescript

//@version=5
indicator("Slim Ribbon Custom", overlay = true)

price = input.source(close, "Price")
superfast_length = input.int(8, "Super Fast Length")
fast_length = input.int(13, "Fast Length")
slow_length = input.int(21, "Slow Length")
displace = input.int(0)

mov_avg8 = ta.ema(price, superfast_length)
mov_avg13 = ta.ema(price, fast_length)
mov_avg21 = ta.ema(price, slow_length)

plot(mov_avg8)
plot(mov_avg13)
plot(mov_avg21)

buy = mov_avg8 > mov_avg13 and mov_avg13 > mov_avg21 and low > mov_avg8
stopbuy = mov_avg8 <= mov_avg13
buynow = not buy[1] and buy

buysignal = 0
buysignal := buynow and not stopbuy ? 1 : buysignal[1] == 1 and stopbuy ? 0 : buysignal[1]

plotshape(buysignal[1] == 0 and buysignal==1, title='Buy Label', style=shape.labelup, location=location.belowbar, size=size.normal, text='Buy', textcolor=color.new(color.white, 0), color=color.new(color.green, 0))
plotshape(buysignal[1] ==1 and buysignal==0, title='Momentum Down Label', style=shape.labeldown, location=location.abovebar, size=size.normal, text='MOM\nDown', textcolor=color.new(color.white, 0), color=color.new(color.gray, 0))

sell = mov_avg8 < mov_avg13 and mov_avg13 < mov_avg21 and high < mov_avg8
stopsell = mov_avg8 >= mov_avg13
sellnow = not sell[1] and sell

sellsignal = 0
sellsignal := sellnow and not stopsell ? 1 : sellsignal[1] == 1 and stopsell ? 0 : sellsignal[1]

plotshape(sellsignal[1] ==0 and sellsignal, title='Sell Label', style=shape.labeldown, location=location.abovebar, size=size.normal, text='Sell', textcolor=color.new(color.white, 0), color=color.new(color.red, 0))
plotshape(sellsignal[1]==1 and sellsignal==0, title='Momentum Up Label', style=shape.labelup, location=location.belowbar, size=size.normal, text='MOM\nUp', textcolor=color.new(color.white, 0), color=color.new(color.gray, 0))

Colorbars = buysignal ==1 ? 1 : sellsignal ==1 ? 2 : buysignal ==0 or sellsignal==0 ? 3 : 0

barcolor(Colorbars ==1 ? color.new(color.green, 0) : Colorbars ==2 ? color.new(color.red, 0) : color.new(color.gray, 0))

YRfpHMX.png
 
Top