Pivot noktası ve Fractal göstergeleri nasıl oluşturulur VIDEO
Birçok gösterge ve strateji temel bilgileri sunmak için grafik nesnelerine dayanır ve cTrader Algo, bu tür nesneleri çizmek için gereken API yöntemlerini sağlar. Pivot noktaları ve Fractal'lar, özellikle kritik fiyat seviyelerini ve dönüm noktalarını belirlemeye yardımcı olmak için işlem grafiklerinde çizilir.
Bu makalede ve ilgili videoda, grafiklerde pivot noktaları ve Fractal'lar çizmeyi öğreneceksiniz.
Pivot noktası göstergesi oluşturun Pivot noktaları, önceki fiyatlardan hesaplanan fiyat seviyeleridir. Bu tür noktalar potansiyel destek veya direnç alanlarını gösterir.
Günlük pivot noktalarını bir grafikte çizen bir gösterge oluşturacağız.
cTrader Algo'da Göstergeler sekmesine gidin ve Yeni 'ye tıklayın. Yeni gösterge için bir ad yazın ve ardından Oluştur düğmesine tıklayın.
Göstergeyi bir bindirme göstergesi yapmak için kod düzenleyicide değiştirin.
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
Initialize() yönteminde günlük çubukları tanımlayın ve alın.
Bars _bars ;
protected override void Initialize ()
{
_bars = MarketData . GetBars ( TimeFrame . Daily , SymbolName );
}
Pivot noktaları olarak bilinen farklı destek ve direnç seviyelerini hesaplayın. Pivot noktasını oluşturan yedi değer, üç direnç seviyesi ve üç destek seviyesi hesaplanır.
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 );
Pivot noktaları hesaplandığı için, trend çizgileri kullanılarak grafikte çizilebilirler.
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 );
Aşağıdaki kodun tamamını kopyalayabilirsiniz:
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 tuşlarına basın veya Derle 'ye tıklayın, ardından Örnek ekle 'ye tıklayarak göstergeyi bir grafiğe ekleyin.
Pivot noktalarının grafikte çizildiğini görmelisiniz.
Fractal göstergesi oluşturun Grafikte Fractal'lar çizen ayrı bir gösterge geliştireceğiz. Önceki bölümdeki adımları tekrarlayın ve yeni bir adla başka bir gösterge oluşturun.
Bu göstergeyi bir bindirme göstergesi yapın.
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
Calculate() yönteminde, yüksek değerin her iki taraftaki iki bitişik çubuktan daha yüksek olduğu çubukların üzerine oklar çizin.
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 );
}
Çubukların altında, düşük değerin her iki taraftaki iki bitişik çubuktan daha düşük olduğu yerlerde yukarı oklar çizin.
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 );
}
Aşağıdaki kodun tamamını kopyalayabilirsiniz:
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 );
}
}
}
}
Göstergeyi oluşturun ve bir örneğini grafiğe ekleyin.
Grafikte ilgili mumlarda görüntülenen fractal nesnelerini görmelisiniz.
Bu makale, önemli bilgilerin doğru şekilde görselleştirilmesini sağlayarak grafiklere pivot noktaları ve fractalları nasıl ekleyeceğinizi göstermiştir.
Önceki Göstergelere bulut Ekleme Sonraki işlem seansı ve destek/direnç göstergeleri Oluşturma