RicardoSantos

[RS]MicuRobert System V0

Request for MicuRobert.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?
//@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)