انتقل إلى المحتوى

كيفية رسم شوكة أندروز

شوكة أندروز هي أداة تحليل فني شائعة تُستخدم، أحيانًا مع مؤشرات أخرى، لتحديد مستويات الدعم والمقاومة المحتملة في سوق متجه. تعمل هذه المستويات كأساس حاسم لإستراتيجيات التداول الناجحة، مما يمنح المتداولين الوضوح والهيكل والثقة في قراراتهم.

سيوضح هذا المقال والفيديو المصاحب له كيفية إنشاء cBot يرسم شوكة أندروز على الرسم البياني، وبرمجة الشوكة للتحديث تلقائيًا مع تغير الرسم البياني.

رسم شوكة أندروز على الرسم البياني

تتكون شوكة أندروز من خط متوسط (خط المنتصف) وخطين متوازيين يشكلان قناة. تساعد هذه الأدوات المتداولين على تصور الاتجاهات، وتوقع تحركات الأسعار وتحديد نقاط الدخول والخروج المحتملة للصفقات.

يتم رسم شوكة أندروز على الرسم البياني للسعر باستخدام ثلاث نقاط رئيسية: قمة، وقاع، ونقطة قمة أو قاع لاحقة. غالبًا ما تتذبذب حركة السعر داخل هذه القناة بين الخطين العلوي والسفلي، بينما يعمل خط المنتصف كنقطة ارتداد.

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

في cTrader Algo، انقر فوق زر جديد لإنشاء cBot وأدخل اسمًا له، ثم انقر فوق إنشاء.

تتطلب شوكة أندروز ستة معلمات لتخزين ما يلي: مؤشرات القمة والقاعين، وسعرين أدنى وسعر مرتفع. قم بتعريف المعلمات الستة.

1
2
3
4
5
6
private int _highIndex;
private int _lowIndex1;
private int _lowIndex2;
private double _max;
private double _min1;
private double _min2;

اكتشف السعرين الأدنى والسعر المرتفع اللازمين لنقاط الشوكة.

1
2
3
_max = Bars.HighPrices.Maximum(50);
_min1 = Bars.LowPrices.Minimum(50);
_min2 = Bars.LowPrices.Minimum(10);

يتيح لك cTrader Algo تحديد الموقع الزمني من خلال الأساليب التي توفر إما الوقت المطلق أو مؤشر الشريط النسبي. تقدم الطريقة المستخدمة لرسم الشوكة على الرسم البياني التجاوزات ذات الصلة. في هذه الحالة، اخترنا مؤشر الشريط النسبي.

اكتب الكود لاكتشاف مؤشرات أسعار القمة والقاع.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
for (int i = 0; i <= 50; i++)
{
    if (Bars.HighPrices.Last(i) == _max)
        _highIndex = Bars.Count - i - 1;
}

for (int i = 0; i <= 50; i++)
{
    if (Bars.LowPrices.Last(i) == _min1)
        _lowIndex1 = Bars.Count - i - 1;
}

for (int i = 0; i <= 10; i++)
{
    if (Bars.LowPrices.Last(i) == _min2)
        _lowIndex2 = Bars.Count - i - 1;
}

ارسم الشوكة على الرسم البياني.

1
Chart.DrawAndrewsPitchfork("AndrewsPitchfork", _lowIndex1, _min1, _highIndex, _max, _lowIndex2, _min2, Color.Red);

