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

كيفية إنشاء مؤشرات جلسة التداول والدعم/المقاومة

توفر واجهة برمجة تطبيقات cTrader Algo الأنواع المطلوبة لإنشاء مؤشرات ترسم المستطيلات والخطوط والمثلثات والسحب والكائنات الأخرى على مخططات التداول. تُستخدم المستطيلات، على وجه الخصوص، على نطاق واسع لتسليط الضوء على الفترات المهمة ومناطق التوحيد ومستويات الدعم/المقاومة.

في هذه المقالة والفيديو المقابل، ستتعلم كيفية رسم مستطيلات تمثل جلسات التداول ومستويات الدعم/المقاومة على مخطط الرمز.

إنشاء مؤشر جلسة التداول

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

في هذا المثال، نريد إنشاء مؤشر يرسم جلسات التداول على المخطط.

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

ابدأ بتعديل المؤشر في محرر الكود. أولاً، اجعله مؤشر تراكب.

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

اكتب الكود لرسم مستطيل يشير إلى جلسة لندن على المخطط.

1
2
3
4
5
6
7
TimeSpan londonOpen = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 9, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("Greenwich Standard Time")).TimeOfDay;
TimeSpan londonClose = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 18, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("Greenwich Standard Time")).TimeOfDay;

Chart.DrawRectangle("London Session ", Server.Time.Date.Add(londonOpen), Chart.TopY, Server.Time.Date.Add(londonClose), Chart.BottomY, 
Color.FromArgb(50, 0, 50, 255)).IsFilled = true;

اضغط على Ctrl+B أو انقر على بناء، ثم أضف المؤشر إلى مخطط بالنقر على إضافة نسخة.

يمكن رؤية مستطيل جلسة لندن على المخطط.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
TimeSpan nyOpen = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 9, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")).TimeOfDay;
TimeSpan nyClose = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 18, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")).TimeOfDay;

Chart.DrawRectangle("NY Session ", Server.Time.Date.Add(nyOpen), Chart.TopY, Server.Time.Date.Add(nyClose), Chart.BottomY,
Color.FromArgb(50, 255, 50, 0)).IsFilled = true;

TimeSpan sydneyOpen = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 9, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time")).TimeOfDay;
TimeSpan sydneyClose = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 18, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time")).TimeOfDay;

Chart.DrawRectangle("Sydney Session ", Server.Time.Date.Add(sydneyOpen).AddDays(-1), Chart.TopY, Server.Time.Date.Add(sydneyClose),
Chart.BottomY, Color.FromArgb(50, 50, 255, 0)).IsFilled = true;

TimeSpan tokyoOpen = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 9, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")).TimeOfDay;
TimeSpan tokyoClose = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 18, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")).TimeOfDay;

Chart.DrawRectangle("Tokio Session ", Server.Time.Date.Add(tokyoOpen), Chart.TopY, Server.Time.Date.Add(tokyoClose), Chart.BottomY,
Color.FromArgb(50, 0, 50, 255)).IsFilled = true;

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

 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
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 TradingSessions : Indicator
    {
        protected override void Initialize()
        {

        }

        public override void Calculate(int index)
        {
            TimeSpan londonOpen = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 9, 0, 0),
            TimeZoneInfo.FindSystemTimeZoneById("Greenwich Standard Time")).TimeOfDay;
            TimeSpan londonClose = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 18, 0, 0),
            TimeZoneInfo.FindSystemTimeZoneById("Greenwich Standard Time")).TimeOfDay;

            Chart.DrawRectangle("London Session ", Server.Time.Date.Add(londonOpen), Chart.TopY, Server.Time.Date.Add(londonClose), Chart.BottomY, 
            Color.FromArgb(50, 0, 50, 255)).IsFilled = true;

            TimeSpan nyOpen = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 9, 0, 0),
            TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")).TimeOfDay;
            TimeSpan nyClose = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 18, 0, 0),
            TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")).TimeOfDay;

            Chart.DrawRectangle("NY Session ", Server.Time.Date.Add(nyOpen), Chart.TopY, Server.Time.Date.Add(nyClose), Chart.BottomY,
            Color.FromArgb(50, 255, 50, 0)).IsFilled = true;

            TimeSpan sydneyOpen = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 9, 0, 0),
            TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time")).TimeOfDay;
            TimeSpan sydneyClose = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 18, 0, 0),
            TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time")).TimeOfDay;

            Chart.DrawRectangle("Sydney Session ", Server.Time.Date.Add(sydneyOpen).AddDays(-1), Chart.TopY, Server.Time.Date.Add(sydneyClose),
            Chart.BottomY, Color.FromArgb(50, 50, 255, 0)).IsFilled = true;

            TimeSpan tokyoOpen = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 9, 0, 0),
            TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")).TimeOfDay;
            TimeSpan tokyoClose = TimeZoneInfo.ConvertTimeToUtc(new DateTime(Server.Time.Year, Server.Time.Month, Server.Time.Day, 18, 0, 0),
            TimeZoneInfo.FindSystemTimeZoneById("Tokyo Standard Time")).TimeOfDay;

            Chart.DrawRectangle("Tokyo Session ", Server.Time.Date.Add(tokyoOpen), Chart.TopY, Server.Time.Date.Add(tokyoClose), Chart.BottomY,
            Color.FromArgb(50, 0, 50, 255)).IsFilled = true;
        }
    }
}

