Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study("Multiple of current TF", "", true)
- resMult = input(4, minval = 1)
- vHtfShow = input(true, "Show HTF Being Used")
- f_resInMinutes() => _resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60. : timeframe.isminutes ? 1. : timeframe.isdaily ? 1440. : timeframe.isweekly ? 10080. : timeframe.ismonthly ? 43800. : na)
- f_multipleOfRes(_res, _mult) => _targetResInMin = _res * max(_mult, 1), _targetResInMin <= 0.083 ? "5S" : _targetResInMin <= 0.251 ? "15S" : _targetResInMin <= 0.501 ? "30S" : _targetResInMin <= 1440 ? tostring(round(_targetResInMin)) : _targetResInMin <= 43800 ? tostring(round(min(_targetResInMin / 1440, 365))) + "D" : tostring(round(min(_targetResInMin / 43800, 12))) + "M"
- targetResInString = f_multipleOfRes(f_resInMinutes(), resMult)
- tgt_close = security(syminfo.tickerid, targetResInString, close)
- plot(tgt_close)
- // Check target res.
- f_htfLabel(_txt, _y, _color, _offsetLabels) =>
- _t = int(time + (f_resInMinutes() * _offsetLabels * 60000)), var _lbl = label.new(_t, _y, _txt, xloc.bar_time, yloc.price, #00000000, label.style_none, color.gray, size.large), if barstate.islast
- label.set_xy(_lbl, _t, _y), label.set_text(_lbl, _txt), label.set_textcolor(_lbl, _color)
- if vHtfShow
- f_htfLabel(targetResInString, sma(high + 3 * tr, 10)[1], color.silver, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement