OPEN-SOURCE SCRIPT

Average and Percentage Increase

//version=5
indicator("Average and Percentage Increase", overlay=false)

// حساب أعلى وأقل قيمة للسهم في آخر سنة (252 يوم)
highest_1year = ta.highest(high, 252)
lowest_1year = ta.lowest(low, 252)

// حساب أعلى وأقل قيمة للسهم في آخر 6 أشهر (126 يوم)
highest_6months = ta.highest(high, 126)
lowest_6months = ta.lowest(low, 126)

// حساب معدل القيم الأربع (أعلى وأقل قيمة في آخر سنة وآخر 6 أشهر)
average_value_4 = (highest_1year + lowest_1year + highest_6months + lowest_6months) / 4

// حساب معدل أعلى القيمتين (أعلى قيمة في آخر سنة وآخر 6 أشهر)
average_highs = (highest_1year + highest_6months) / 2

// حساب الزيادة المئوية لمعدل القيم الأربع بالنسبة لمعدل القيم القصوى
percentage_increase = ((average_value_4 - average_highs) / average_highs) * 100

// عرض النتائج في جدول بدون رسم أي مؤشرات
var table myTable = table.new(position.top_right, 1, 3)

if (bar_index == last_bar_index)
// عرض معدل القيم الأربع
table.cell(myTable, 0, 0, text="Average of 4 Values: " + str.tostring(average_value_4, "#.##"), text_color=color.white, bgcolor=color.blue)
// عرض معدل أعلى القيمتين
table.cell(myTable, 1, 0, text="Average of Highest (1Y & 6M): " + str.tostring(average_highs, "#.##"), text_color=color.white, bgcolor=color.green)
// عرض الزيادة المئوية
table.cell(myTable, 2, 0, text="Percentage Increase: " + str.tostring(percentage_increase, "#.##") + "%", text_color=color.white, bgcolor=color.red)
Bands and Channels

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer