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)