يمكنك نسخ الكود الكامل أدناه:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
    public class AndrewsPitchfork : Robot
    {
        private int _highIndex;
        private int _lowIndex1;
        private int _lowIndex2;
        private double _max;
        private double _min1;
        private double _min2;

        protected override void OnStart()
        {
            _max = Bars.HighPrices.Maximum(50);
            _min1 = Bars.LowPrices.Minimum(50);
            _min2 = Bars.LowPrices.Minimum(10);

            for (int i = 0; i <= 50; i++)
            {
                if (Bars.HighPrices.Last(i) == _max)
                    _highIndex = Bars.Count - i - 1;
            }

            for (int i = 0; i <= 50; i++)
            {
                if (Bars.LowPrices.Last(i) == _min1)
                    _lowIndex1 = Bars.Count - i - 1;
            }

            for (int i = 0; i <= 10; i++)
            {
                if (Bars.LowPrices.Last(i) == _min2)
                    _lowIndex2 = Bars.Count - i - 1;
            }

            Chart.DrawAndrewsPitchfork("AndrewsPitchfork", _lowIndex1, _min1, _highIndex, _max, _lowIndex2, _min2, Color.Red);

        }

        protected override void OnTick()
        {
            // Handle price updates here
        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

لبناء cBot، استخدم اختصار لوحة المفاتيح Ctrl+B أو انقر فوق بناء.

أضف نسخة محلية من cBot: انقر فوق إضافة نسخة، حدد خيار محليًا، ثم انقر فوق إضافة نسخة.

انقر فوق النسخة وانتقل إلى علامة التبويب الاختبار العكسي. حدد فترة للاختبار العكسي، قم بتمكين خيار الوضع المرئي ثم انقر فوق أيقونة التشغيل.

يجب أن ترى شوكة أندروز مرسومة على الرسم البياني.

تحديث شوكة أندروز

عُد إلى تطبيق Algo وقم ببرمجة cBot لتحديث الشوكة مع تغير الرسم البياني.

قم بإنشاء طريقة جديدة لرسم الشوكة وانقل المنطق الأصلي إلى تلك الطريقة.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
private void DrawAndrewsPitchfork()
{
    _max = Bars.HighPrices.Maximum(50);
    _min1 = Bars.LowPrices.Minimum(50);
    _min2 = Bars.LowPrices.Minimum(10);

    for (int i = 0; i <= 50; i++)
    {
        if (Bars.HighPrices.Last(i) == _max)
            _highIndex = Bars.Count - i - 1;
    }

    for (int i = 0; i <= 50; i++)
    {
        if (Bars.LowPrices.Last(i) == _min1)
            _lowIndex1 = Bars.Count - i - 1;
    }

    for (int i = 0; i <= 10; i++)
    {
        if (Bars.LowPrices.Last(i) == _min2)
            _lowIndex2 = Bars.Count - i - 1;
    }

    if (_lowIndex1 < _highIndex && _highIndex < _lowIndex2)
        Chart.DrawAndrewsPitchfork("AndrewsPitchfork", _lowIndex1, _min1, _highIndex, _max, _lowIndex2, _min2, Color.Red);
}

استدعِ الطريقة الجديدة في طريقة OnBar().

1
2
3
4
protected override void OnBar()
{
    DrawAndrewsPitchfork();
}

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

1
2
if (_lowIndex1 < _highIndex && _highIndex < _lowIndex2)
    Chart.DrawAndrewsPitchfork("AndrewsPitchfork", _lowIndex1, _min1, _highIndex, _max, _lowIndex2, _min2, Color.Red);

يمكنك نسخ الكود الكامل أدناه:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None, AddIndicators = true)]
    public class AndrewsPitchfork : Robot
    {
        private int _highIndex;
        private int _lowIndex1;
        private int _lowIndex2;
        private double _max;
        private double _min1;
        private double _min2;

        protected override void OnStart()
        {

        DrawAndrewsPitchfork(); 

        }

        private void DrawAndrewsPitchfork() 
        {
           _max = Bars.HighPrices.Maximum(50);
            _min1 = Bars.LowPrices.Minimum(50);
            _min2 = Bars.LowPrices.Minimum(10);

            for (int i = 0; i <= 50; i++)
            {
                if (Bars.HighPrices.Last(i) == _max)
                    _highIndex = Bars.Count - i - 1;
            }

            for (int i = 0; i <= 50; i++)
            {
                if (Bars.LowPrices.Last(i) == _min1)
                    _lowIndex1 = Bars.Count - i - 1;
            }

            for (int i = 0; i <= 10; i++)
            {
                if (Bars.LowPrices.Last(i) == _min2)
                    _lowIndex2 = Bars.Count - i - 1;
            }

            if (_lowIndex1 < _highIndex && _highIndex < _lowIndex2)
                 Chart.DrawAndrewsPitchfork("AndrewsPitchfork", _lowIndex1, _min1, _highIndex, _max, _lowIndex2, _min2, Color.Red);
        }

        protected override void OnBar()
        {
            DrawAndrewsPitchfork(); 
        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

قم ببناء cBot مرة أخرى واختباره عكسيًا.

قم بزيادة سرعة الوضع المرئي وانقر فوق أيقونة التشغيل.

هذه المرة، يجب أن ترى كيف يتم إعادة رسم الشوكة باستمرار مع تغير الرسم البياني.

الملخص

شرح هذا المقال كيفية رسم شوكة أندروز على الرسم البياني للرمز وبرمجة الشوكة لتحديث نفسها مع تغير الرسم البياني.