يقوم Pine Script ™ الآن بعمل تدرجات عمودية!

Oct 5, 2022

الإضافات الجديدة التالية لـدالة fill() تمكن من إنشاء تدرجات رأسية:

fill(plot1, plot2, top_value, bottom_value, top_color, bottom_color)

 

fill(hline1, hline2,  top_value, bottom_value, top_color, bottom_color)

تقبل جميع المعلمات في الإضافات الجديدة وسيطات المتسلسلة. تقوم بإنشاء تدرج عمودي بين “top_color” و “bottom_color” في المسافة بين “top_value” و “bottom_value”. تعمل المخططات أو الخطوط hlines المستخدمة في الوسيطتين الأوليين كقناع فوق التدرج اللوني، مما يحدد أي جزء من التدرج يكون مرئيًا.

انظر هنا كيف نمنح MACD القديم مظهرًا جديدًا بتدرجين عموديين، أحدهما لملء الفراغ بين المتوسطين المتحركين، والآخر لما يتم تمثيله عادةً كمدرج تكراري:

//@version=5
indicator("MACD")
[macd, signal, hist] = ta.macd(close, 12, 26, 9)

// Histogram
float  maxHist  = ta.highest(hist, 100)
float  minHist  = ta.lowest(hist,  100)
bool   histBull = hist > 0
color  topHistColor = histBull ? color.new(color.green, 90) : color.red
color  botHistColor = histBull ? color.green : color.new(color.red, 90)
float  topHistValue = histBull ? maxHist : 0
float  botHistValue = histBull ? 0 : minHist
histPlot   = plot(hist, "Histogram", color(na))
centerPlot = plot(0,    "Middle",    color(na))
fill(histPlot, centerPlot, topHistValue, botHistValue, topHistColor, botHistColor)

// Averages
float  maxLine  = ta.highest(math.max(macd, signal), 100)
float  minLine  = ta.lowest(math.min(macd, signal), 100)
bool   lineBull = macd > signal
color  topLineColor = lineBull ? color.new(color.lime, 90) : color.fuchsia
color  botLineColor = lineBull ? color.lime : color.new(color.fuchsia, 90)
float  topLineValue = lineBull ? maxLine : maxLine
float  botLineValue = lineBull ? minLine : minLine
macdPlot   = plot(macd,   "MACD",   color.gray,   1)
signalPlot = plot(signal, "Signal", color.silver, 1)
fill(macdPlot, signalPlot, topLineValue, botLineValue, topLineColor, botLineColor)

في المثال التالي، نقوم بإنشاء Pine  باستخدام تدرج لوني للخلفية والآخر لـ RSI– خط الشجرة القائم:

/@version=5
indicator("Gradient Fill: Night in the Pine forest")

// Sky
skyTopColor = input.color(color.rgb(144, 191, 249, 1))
skyBotColor = input.color(color.rgb(251, 192, 45, 1))
skyPlot     = plot(100, color = skyTopColor)
groundPlot  = plot(0, color = color.black)
fill(skyPlot, groundPlot, 100, 0, skyTopColor, skyBotColor)

// Trees
crownsVal = ta.rsi(close, 20)
treesPlot = plot(crownsVal, color = color.rgb(6, 126, 116))
fill(treesPlot, groundPlot, crownsVal, 0, color.rgb(6, 126, 116), color.black)

فيما يلي بعض الأمثلة الأخرى التي نشرها بعض PineCoders في نصوص المجتمع البرمجية:

قنوات حجم دلتا مؤشر بواسطة LucF

RSI – لون التنفيذ مؤشر بواسطة فيكيرا

مؤشر القوة النسبية لـ Webby مؤشر بواسطة جون ماتشو

للبقاء على اطلاع بميزات Pine الجديدة، راقب دليل المستخدم ملاحظات الإصدار. يبث حساب PineCoders أيضًا تحديثات من Squawk Box على تيليغرام، وحساب تويتر، ومن الدردشة العامة “Pine Script ™ Q&A” على TradingView.

نأمل أن تجد هذا الميزات المطلوبة بشدة مفيدة. يرجى الاستمرار في إرسال ملاحظاتك واقتراحاتك إلينا للتحسين. نحن نبني TradingView لتفيدك، ونحن حريصون دائمًا على الاستماع إليك.

Look first Then leap

تم إنشاء TradingView خصيصًا لك، لذا تأكد من حصولك على أقصى استفادة من خدماتنا الرائعة
فتح الرسم البياني