ورود

ثبت نام

Amir

artaelevators

مشخصات معامله

قیمت در زمان انتشار:

۱.۵۹۶۷

توضیحات

//@version=5 indicator("Trendlines with Local Highs/Lows", overlay=true) length = input.int(5, minval=1, title="Lookback Period for Local High/Low") // پیدا کردن نقاط local high و local low localHigh = ta.pivothigh(high, length, length) localLow = ta.pivotlow(low, length, length) // ذخیره نقاط در آرایه‌ها (index و قیمت) var float highPrices = array.new_float() var int highIndexes = array.new_int() var float lowPrices = array.new_float() var int lowIndexes = array.new_int() if (not na(localHigh)) array.push(highPrices, localHigh) array.push(highIndexes, bar_index - length) if (not na(localLow)) array.push(lowPrices, localLow) array.push(lowIndexes, bar_index - length) // تابع رسم خطوط روند بین دو نقطه drawTrendLine(int idx1, float price1, int idx2, float price2, color col) => line.new(idx1, price1, idx2, price2, color=col, width=2) // رسم خطوط روند صعودی (از دو نقطه low به low) for i = 0 to array.size(lowPrices) - 2 idx1 = array.get(lowIndexes, i) price1 = array.get(lowPrices, i) idx2 = array.get(lowIndexes, i + 1) price2 = array.get(lowPrices, i + 1) if price2 > price1 drawTrendLine(idx1, price1, idx2, price2, color.green) // رسم خطوط روند نزولی (از دو نقطه high به high) for i = 0 to array.size(highPrices) - 2 idx1 = array.get(highIndexes, i) price1 = array.get(highPrices, i) idx2 = array.get(highIndexes, i + 1) price2 = array.get(highPrices, i + 1) if price2 < price1 drawTrendLine(idx1, price1, idx2, price2, color.red)