[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Parabolic SAR for Heikin Ashi Charts



PureBytes Links

Trading Reference Links

Hi there,

I am trying to modify the Parabolic SAR formula I found on 
Amibroker's website (written by Thomas Ludwig)so that it uses Heikin 
ashi O, H, L and C instead of normal O, H, L, C. I tried to do this 
by simply replacing all the O, H, L, and C in the SAR formula by the 
corresponding Heikin Ashi HaClose, HaOpen, HaHigh and HaLow. However, 
this just doesn't work and I can't find out why. Whenever I am trying 
to blot the SAR, it says that it is EMPTY and no curve can be seen.
The two formulas are lised below.
Any help would be greatly appreciated!
Thanks a lot!



//Heikin Ashi:

HaClose = (O+H+L+C)/4; 
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); 
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 
HaLow = Min( L, Min( HaClose, HaOpen ) ); 



// Parabolic SAR (ParabXO): 

acc=Param("Acceleration factor",0.02,0.01,0.05,0.01);
af_start=Param("Starting AF value",0.02,0.01,0.05,0.01);
af_max=Param("Maximum AF value",0.2,0.1,0.3,0.01);
Ct=Param("Crossover threshold in %",1,0,3,0.5);
Ct1=Ct/100;

IAF = acc; 
MaxAF = af_max;     // max acceleration

psar = Close;		// initialize
long = 1;        // assume long for initial conditions
af = af_start;   // starting value of the acelleration factor
ep = Low[ 0 ];   // init extreme point
hp = High [ 0 ];
lp = Low [ 0 ];

for( i = 2; i < BarCount; i++ )
{
	if ( long )
	{
		psar [ i ] = psar [ i-1 ] + af * ( hp - psar [ i-
1 ] );
	}
	else
	{
		psar [ i ] = psar [ i-1 ] + af * ( lp - psar [ i-
1 ] );
	}

	reverse =  0;
	//check for reversal
	if ( long )
	{
		if ( Low [ i ] < psar [ i ] * (1-Ct1) )
		{
			long = 0; reverse = 1; // reverse position to 
Short
			psar [ i ] =  hp;       // SAR is High point 
in prev trade
			lp = Low [ i ];
			af = af_start;
		}
	}
	else
	{
		if ( High [ i ] > psar [ i ] * (1+Ct1) )
		{
			long = 1; reverse = 1;        //reverse 
position to long
			psar [ i ] =  lp;
			hp = High [ i ];
			af = af_start;
		}
	}

	if ( reverse == 0 )
	{
		if ( long )
		{
			if ( High [ i ] > hp ) 
			{
				hp = High [ i ]; 
				af = af + IAF; 
				if( af > MaxAF ) af = MaxAF; 
			}
             
			if( Low[ i - 1 ] < psar[ i ] ) psar[ i ] = Low
[ i - 1 ];
			if( Low[ i - 2 ] < psar[ i ] ) psar[ i ] = Low
[ i - 2 ];
		}
       else
		{
			if ( Low [ i ] < lp )  
			{ 
				lp = Low [ i ]; 
				af = af + IAF; 
				if( af > MaxAF ) af = MaxAF; 
			}	
				
			if( High[ i - 1 ] > psar[ i ] ) psar[ i ] = 
High[ i - 1 ];
			if( High[ i - 2 ] > psar[ i ] ) psar[ i ] = 
High[ i - 2 ];

		}
	}
}


Plot( psar, _DEFAULT_NAME(), ParamColor( "Color", colorRed ), 
styleDots | styleNoLine | styleThick ); 



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/