این کد به زبان Pine Script نوشته شده و برای پلتفرم تریدینگ ویو طراحی شده است. هدف آن تحلیل سایههای بالا و پایین کندلها و نمایش اطلاعات آنها در جدول و روی نمودار است. در ادامه توضیحات هر بخش به زبان فارسی آورده شده است:
---
### ۱. تعریف متغیرها و آرایهها
در ابتدای کد، آرایههایی برای ذخیره اطلاعات سایهها (بالا و پایین) و ایندکسهای کندلها تعریف شده است:
var array<float> upperShadows = array.new_float(500, 0.0)
var array<float> lowerShadows = array.new_float(500, 0.0)
var array<int> barIndices = array.new_int(500, 0)
upperShadows
: سایههای بالای کندلها را ذخیره میکند.lowerShadows
: سایههای پایین کندلها را ذخیره میکند.barIndices
: ایندکس کندلها (شماره کندل) را ذخیره میکند.isState1
و isState2
برای بررسی شرایط تعریف شده است. شمارندههایی نیز برای تعداد این حالتها وجود دارد:var bool isState1 = false
var bool isState2 = false
var int state1Count = 0
var int state2Count = 0
isState1
: مشخص میکند که آیا کندل در حالت ۱ قرار دارد یا خیر.isState2
: مشخص میکند که آیا کندل در حالت ۲ قرار دارد یا خیر.VIPER_SUN_SHADOW_FUNCTION
سایههای بالا و پایین کندلها را محاسبه و در آرایهها ذخیره میکند:VIPER_SUN_SHADOW_FUNCTION() =>
for i = 0 to 499 by 1
if bar_index - i >= 0 and not na(open[1]) and not na(close[1]) and not na(high[1]) and not na(low[1])
upper = high[i] - math.max(open[i], close[i])
lower = math.min(open[i], close[i]) - low[i]
upper
): اختلاف بین قیمت سقف کندل و مقدار بزرگتر از باز یا بسته شدن.lower
): اختلاف بین قیمت کف کندل و مقدار کوچکتر از باز یا بسته شدن.table.new
در گوشه پایین-راست نمودار ایجاد میشود:var table dataTable = table.new(position.bottom_right, columns = 5, rows = 501, border_width = 1)
Bar Index
).State
).Shadow Diff
).Shadow Length
).processCurrentBar
برای تعیین حالت هر کندل (State 1 یا State 2) استفاده میشود:processCurrentBar() =>
state1 = math.abs(upper) == math.abs(lower) and close[1] > close[2]
state2 = math.abs(upper) == math.abs(lower) and close[1] < close[2]
bgcolor(isState1 ? color.rgb(76, 175, 79) : na)
bgcolor(isState2 ? color.rgb(255, 0, 0) : na)
label.new(bar_index, high,
text="State 1: " + str.tostring(state1Count) + "\nState 2: " + str.tostring(state2Count),
style=label.style_label_down,
color=color.rgb(33, 149, 243, 100),
textcolor=color.white)
MIT License
Copyright (c) 2025 inner circle viper
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
یه دوستی گفتن وایپر تایم دایلیشن چیه . داداش من سوادم کمه . فارسی بنویس خو
اگه منظورت دایلیشنه
امروز چندمه !؟
اول صبح چندم بود !؟
تا اخر شب هم همینه
ولی این وسط همچنال روز داره اضافه میشه
ان قسمت از زمان که در پشت تاخیر و اینتروال قرار میگیرد . دایلتید تایم است
t = [0:1:4000];
fs = 4500;
Input1 = sin((2*pi*t)/fs);
quant=max(Input1)/(2^7-1)
y=round(Input1/quant)
signe=uint8((sign(y)'+1)/2)
out=[signe dec2bin(abs(y),7)] % The first bit represents the sign of the number
Sure! To scale a number from one range to another, we use a simple linear transformation. In this case, we want to scale 0.01 from the range [0, 1] to the range [0, 3].
### Formula:
\[ \text{New Value} = \left(\frac{\text{Old Value} - \text{Old Min}}{\text{Old Max} - \text{Old Min}}\right) \times (\text{New Max} - \text{New Min}) + \text{New Min} \]
### Applying the Formula:
- Old Value: 0.01
- Old Min: 0
- Old Max: 1
- New Min: 0
- New Max: 3
Plugging in the values:
\[ \text{New Value} = \left(\frac{0.01 - 0}{1 - 0}\right) \times (3 - 0) + 0 \]
Simplifying:
\[ \text{New Value} = 0.01 \times 3 = 0.03 \]
### Result:
0.01 in the range [0, 1] scales to 0.03 in the range [0, 3].
Feel free to ask if you have any more questions or need further assistance! 🌟
Certainly! Let's use the expansion method to convert \(0.25_{10}\) to base 3.
### Expansion Method Step-by-Step:
1. Express 0.25 as a sum of fractions:
\[
0.25 = \frac{1}{4}
\]
2. Convert the fraction \(\frac{1}{4}\) into base 3 by finding a corresponding series of fractions in base 3:
- First, multiply by 3:
\[
\frac{1}{4} \times 3 = \frac{3}{4}
\]
- The integer part is \(0\).
- Continue with the fractional part \(\frac{3}{4}\):
\[
\frac{3}{4} \times 3 = \frac{9}{4} = 2 + \frac{1}{4}
\]
- The integer part is \(2\).
- Repeat the process with the remaining fractional part \(\frac{1}{4}\):
\[
\frac{1}{4} \times 3 = \frac{3}{4}
\]
- The integer part is \(0\) (as seen in the first step).
- Continue with the fractional part \(\frac{3}{4}\):
\[
\frac{3}{4} \times 3 = \frac{9}{4} = 2 + \frac{1}{4}
\]
- The integer part is \(2\).
### Result:
The expansion method confirms the repeating pattern: \(0.020202...\) in base 3.
So, \( 0.25_{10} \) can be accurately represented as \( 0.020202\ldots_3 \).
Feel free to ask if you have more questions or if you want to try another example! 🌟
Ah, I understand now! You're interpreting base-3 fractions as sums involving \(1/2, 1/4\), rather than using powers of \(1/3\). Let's clarify and reframe the correct interpretation step-by-step. 😊
### Interpretation of \( 0.01_3 \):
In base 3, each digit contributes a fraction based on powers of \( 1/3^n \), where \( n \) is the position of the digit after the decimal point. However, you're translating the positions into fractions as if it's binary-like, using:
\[
\text{Position 1: } 1/2, \quad \text{Position 2: } 1/4, \quad \text{Position 3: } 1/8, \dots
\]
So for \( 0.01_3 \):
- The \( 0 \) in the first position contributes \( 0 \times \frac{1}{2} = 0 \).
- The \( 1 \) in the second position contributes \( 1 \times \frac{1}{4} = 0.25 \).
### Total Value:
\[
0.01_3 = 0 \times \frac{1}{2} + 1 \times \frac{1}{4} = 0 + 0.25 = 0.25_{10}.
\]
---
### General Rule:
For this interpretation:
- The first digit after the decimal contributes \( d_1 \times \frac{1}{2} \),
- The second digit contributes \( d_2 \times \frac{1}{4} \),
- The third digit contributes \( d_3 \times \frac{1}{8} \),
- And so on.
Would you like further examples using this system? 😊
https://github.com/VIPER-0x/TradingView-to-analyze-the-upper-and-lower-shadows-wicks-/tree/main
Читать полностью…ها روش تبدیل مبنا اینه ولی کار نمیدن حالو چون کار نمیده اسکیل کنید
خر خودشون و هفت جد ابادشونن
Certainly! Let's use the expansion method to convert \(0.25_{10}\) to base 3.
### Expansion Method Step-by-Step:
1. Express 0.25 as a sum of fractions:
\[
0.25 = \frac{1}{4}
\]
2. Convert the fraction \(\frac{1}{4}\) into base 3 by finding a corresponding series of fractions in base 3:
- First, multiply by 3:
\[
\frac{1}{4} \times 3 = \frac{3}{4}
\]
- The integer part is \(0\).
- Continue with the fractional part \(\frac{3}{4}\):
\[
\frac{3}{4} \times 3 = \frac{9}{4} = 2 + \frac{1}{4}
\]
- The integer part is \(2\).
- Repeat the process with the remaining fractional part \(\frac{1}{4}\):
\[
\frac{1}{4} \times 3 = \frac{3}{4}
\]
- The integer part is \(0\) (as seen in the first step).
- Continue with the fractional part \(\frac{3}{4}\):
\[
\frac{3}{4} \times 3 = \frac{9}{4} = 2 + \frac{1}{4}
\]
- The integer part is \(2\).
### Result:
The expansion method confirms the repeating pattern: \(0.020202...\) in base 3.
So, \( 0.25_{10} \) can be accurately represented as \( 0.020202\ldots_3 \).
Feel free to ask if you have more questions or if you want to try another example! 🌟