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

كيفية إضافة السحب إلى مؤشرات cTrader

يتيح لك cTrader Algo رسم السحب بين الخطوط على الرسم البياني. تسمح لك هذه السحب بتحديد المناطق الرئيسية على الرسوم البيانية بسرعة واكتشاف التحولات في سلوك السوق.

في هذه المقالة والفيديو المصاحب لها، سنوضح لك كيفية إضافة السحب وتخصيصها في المؤشرات.

إضافة مؤشر

يتكون مؤشر Bollinger Bands النموذجي من نطاق علوي ونطاق سفلي ومتوسط متحرك بسيط في الوسط. لتحسين مظهر المؤشر، نخطط لملء المساحة بين النطاقات بسحابة.

لإنشاء المؤشر، افتح تطبيق Algo وانتقل إلى علامة التبويب المؤشرات. انقر على زر جديد، اكتب اسمًا للمؤشر، مثل "Bollinger Bands Cloud" ثم انقر على زر إنشاء.

يمكننا الآن تعديل كود المؤشر. سنجعل مثالنا مؤشر تراكب.

1
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]

ثم نضيف خطوط الإخراج الثلاثة المطلوبة لرسم Bollinger Bands على الرسم البياني.

1
2
3
4
5
6
7
8
[Output("Main", LineColor = "Yellow", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Main { get; set; }

[Output("Top", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Top { get; set; }

[Output("Bottom", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Bottom { get; set; }

نعلن عن مؤشر Bollinger Bands الخاص بنا.

1
private BollingerBands _bollingerBands;

نقوم بتهيئة المؤشر.

1
_bollingerBands = Indicators.BollingerBands(Bars.ClosePrices, 20, 2, MovingAverageType.Simple);

نملأ الخطوط بقيم المؤشر في طريقة Calculate().

1
2
3
Main[index] = _bollingerBands.Main[index];
Top[index] = _bollingerBands.Top[index];
Bottom[index] = _bollingerBands.Bottom[index];

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

 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
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None, IsOverlay = true)]

    public class BollingerBandsCloud : Indicator
    {

        [Output("Main", LineColor = "Yellow", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Main { get; set; }

        [Output("Top", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Top { get; set; }

        [Output("Bottom", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Bottom { get; set; }

        private BollingerBands _bollingerBands;


        protected override void Initialize()
        {
            _bollingerBands = Indicators.BollingerBands(Bars.ClosePrices, 20, 2, MovingAverageType.Simple);
        }

        public override void Calculate(int index)
        {
            Main[index] = _bollingerBands.Main[index];
            Top[index] = _bollingerBands.Top[index];
            Bottom[index] = _bollingerBands.Bottom[index];
        }
    }
}

انقر على بناء أو استخدم الاختصار Ctrl+B لبناء المؤشر.

أضف مثيل مؤشر لرمز EURUSD.

يجب أن ترى مؤشر Bollinger Bands نموذجي على الرسم البياني.

إضافة سحابة إلى Bollinger Bands

الآن، نعود إلى محرر الكود ثم نعمل على إضافة سحابة بين النطاقات.

لتحقيق هدفنا، نضيف سمة Cloud إلى المؤشر الموجود. تعليمات سمة Cloud المؤشر لرسم سحابة بين خطي Top وBottom.

1
[Cloud("Top", "Bottom", Opacity = 0.2)]

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

 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
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
    [Cloud("Top", "Bottom", Opacity = 0.2)]

    public class BollingerBandsCloud : Indicator
    {

        [Output("Main", LineColor = "Yellow", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Main { get; set; }

        [Output("Top", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Top { get; set; }

        [Output("Bottom", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Bottom { get; set; }

        private BollingerBands _bollingerBands;

        protected override void Initialize()
        {
            _bollingerBands = Indicators.BollingerBands(Bars.ClosePrices, 20, 2, MovingAverageType.Simple);
        }

        public override void Calculate(int index)
        {
            Main[index] = _bollingerBands.Main[index];
            Top[index] = _bollingerBands.Top[index];
            Bottom[index] = _bollingerBands.Bottom[index];
        }
    }
}

نعيد بناء الخوارزمية ثم نتحقق من مؤشرنا لنرى ما تغير.

يجب أن ترى سحابة حمراء بين النطاقات. إذا قمت بتغيير لون خط Top، سيتم تحديث لون السحابة تلقائيًا.

نعود إلى محرر الكود ونغير سمة Cloud لرسم سحابة فقط قبل خط Main (الأصفر).

1
[Cloud("Top", "Main", Opacity = 0.2)]

أعد بناء المؤشر ثم تحقق منه لتأكيد مظهره الجديد.

إضافة سحابة إلى تقاطع المتوسط المتحرك

سنقوم بإنشاء مؤشر جديد ونستخدمه لتوضيح كيفية إضافة سحب بألوان مختلفة إلى الرسم البياني. نهدف إلى تطوير مؤشر تقاطع المتوسط المتحرك (MA) مع سحابة خضراء للاتجاهات الصاعدة وسحابة حمراء للاتجاهات الهابطة.

كرر الخطوات من القسم السابق لإنشاء مؤشر جديد. هذه المرة، يجب أن يكون اسم المؤشر "MA Cloud".

نبدأ بتعديل المؤشر الجديد عن طريق تعيين خاصية IsOverlay إلى True.

1
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]

أضف سمة Cloud المطلوبة.

1
[Cloud("Fast", "Slow", Opacity = 0.2)]

أضف خطوط الإخراج وقم بتعريف المتوسطات المتحركة.

1
2
3
4
5
6
7
8
[Output("Fast", LineColor = "Green", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Fast { get; set; }

[Output("Slow", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries Slow { get; set; }

SimpleMovingAverage _fastMA;
SimpleMovingAverage _slowMA;

كرر الخطوة من المثال السابق (Bollinger Bands). قم بتهيئة المتوسطات المتحركة وتمرير القيم الناتجة إلى الخطوط بحيث يتم عرضها على الرسم البياني.

1
2
3
4
5
_fastMA = Indicators.SimpleMovingAverage(Bars.ClosePrices, 7);
_slowMA = Indicators.SimpleMovingAverage(Bars.ClosePrices, 13);

Fast[index] = _fastMA.Result[index];
Slow[index] = _slowMA.Result[index];

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

 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
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
    [Cloud("Top", "Bottom", Opacity = 0.2)]

    public class BollingerBandsCloud : Indicator
    {

        [Output("Main", LineColor = "Yellow", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Main { get; set; }

        [Output("Top", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Top { get; set; }

        [Output("Bottom", LineColor = "Red", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries Bottom { get; set; }

        private BollingerBands _bollingerBands;

        protected override void Initialize()
        {
            _bollingerBands = Indicators.BollingerBands(Bars.ClosePrices, 20, 2, MovingAverageType.Simple);
        }

        public override void Calculate(int index)
        {
            Main[index] = _bollingerBands.Main[index];
            Top[index] = _bollingerBands.Top[index];
            Bottom[index] = _bollingerBands.Bottom[index];
        }
    }
}

قم ببناء المؤشر وإضافة نسخة لعرض المؤشر على الرسم البياني.

تتغير ألوان السحابة عند كل تقاطع (تقاطع) للمتوسطات المتحركة.

أظهرت لك هذه المقالة كيفية إضافة سحب مفيدة إلى المؤشرات في cTrader.

Image title