RicardoSantos

[RS]MicuRobert System V0

Request for MicuRobert.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
//@version=2
//  Request for MicuRobert
study(title='[RS]MicuRobert System V0', shorttitle='MAC', overlay=true)
src = input(title='Source series:', type=source, defval=close)
ma0_length = input(title='Moving average length', type=integer, defval=1)
ma1_length = input(title='Moving average length', type=integer, defval=50)
sl_in_pips = input(title='Stoploss in pips:', type=float, defval=4.00, step=0.01) * (syminfo.mintick*10)

ma0 = sma(src, ma0_length)
ma1 = sma(src, ma1_length)
plot(title='MA0', series=ma0, color=gray)
plot(title='MA1', series=ma1, color=black)

crossup = crossover(ma0, ma1)
crossdown = crossunder(ma0, ma1)
direction_up = barssince(crossup) <= barssince(crossdown)
plotshape(title='UP', series=crossup, style=shape.triangleup, location=location.abovebar, color=green)
plotshape(title='DOWN', series=crossdown, style=shape.triangledown, location=location.belowbar, color=maroon)

buy_sl = direction_up ? na(buy_sl[1]) ? low-sl_in_pips : max(low-sl_in_pips, buy_sl[1]) : na
sel_sl = not direction_up ? na(sel_sl[1]) ? high+sl_in_pips : min(high+sl_in_pips, sel_sl[1]) : na
plot(title='BSL', series=buy_sl, style=circles, color=black)
plot(title='SSL', series=sel_sl, style=circles, color=black)

buy_close = direction_up and crossunder(ma0, buy_sl)
sel_close = not direction_up and crossover(ma0, sel_sl)
plotshape(title='BX', series=buy_close, style=shape.xcross, location=location.belowbar, color=green)
plotshape(title='SX', series=sel_close, style=shape.xcross, location=location.abovebar, color=maroon)

open_range = input(title='Open range value:', type=float, defval=0.0020, step=0.00001)
isnewday = change(time('D'))!=0
open_price = isnewday ? open : open_price[1]
open_top = open_price + open_range
open_bot = open_price - open_range
plot(title='O', series=open_price, color=isnewday ? na : black)
plot(title='OT', series=open_top, color=isnewday ? na : blue)
plot(title='OB', series=open_bot, color=isnewday ? na : blue)