أعد بناء المؤشر ثم تحقق من المخطط لرؤية جميع جلسات التداول الممثلة هناك.

إنشاء مؤشر دعم/مقاومة

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

قم بإنشاء مؤشر جديد باستخدام نفس الخطوات، ولكن قم بتعيين اسم مختلف له.

ابدأ التعديلات بتعيين IsOverlay إلى true.

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

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

اكتب الكود الذي يرسم منطقة المقاومة.

1
2
3
4
5
6
if (Bars.HighPrices[index - 2] > Bars.HighPrices[index - 1] && Bars.HighPrices[index - 2] > Bars.HighPrices[index] &&
Bars.HighPrices[index - 2] > Bars.HighPrices[index - 3] && Bars.HighPrices[index - 2] > Bars.HighPrices[index - 4])
{
    Chart.DrawRectangle(Bars.OpenTimes[index - 2].ToString(), Bars.OpenTimes[index - 2], Bars.HighPrices[index - 2], Bars.OpenTimes[index - 2].AddDays(1),
    Bars.ClosePrices[index - 2], Color.FromArgb(50, Color.Green)).IsFilled = true;
}

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

اكتب الكود الذي يرسم منطقة الدعم.

1
2
3
4
5
6
if (Bars.LowPrices[index - 2] < Bars.LowPrices[index - 1] && Bars.LowPrices[index - 2] < Bars.LowPrices[index] &&
Bars.LowPrices[index - 2] < Bars.LowPrices[index - 3] && Bars.LowPrices[index - 2] < Bars.LowPrices[index - 4])
{
    Chart.DrawRectangle(Bars.OpenTimes[index - 2].ToString(), Bars.OpenTimes[index - 2], Bars.ClosePrices[index - 2], Bars.OpenTimes[index - 2].AddDays(1),
    Bars.LowPrices[index - 2], Color.FromArgb(50, Color.Red)).IsFilled = true;
}

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

 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
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 SupportResistanceExample : Indicator
    {
        protected override void Initialize()
        {

        }

        public override void Calculate(int index)
        {
            if (Bars.HighPrices[index - 2] > Bars.HighPrices[index - 1] && Bars.HighPrices[index - 2] > Bars.HighPrices[index] &&
            Bars.HighPrices[index - 2] > Bars.HighPrices[index - 3] && Bars.HighPrices[index - 2] > Bars.HighPrices[index - 4])
            {
                Chart.DrawRectangle(Bars.OpenTimes[index - 2].ToString(), Bars.OpenTimes[index - 2], Bars.HighPrices[index - 2], Bars.OpenTimes[index - 2].AddDays(1),
                Bars.ClosePrices[index - 2], Color.FromArgb(50, Color.Green)).IsFilled = true;
            }

            if (Bars.LowPrices[index - 2] < Bars.LowPrices[index - 1] && Bars.LowPrices[index - 2] < Bars.LowPrices[index] &&
            Bars.LowPrices[index - 2] < Bars.LowPrices[index - 3] && Bars.LowPrices[index - 2] < Bars.LowPrices[index - 4])
            {
                Chart.DrawRectangle(Bars.OpenTimes[index - 2].ToString(), Bars.OpenTimes[index - 2], Bars.ClosePrices[index - 2], Bars.OpenTimes[index - 2].AddDays(1),
                Bars.LowPrices[index - 2], Color.FromArgb(50, Color.Red)).IsFilled = true;
            }
        }
    }
}

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

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