АмиБрокер. Долгосрочный свечной осциллятор Heikin-ashi

Метод торговли ETF с использованием осциллятора Heikin-ashi.

свечной осциллятор heikin-ashi

Чтобы использовать код, введите формулу в редакторе AFL, затем нажмите кнопку «Вставить индикатор» для отображения графика.

Формула осциллятора Heikin-ashi

// Heikin-Ashi Candles Oscillator 
Avgp = Param( "TEMA average", 55, 1, 100 ); 
CandleSize = Param( "Candle Size factor", 1.1, 0.01, 5, 0.01 ); 
LTAverage = Param( "Shorting LT Average", 60, 1, 200 ); 

price = ( O + H + L + C ) / 4; 

haOpen = AMA( Ref( price, -1 ), 0.5 ); 

haC = ( price + haOpen + Max( H, haOpen ) + Min( L, haOpen ) ) / 4; 

ZlHa = TEMA( haC, Avgp ) + ( TEMA( haC, Avgp ) - 
	( TEMA( TEMA( haC, Avgp ), Avgp ) ) ); 

ZlCl = TEMA( ( H + L ) / 2, Avgp ) + ( TEMA( ( H + L ) / 2, Avgp ) - 
	( TEMA( TEMA( ( H + L ) / 2, Avgp ), Avgp ) ) ); 

keep1 = Hold( haC >= haOpen, 2 ) OR C >= haC OR 
	( H > Ref( H, -1 ) OR L > Ref( L, -1 ) ); 
keep2 = ( ZlCl - ZlHa ) >= 0; 
keeping = ( keep1 OR keep2 ); 
keepall = keeping OR ( Ref( keeping, -1 ) AND C >= O OR C >= Ref( C, -1 ) ); 
keep3 = ( abs( C - O ) < ( H - L ) * CandleSize AND H >= Ref( L, -1 ) ); 
utr = Keepall OR ( Ref( keepall, -1 ) AND keep3 ); 
keep1 = Hold( haC < haOpen, 2 ); 
keep2 = ( ZlCl - ZlHa ) < 0; 
keep3 = abs( C - O ) < ( H - L ) * CandleSize AND L <= Ref( H, -1 ); 
keeping = keep1 OR keep2; 
keepall = keeping OR ( Ref( keeping, -1 ) AND C < O OR C < Ref( C, -1 ) ); 
dtr = Keepall OR ( Ref( keepall, -1 ) AND keep3 ) == 1; 
upw = dtr == 0 AND Ref( dtr, -1 ) AND utr; 
dnw = utr == 0 AND Ref( utr, -1 ) AND dtr; 
Result = IIf( upw, 1, IIf( dnw, 0, ValueWhen( upw + dnw, upw ) ) ); 
LTSell = C < EMA( C, LTAverage ); 
LTResult = Flip( Result, Result == 0 AND LTSell ); 
Haco = IIf( Result, 100, IIf( LTResult, 50, 0 ) ); 


Plot( Haco , "HACO"+_PARAM_VALUES(), ParamColor("Color", colorRed)); 

pHaco = Ref( Haco, -1 ); 

Buy = Haco == 100 AND pHaco != 100; 
Sell = ( Haco == 50 OR Haco == 0 ) AND pHaco == 100; 
Short = Haco == 0 AND pHaco != 0; 
Cover = Buy;

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *