يعمل فريق برمجة Pine بجد لمواصلة تحسين Pine منذ طرح الإصدار v5 الخامس. فلنستعرض بعض الميزات التي طال انتظارها والتي أضافوها خلال الشهرين الماضيين.
زيادة أحمال الدوال
زيادة الأحمال overloads على الدوال هي اختلافات لدالة يمكن تعريفها في مكتبة أو تضمينها في برنامج نصي. تشترك الأحمال الزائدة في نفس اسم الدالة الأصلية ، ولكنها تستخدم كميات مختلفة من المعلمات أو معلمات من أنواع مختلفة. إنها مفيدة بشكل خاص في المكتبات ، حيث تكون أنواع المعلمات إلزامية.
في هذا المؤشر ، نحدد الحمل الزائد لدالة mult() التي تقبل ثلاث حجج:
//@version=5 indicator("Function overload") // Two parameters mult(x1, x2) => x1 * x2 // Three parameters mult(x1, x2, x3) => x1 * x2 * x3 plot(mult(7, 4)) plot(mult(7, 4, 2))
//@version=5 indicator("Function overload") // Accepts both 'int' and 'float' values because any 'int' can be automatically cast to 'float' mult(float x1, float x2) => x1 * x2 // Returns a 'bool' value instead of a number mult(bool x1, bool x2) => x1 and x2 ? true : false mult(string x1, string x2) => str.tonumber(x1) * str.tonumber(x2) // Has three parameters, so explicit types are not required mult(x1, x2, x3) => x1 * x2 * x3 plot(mult(7, 4)) plot(mult(7.5, 4.2)) plot(mult(true, false) ? 1 : 0) plot(mult("5", "6")) plot(mult(7, 4, 2))
FOR…IN
يتطلب التكرار عبر مصفوفة باستخدام بنية for منع إدخال الحلقة إذا كانت المصفوفة فارغة وتحميها من فهرس مصفوفة خارج الحدود.
هيكل دالة for…in الجديد يجعل حياتك أسهل من خلال التكرار على جميع عناصر المصفوفة من أجلك. التركيب اللغوي بسيط: for array_element in array_id ، سيتكرر على عناصر array_id بدءًا من الفهرس صفر ، مع تعيين قيمة عنصر المصفوفة إلى متغير array_element في كل تكرار. لن يحدث أي تكرار أو خطأ إذا كانت المصفوفة فارغة ، ويمكن إضافة عناصر المصفوفة أو إزالتها في التكرارات الحلقية.
في البرنامج النصي أدناه ، نستخدم for…in للعثور على أكبر رقم في المصفوفة a1:
//@version=5 indicator("For...in cycle") var int[] a1 = array.from(1, 3, 6, 3, 8, 0, -9, 5) highest(array) => var int highestNum = na for element in array if na(highestNum) or element > highestNum highestNum := element highestNum plot(highest(a1))
دوال STRING-MANIPULATION الجديدة
str.contains(source, str)
var isContinuous = str.contains(syminfo.tickerid, "!") plot(isContinuous ? 1 : 0)
s = input.string("Time to sell some NASDAQ:AAPL") pos = str.pos(s, ":") // Get the position of the ":" character tkr = str.substring(s, pos + 1) // "AAPL"
var source = "FTX:BTCUSD / FTX:BTCEUR" // Replace the first occurrence of "FTX" with the "BINANCE" replacement string var newSource = str.replace(source, "FTX", "BINANCE", 0)
s = str.lower("Time to Sell Some AAPL") // time to sell some aapl! s = str.upper("Time to Sell Some AAPL!") // TIME TO SELL SOME AAPL!
s = "It's time to sell some NASDAQ:AAPL!" var string tickerId = str.match(s, "[\\w]+:[\\w]+") //"NASDAQ:AAPL"
تحويل العملات CURRENCY CONVERSION
TEXTBOXES

للبقاء على اطلاع بميزات Pine الجديدة ، راقب ملاحظات إصدار دليل مستخدم Pine. تبث PineCoders أيضًا تحديثات على قناة Squawk Box Telegram و Twitter ومن الدردشة العامة Pine Script على TradingView.
نأمل أن تجد هذه الميزات المطلوبة بشدة مفيدة.
يرجى الاستمرار في إعطائنا ملاحظاتك واقتراحاتك للتحسين.
نحن نبني TradingView لك ، ونحن حريصون دائمًا على الاستماع إليك.