كيفية إنشاء مؤشرات نقطة المحور والفركتال VIDEO
تعتمد العديد من المؤشرات والاستراتيجيات على كائنات المخطط لتقديم المعلومات الأساسية، ويوفر cTrader Algo طرق API المطلوبة لرسم مثل هذه الكائنات. يتم رسم نقاط المحور والفركتالات، على وجه الخصوص، على مخططات التداول للمساعدة في تحديد مستويات الأسعار الحرجة ونقاط التحول.
في هذه المقالة والفيديو المقابل، ستتعلم كيفية رسم نقاط المحور والفركتالات على المخططات.
إنشاء مؤشر نقطة المحور نقاط المحور هي مستويات أسعار محسوبة من الأسعار السابقة. تشير هذه النقاط إلى مناطق محتملة للدعم أو المقاومة.
سننشئ مؤشرًا يرسم نقاط المحور اليومية على المخطط.
في cTrader Algo، انتقل إلى علامة التبويب المؤشرات وانقر على جديد . اكتب اسمًا للمؤشر الجديد ثم انقر على زر إنشاء .
قم بتعديل المؤشر في محرر الكود لجعله مؤشر تراكب.
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
حدد واحصل على الشموع اليومية في طريقة Initialize().
Bars _bars ;
protected override void Initialize ()
{
_bars = MarketData . GetBars ( TimeFrame . Daily , SymbolName );
}
احسب مستويات الدعم والمقاومة المختلفة المعروفة باسم نقاط المحور. يتم حساب سبع قيم تشمل نقطة المحور وثلاثة مستويات مقاومة وثلاثة مستويات دعم.
var pivot = ( _bars . HighPrices . Last ( 1 ) + _bars . LowPrices . Last ( 1 ) + _bars . ClosePrices . Last ( 1 )) / 3 ;
var r1 = 2 * pivot - _bars . LowPrices . Last ( 1 );
var s1 = 2 * pivot - _bars . HighPrices . Last ( 1 );
var r2 = pivot + _bars . HighPrices . Last ( 1 ) - _bars . LowPrices . Last ( 1 );
var s2 = pivot - _bars . HighPrices . Last ( 1 ) + _bars . LowPrices . Last ( 1 );
var r3 = _bars . HighPrices . Last ( 1 ) + 2 * ( pivot - _bars . LowPrices . Last ( 1 ));
var s3 = _bars . LowPrices . Last ( 1 ) - 2 * ( _bars . HighPrices . Last ( 1 ) - pivot );
بما أنه تم حساب نقاط المحور، يمكن رسمها على المخطط باستخدام خطوط الاتجاه.
Chart . DrawTrendLine ( "pivot " , _bars . OpenTimes . LastValue , pivot , _bars . OpenTimes . LastValue . AddDays ( 1 ), pivot , Color . White );
Chart . DrawTrendLine ( "r1 " , _bars . OpenTimes . LastValue , r1 , _bars . OpenTimes . LastValue . AddDays ( 1 ), r1 , Color . Green );
Chart . DrawTrendLine ( "r2 " , _bars . OpenTimes . LastValue , r2 , _bars . OpenTimes . LastValue . AddDays ( 1 ), r2 , Color . Green );
Chart . DrawTrendLine ( "r3 " , _bars . OpenTimes . LastValue , r3 , _bars . OpenTimes . LastValue . AddDays ( 1 ), r3 , Color . Green );
Chart . DrawTrendLine ( "s1 " , _bars . OpenTimes . LastValue , s1 , _bars . OpenTimes . LastValue . AddDays ( 1 ), s1 , Color . Red );
Chart . DrawTrendLine ( "s2 " , _bars . OpenTimes . LastValue , s2 , _bars . OpenTimes . LastValue . AddDays ( 1 ), s2 , Color . Red );
Chart . DrawTrendLine ( "s3 " , _bars . OpenTimes . LastValue , s3 , _bars . OpenTimes . LastValue . AddDays ( 1 ), s3 , 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 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 PivotPointsExample : Indicator
{
Bars _bars ;
protected override void Initialize ()
{
_bars = MarketData . GetBars ( TimeFrame . Daily , SymbolName );
}
public override void Calculate ( int index )
{
var pivot = ( _bars . HighPrices . Last ( 1 ) + _bars . LowPrices . Last ( 1 ) + _bars . ClosePrices . Last ( 1 )) / 3 ;
var r1 = 2 * pivot - _bars . LowPrices . Last ( 1 );
var s1 = 2 * pivot - _bars . HighPrices . Last ( 1 );
var r2 = pivot + _bars . HighPrices . Last ( 1 ) - _bars . LowPrices . Last ( 1 );
var s2 = pivot - _bars . HighPrices . Last ( 1 ) + _bars . LowPrices . Last ( 1 );
var r3 = _bars . HighPrices . Last ( 1 ) + 2 * ( pivot - _bars . LowPrices . Last ( 1 ));
var s3 = _bars . LowPrices . Last ( 1 ) - 2 * ( _bars . HighPrices . Last ( 1 ) - pivot );
Chart . DrawTrendLine ( "pivot " , _bars . OpenTimes . LastValue , pivot , _bars . OpenTimes . LastValue . AddDays ( 1 ), pivot , Color . White );
Chart . DrawTrendLine ( "r1 " , _bars . OpenTimes . LastValue , r1 , _bars . OpenTimes . LastValue . AddDays ( 1 ), r1 , Color . Green );
Chart . DrawTrendLine ( "r2 " , _bars . OpenTimes . LastValue , r2 , _bars . OpenTimes . LastValue . AddDays ( 1 ), r2 , Color . Green );
Chart . DrawTrendLine ( "r3 " , _bars . OpenTimes . LastValue , r3 , _bars . OpenTimes . LastValue . AddDays ( 1 ), r3 , Color . Green );
Chart . DrawTrendLine ( "s1 " , _bars . OpenTimes . LastValue , s1 , _bars . OpenTimes . LastValue . AddDays ( 1 ), s1 , Color . Red );
Chart . DrawTrendLine ( "s2 " , _bars . OpenTimes . LastValue , s2 , _bars . OpenTimes . LastValue . AddDays ( 1 ), s2 , Color . Red );
Chart . DrawTrendLine ( "s3 " , _bars . OpenTimes . LastValue , s3 , _bars . OpenTimes . LastValue . AddDays ( 1 ), s3 , Color . Red );
}
}
}
اضغط على Ctrl + B أو انقر على بناء ، ثم أضف المؤشر إلى مخطط بالنقر على إضافة نسخة .
يجب أن ترى نقاط المحور مرسومة على المخطط.
إنشاء مؤشر الفركتال سنقوم بتطوير مؤشر منفصل يرسم الفركتالات على المخطط. كرر الخطوات من القسم السابق وأنشئ مؤشرًا آخر باسم جديد.
اجعل هذا المؤشر مؤشر تراكب.
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
ارسم أسهمًا فوق الشموع حيث تكون القيمة العالية أعلى من الشمعتين المجاورتين على كل جانب في طريقة Calculate().
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 . DrawIcon ( Bars . OpenTimes [ index ]. ToString (), ChartIconType . DownArrow , Bars . OpenTimes [ index - 2 ], Bars . HighPrices [ index - 2 ], Color . Red );
}
ارسم أسهمًا لأعلى أسفل الشموع حيث تكون القيمة المنخفضة أقل من الشمعتين المجاورتين على كل جانب.
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 . DrawIcon ( Bars . OpenTimes [ index ]. ToString (), ChartIconType . UpArrow , Bars . OpenTimes [ index - 2 ], Bars . LowPrices [ index - 2 ], Color . Green );
}
يمكنك نسخ الكود الكامل أدناه:
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 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 FractalsExample : 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 . DrawIcon ( Bars . OpenTimes [ index ]. ToString (), ChartIconType . DownArrow , Bars . OpenTimes [ index - 2 ], Bars . HighPrices [ index - 2 ], Color . Red );
}
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 . DrawIcon ( Bars . OpenTimes [ index ]. ToString (), ChartIconType . UpArrow , Bars . OpenTimes [ index - 2 ], Bars . LowPrices [ index - 2 ], Color . Green );
}
}
}
}
قم ببناء المؤشر وأضف نسخة إلى المخطط.
يجب أن ترى كائنات الفركتال معروضة على الشموع ذات الصلة على المخطط.
أظهرت هذه المقالة كيفية إضافة نقاط المحور والفركتالات إلى المخططات، مما يتيح التصور المناسب للمعلومات الرئيسية.