অন্তর্নির্মিত ফাংশন_ক্রস বিশ্লেষণ এবং নির্দেশাবলী

লেখক:নিনাবাদাস, সৃষ্টিঃ ২০২২-০৩-২৩ ০৮ঃ৫৬ঃ২৯, আপডেটঃ ২০২২-০৩-২৪ ১৬ঃ৫৪ঃ৩০

অন্তর্নির্মিত ফাংশন_ক্রস বিশ্লেষণ ও নির্দেশাবলী

এপিআই ডকুমেন্টেশনের গ্লোবাল ফাংশন কলামে _ক্রস ফাংশন দুটি সূচক লাইনের ক্রস-স্টেটস গণনা করতে ব্যবহৃত হয়

  • নিম্নলিখিত কোডগুলি ফাংশন দ্বারা বাস্তবায়িত হয়ঃ

    এটা লক্ষ করা উচিত যে যখনarr1ফাস্ট লাইন সূচকগুলির একটি অ্যারে হিসাবে সংজ্ঞায়িত করা হয় এবংarr2ধীর রেখার সূচকগুলির একটি অ্যারে হিসাবে সংজ্ঞায়িত করা হয়, দ্বারা ফেরত মান_Crossফাংশন একটি ধনাত্মক সংখ্যা, অর্থাৎ, ডকুমেন্টেশন প্রসঙ্গে অনুযায়ীa positive number is the upswing period, a negative number indicates the downswing period, and 0 means it is the same as the current price, এটা দেখা যাচ্ছে যে এই সময়ে,arr1উপরে ক্রস করেছেarr2n চক্রের জন্য, যথা দ্রুত লাইন আপ ধীর লাইন অতিক্রম, গোল্ডেন ক্রস নির্দেশ করে। একইভাবে, যদি_Crossফাংশন একটি ঋণাত্মক সংখ্যা ফেরত দেয়, এর অর্থ মৃত্যু ক্রস।

    যদি ` `arr1is defined as an array of slow line indicators, andarr2as an array of fast line indicators, the situation will be opposite. If the value returned by the_ ক্রসfunction is a positive number, it means death cross. If the value returned by the_ক্রস ` ` ফাংশন একটি নেতিবাচক সংখ্যা, এর অর্থ হল গোল্ডেন ক্রস।

// Return the number of upswing periods; a positive number represents the number of upswing periods, and a negative number represents the number of downswing periods, and 0 means it is the same as the current price  
$.Cross = function(arr1, arr2) {            // The number of parameters is 2. As you can see from the parameter names, these two parameters should be of array type. 
                                            // The array is like a line segment in the coordinate system where the X axis is the array index value and the Y axis is the index value. The function is to determine the intersection of two lines
    if (arr1.length !== arr2.length) {      // First, judge whether the lengths of the two compared arrays are equal 
        throw "array length not equal";     // If they are not equal, raise an error, for the unequal indicator lines cannot judge if crossed or not 
    }
    var n = 0;                              // Declare the variable n to record the cross-status; its initial value is 0, indicating not crossed
    for (var i = arr1.length-1; i >= 0; i--) {      // Traverse arr1,from the last element to the front 
        if (typeof(arr1[i]) !== 'number' || typeof(arr2[i]) !== 'number') { // when arr1 or arr2 is non-numeric type (namely invalid indicators), break the traversing loop 
            break;                                  // break the loop 
        }
        if (arr1[i] < arr2[i]) {                    // If arr1 < arr2, the n-- will record the comparative status of arr1 and arr2 from the beginning (that is, at the beginning, n will adjust automatically according to the comparative value of arr1[i] and arr2[i]; once the comparison relation between arr1[i] and arr2[i] opposite to n happens, it means the two lines crossed). 
            if (n > 0) {
                break;
            }
            n--;
        } else if (arr1[i] > arr2[i]) {             // If arr1 > arr2, then n++
            if (n < 0) {
                break;
            }
            n++;
        } else {                                    // arr1[i] == arr2[i], then break immediately 
            break;
        }
    }
    return n;                                       // Return n, indicating the number of periods with cross, 0 means equal indicator values
};
  • আমরা একটি অ্যারে ডেটা সিমুলেট করি এবং ফলাফল দেখতে এটি পাস করি

var arr1 = [1,2,3,4,5,6,8,8,9]     // Fast line indicator
var arr2 = [2,3,4,5,6,7,7,7,7]     // Slow line indicator
function main(){
    Log("_Cross(arr1, arr2) : ", _Cross(arr1, arr2))
    Log("_Cross(arr2, arr1) : ", _Cross(arr2, arr1))
}

img

আপনি দেখতে পাচ্ছেন ফলাফল ৩ এবং -৩।

ক্রস অবস্থান তিনটি কে-লাইন বারের সামনে।


আরো