├── LICENSE ├── README.md └── IMPLEMENTATION EXPONENTIATION VIPER ADVANCED AND COMPACT ALGORITHMS /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 inner circle viper 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | پیاده‌سازی الگوریتم‌های پیشرفته و فشرده VIPER برای نمایی‌سازی (Exponentiation) 2 | این کد یک اسکریپت Pine Script است که در پلتفرم TradingView برای تحلیل داده‌های مالی استفاده می‌شود. هدف اصلی این کد پیاده‌سازی الگوریتم‌های پیشرفته و فشرده برای محاسبه تعداد ارقام اعشاری (Decimals) در مقادیر ورودی است. همچنین، این کد شامل نمایش داده‌های مختلف در قالب جدول‌های گرافیکی برای مقایسه خروجی الگوریتم‌ها است. 3 | 4 | توضیح بخش‌های مختلف کد: 5 | 1. تنظیمات اولیه 6 | pinescript 7 | //@version=6 8 | indicator(title = 'IMPLEMENTATION EXPONENTIATION VIPER ADVANCED AND COMPACT ALGORITHMS', shorttitle = 'IMPLEMENTATION EXPONENTIATION ', overlay = false) 9 | src = close * math.pow(10, 9) 10 | نسخه اسکریپت 6 است. 11 | عنوان اندیکاتور و تنظیمات اولیه مشخص شده است. 12 | مقدار src برابر با قیمت بسته شدن (Close) ضربدر توان 10 به توان 9 محاسبه شده است. 13 | 2. الگوریتم پیشرفته (Extended Algorithm) 14 | pinescript 15 | VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(_value) => 16 | decimals = int(na) 17 | to5tring = str.tostring(_value) 18 | validate = not na(str.tonumber(to5tring)) 19 | if not validate 20 | decimals := int(na) 21 | decimals 22 | else if validate 23 | getRadix = str.pos(to5tring, '.') 24 | if na(getRadix) 25 | decimals := 0 26 | decimals 27 | else 28 | toSubstr = str.substring(to5tring, getRadix + 1) 29 | decimals := str.length(toSubstr) 30 | decimals 31 | این الگوریتم تعداد ارقام اعشاری یک مقدار ورودی (که می‌تواند عدد صحیح، اعشاری یا رشته باشد) را محاسبه می‌کند. 32 | ابتدا مقدار ورودی به رشته تبدیل می‌شود. 33 | بررسی می‌شود که آیا مقدار معتبر است یا خیر. 34 | اگر مقدار معتبر باشد، موقعیت نقطه اعشار (.) شناسایی شده و تعداد ارقام بعد از آن محاسبه می‌شود. 35 | 3. الگوریتم فشرده (Compact Algorithm) 36 | pinescript 37 | VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(_in) => 38 | n = int(na) 39 | s = str.tostring(_in) 40 | p = str.pos(s, '.') 41 | n := na(str.tonumber(s)) ? int(na) : na(p) ? 0 : str.length(str.substring(s, p + 1)) 42 | n 43 | نسخه فشرده الگوریتم بالا است که با خطوط کمتری نوشته شده است. 44 | عملکرد مشابهی دارد و تعداد ارقام اعشاری را محاسبه می‌کند. 45 | 4. مقادیر نمونه (Example Values) 46 | pinescript 47 | float cnt0 = float(0.12345678901234567890) 48 | var int cnt1 = int(123456789012345678901) 49 | string cnt2 = '0.12345678901234567890' 50 | string cnt3 = '123456789012345678901' 51 | مقادیر نمونه‌ای از انواع مختلف داده (اعشاری، صحیح و رشته) تعریف شده‌اند. 52 | این مقادیر برای تست الگوریتم‌ها استفاده می‌شوند. 53 | 5. خروجی به صورت جدول 54 | pinescript 55 | if barstate.islast 56 | var VIPER_PANEL = table.new(position.top_center, 8, 18, bgcolor = color.rgb(0, 0, 255), border_color = #ffffff, border_width = -4, frame_color = #ffffff, frame_width = 2) 57 | 58 | ROWS(VIPER_PANEL, 0, 'PINE BULT-IN FUNCTIONS', 'LOADED VALUE', 'LOADED DECIMALS', 'RETURNS', 'VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED[VIPER]', 'VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT[]') 59 | در این بخش از کد، یک جدول گرافیکی (Table) ایجاد می‌شود که نتایج الگوریتم‌ها را به همراه مقادیر ورودی نمایش می‌دهد. 60 | ستون‌ها شامل اطلاعاتی نظیر نوع داده، مقدار ورودی، تعداد ارقام اعشاری، و خروجی الگوری 61 | -------------------------------------------------------------------------------- /IMPLEMENTATION EXPONENTIATION VIPER ADVANCED AND COMPACT ALGORITHMS: -------------------------------------------------------------------------------- 1 | IMPLEMENTATION EXPONENTIATION VIPER ADVANCED AND COMPACT ALGORITHMS 2 | //I_AM_THE_ALGORITHM 3 | //@version=6 4 | indicator(title = 'IMPLEMENTATION EXPONENTIATION VIPER ADVANCED AND COMPACT ALGORITHMS', shorttitle = 'IMPLEMENTATION EXPONENTIATION ', overlay = false) 5 | src = close * math.pow(10, 9) 6 | // === ALGORITHM EXTENDED VERSION === 7 | VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(_value) => // accepts float, integer, or string values 8 | decimals = int(na) // declare variable to hold count 9 | to5tring = str.tostring(_value) // convert _value to string 10 | validate = not na(str.tonumber(to5tring)) // check if this is a valid number 11 | if not validate // if number is invalidated 12 | decimals := int(na) // returns na 13 | decimals 14 | else if validate // else if number is validated 15 | getRadix = str.pos(to5tring, '.') // get position of separator character "." 16 | if na(getRadix) // if separator not found 17 | decimals := 0 // there are no decimal characters 18 | decimals 19 | else // else separator was found 20 | toSubstr = str.substring(to5tring, getRadix + 1) // create substring of decimal characters 21 | decimals := str.length(toSubstr) // returns number of decimal characters 22 | decimals 23 | 24 | // === ALGORITHM COMPACT VERSION === 25 | VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(_in) => //_in: float, integer, string | out: n Decimals 26 | n = int(na) 27 | s = str.tostring(_in) 28 | p = str.pos(s, '.') 29 | n := na(str.tonumber(s)) ? int(na) : na(p) ? 0 : str.length(str.substring(s, p + 1)) 30 | n 31 | 32 | 33 | 34 | // === EXAMPLE VALUES === 35 | float cnt0 = float(0.12345678901234567890) // form const type float 36 | var int cnt1 = int(123456789012345678901) // form const type integer 37 | string cnt2 = '0.12345678901234567890' // form const type string 38 | string cnt3 = '123456789012345678901' // form const type string 39 | 40 | float inp0 = input(0.1234567890123456, 'Float') // form input type float 41 | int inp1 = input(123456789012, 'Integer') // form input type integer 42 | string inp2 = input('0.12345678901234567890', 'String') // form input type string 43 | string inp3 = input('123456789012345678901', 'String') // form input type string 44 | 45 | float smp0 = syminfo.mintick // form simple type float 46 | int smp1 = timeframe.multiplier // form simple type integer 47 | string smp2 = timeframe.period // form simple type string 48 | 49 | float ser0 = close > open ? cnt0 : cnt0 // form series type float 50 | int ser1 = close > open ? cnt1 : cnt1 // form series type integer 51 | string ser2 = close > open ? cnt2 : cnt2 // form series type string 52 | string ser3 = close > open ? cnt3 : cnt3 // form series type string 53 | 54 | 55 | 56 | // === EXAMPLE OUTPUT === 57 | str(int _value) => // apply string across table cells where loaded argument type is int 58 | to5tring = str.tostring(_value) 59 | to5tring 60 | str(float _value) => // apply string across table cells where loaded argument type is float 61 | to5tring = str.tostring(_value, '#.#########################') 62 | to5tring 63 | str(string _value) => // apply string across table cells where loaded argument type is string 64 | to5tring = _value 65 | to5tring 66 | 67 | COLUMNS(_str, _column, _row, _t) => // single cell of string _str of number _column of number _row of table _t 68 | table.cell(_t, _column, _row, _str, text_color = #ffffff, text_halign = text.align_center) 69 | 70 | ROWS(_t, _row, _strC0, _strC1, _strC2, _strC3, _strC4, _strC5) => // single row of table _t of number _row of string columns _strCn 71 | COLUMNS(_strC0, 0, _row, _t) 72 | COLUMNS(_strC1, 1, _row, _t) 73 | COLUMNS(_strC2, 2, _row, _t) 74 | COLUMNS(_strC3, 3, _row, _t) 75 | COLUMNS(_strC4, 4, _row, _t) 76 | COLUMNS(_strC5, 5, _row, _t) 77 | 78 | if barstate.islast 79 | var VIPER_PANEL = table.new(position.top_center, 8, 18, bgcolor = color.rgb(0, 0, 255), border_color = #ffffff, border_width = -4, frame_color = #ffffff, frame_width = 2) 80 | 81 | ROWS(VIPER_PANEL, 0, 'PINE BULT-IN FUNCTIONS', 'LOADED VALUE', 'LOADED DECIMALS', 'RETURNS', 'VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED[VIPER]', 'VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT[]') 82 | 83 | ROWS(VIPER_PANEL, 1, 'const float', '0.1234567890123456', '16', str(cnt0), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(cnt0))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(cnt0)))) 84 | ROWS(VIPER_PANEL, 2, 'const int', '12345678901234567', '0', str(cnt1), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(cnt1))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(cnt1)))) 85 | ROWS(VIPER_PANEL, 3, 'const strng', '0.12345678901234567890', '20', str(cnt2), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(cnt2))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(cnt2)))) 86 | ROWS(VIPER_PANEL, 4, 'const strng', '123456789012345678901', '0', str(cnt3), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(cnt3))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(cnt3)))) 87 | 88 | ROWS(VIPER_PANEL, 5, 'input float', '"' + str(inp0) + '"', '16', str(inp0), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(inp0))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(inp0)))) 89 | ROWS(VIPER_PANEL, 6, 'input int', '"' + str(inp1) + '"', '0', str(inp1), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(inp1))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(inp1)))) 90 | ROWS(VIPER_PANEL, 7, 'input strng', '"' + str(inp2) + '"', '20', str(inp2), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(inp2))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(inp2)))) 91 | ROWS(VIPER_PANEL, 8, 'input strng', '"' + str(inp3) + '"', '0', str(inp3), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(inp3))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(inp3)))) 92 | 93 | ROWS(VIPER_PANEL, 9, 'simple float', 'syminfo.mintick', '2', str(smp0), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(smp0))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(smp0)))) 94 | ROWS(VIPER_PANEL, 10, 'simple int', 'timeframe.multiplier', '0', str(smp1), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(smp1))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(smp1)))) 95 | ROWS(VIPER_PANEL, 11, 'simple strng', 'timeframe.period', '0', str(smp2), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(smp2))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(smp2)))) 96 | 97 | ROWS(VIPER_PANEL, 12, 'series float', '0.1234567890123456', '16', str(ser0), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(ser0))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(ser0)))) 98 | ROWS(VIPER_PANEL, 13, 'series int', '12345678901234567', '0', str(ser1), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(ser1))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(ser1)))) 99 | ROWS(VIPER_PANEL, 14, 'series strng', '0.12345678901234567890', '20', str(ser2), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(ser2))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(ser2)))) 100 | ROWS(VIPER_PANEL, 15, 'series strng', '123456789012345678901', '0', str(inp3), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(ser3))), str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(ser3)))) 101 | var VIPER_PANEL1 = table.new(position.middle_center, 4, 8, bgcolor = #0000ff00) 102 | table.cell(VIPER_PANEL1, row = 0, column = 0, text = 'IMPLEMENTATION ALGORITHMS [COMPACT] AND [EXTENDED] ON CURRENT PRICE ', bgcolor = color.rgb(255, 0, 0), text_color = color.rgb(0, 0, 0)) 103 | table.cell(VIPER_PANEL1, row = 0, column = 1, text = 'IMPLEMENTATION ALGORITHMS [COMPACT] AND [EXTENDED] ON CURRENT PRICE ', bgcolor = color.rgb(238, 255, 0), text_color = color.rgb(0, 0, 0)) 104 | table.cell(VIPER_PANEL1, row = 0, column = 2, text = 'IMPLEMENTATION ALGORITHMS [COMPACT] AND [EXTENDED] ON CURRENT PRICE ', bgcolor = color.rgb(30, 0, 255), text_color = color.rgb(0, 0, 0)) 105 | table.cell(VIPER_PANEL1, row = 1, column = 0, text = 'current price ' + str.tostring(close) + '\n' + '[EXTENDED][number of decimals : ] ' + str.tostring(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(str(close))) + '\n\n' + '[COMPACT][number of decimals : ] ' + str(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(str(close))), bgcolor = color.rgb(0, 0, 0), text_color = color.rgb(242, 255, 0)) 106 | table.cell(VIPER_PANEL1, row = 1, column = 1, text = 'input ' + str.tostring(close) + '[base 10 ] ' + 'EXPONENT ' + str.tostring(VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(close)) + '\n' + 'FINAL RESULT ' + '\n' + str.tostring(close * math.pow(10, VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(close))), bgcolor = color.rgb(0, 0, 0), text_color = color.rgb(246, 255, 0)) 107 | table.cell(VIPER_PANEL1, row = 1, column = 2, text = 'input ' + str.tostring(close) + '[base 10 ] ' + 'EXPONENT ' + str.tostring(VIPER_ADVANCED_DECIMAL_ALGORITHM_EXTENDED(close)) + '\n' + 'FINAL RESULT ' + '\n' + str.tostring(close * math.pow(10, VIPER_ADVANCED_DECIMAL_ALGORITHM_COMPACT(close))), bgcolor = color.rgb(255, 230, 0), text_color = color.rgb(0, 0, 0)) 108 | // 109 | var table LOGO = table.new(position.bottom_center, rows = 1, columns = 1, bgcolor = color.rgb(255, 255, 255, 100)) 110 | table.cell(LOGO, 0, 0, 'VIPER™ DENOISE THEORY\n ' + 'IN MATH WE TRUST\n' + 'O ' + str.tostring(open) + ' H ' + str.tostring(high) + ' L ' + str.tostring(low) + ' C ' + str.tostring(close), text_size = size.normal, text_color = color.rgb(255, 0, 0)) 111 | --------------------------------------------------------------------------------