RicardoSantos

Function 2 Point Line using UNIX TIMESTAMP V1

experimental:
draws a line from 2 vectors(price, time)
update:
reformatted the function,
added automatic detection of the period multiplier by approximation(gets a bit goofy with stocks/week time),
example using timestamp() function.

offsetting is still bugged, i cant find a way around it atm.
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?
//@version=2
study(title='Function 2 Point Line using UNIX TIMESTAMP V1', shorttitle='f', overlay=true)
offset = input(100)

_p0 = 4.92
_t0 = timestamp(2011, 12, 19, 0, 0)
_p1 = 6.72
_t1 = timestamp(2012, 05, 21, 0, 0)


f_2p_line(_price0, _time0, _price1, _time1, _shift) =>
    _period_multiplier = lowest(change(time), 10)
    _diference_in_price = (_price1 - _price0)
    _diference_in_time = (_time1 - _time0)
    _fraction = (_diference_in_price / _diference_in_time)
    _current_time_plus_offset = (time + (_shift*_period_multiplier))
    _return = _price0 + (_fraction * (_current_time_plus_offset - _time0))

plot(f_2p_line(_p0, _t0, _p1, _t1, offset), color=color(blue, 0), offset=offset)