Advertisement
PineCoders

4x Res

Feb 6th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. //@version=4
  2. study("Multiple of current TF", "", true)
  3. resMult = input(4, minval = 1)
  4. vHtfShow = input(true, "Show HTF Being Used")
  5. f_resInMinutes() => _resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60. : timeframe.isminutes ? 1. : timeframe.isdaily ? 1440. : timeframe.isweekly ? 10080. : timeframe.ismonthly ? 43800. : na)
  6. 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"
  7. targetResInString = f_multipleOfRes(f_resInMinutes(), resMult)
  8. tgt_close = security(syminfo.tickerid, targetResInString, close)
  9. plot(tgt_close)
  10. // Check target res.
  11. f_htfLabel(_txt, _y, _color, _offsetLabels) =>
  12. _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
  13. label.set_xy(_lbl, _t, _y), label.set_text(_lbl, _txt), label.set_textcolor(_lbl, _color)
  14. if vHtfShow
  15. f_htfLabel(targetResInString, sma(high + 3 * tr, 10)[1], color.silver, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement