함수설명

종가 파라볼릭(Parablic Stop And Reverse) 지표함수

작성방법

CSar(AF, AFMAX)

매개변수 설명

<aside> 📘 계산 익일Sar = 당일Sar + (극단값-당일CSar)X가속도 일반 파라볼릭은 극단값으로 고가와 저가를 사용하고 파라볼릭 종가는 극단값으로 종가를 사용합니다.

</aside>

활용예시

//인라인함수(수식안에서 만들어 사용하는 함수)
Function Infx_CSAR  Numeric 
{
	Input	: AF(NumericSimple), AFMAX(NumericSimple);
	Var		: Direction(0), SAR_Value(Close), AF_Value(.02), HighValue(High), LowValue(Low), EP(0);

	if EP != 0 Then
	{
		if Direction == 1 then
		{
			EP = HighValue;
			SAR_Value = SAR_Value + AF_Value * (EP - SAR_Value);

			if High > HighValue then
			{
				HighValue = High;
				AF_Value = AF_Value + AF;
				if AF_Value >= AFMAX then AF_Value = AFMAX;
			}

			if Close < SAR_Value then
			{
				Direction 	= -1;
				SAR_Value 	= EP;
				AF_Value 	= 0;
				EP 			= 0;
				LowValue 	= low;
			}
		}
		else
		{
			EP = LowValue;
			SAR_Value = SAR_Value + AF_Value * (EP - SAR_Value);

			if Low < LowValue then
			{
				LowValue = Low;
				AF_Value = AF_Value + Af;
				if AF_Value >= AFMAX then AF_Value = AFMAX;
			}

			if Close > SAR_Value then
			{
				Direction = 1;
				SAR_Value = EP;
				AF_Value = 0;
				EP = 0;
				HighValue = High;
			}
		}

		Infx_CSAR = SAR_Value;
	}
	else
	{
		if SAR_Value != 0 && EP == 0 then
		{
			if Direction == 1 then
			{
				EP = HighValue;
				AF_Value = AF;
				SAR_Value = SAR_Value + AF_Value * (EP - SAR_Value);

				if High > HighValue  then
				{
					HighValue = High;
					AF_Value = AF_Value + AF;

					if AF_Value >= AFMAX then AF_Value = AFMAX;
				}
			}
			else
			{
				EP = LowValue;
				AF_Value = Af;
				SAR_Value = SAR_Value + AF_Value * (EP - SAR_Value);

				if Low < LowValue then
				{
					LowValue = Low;
					AF_Value = AF_Value + AF;

					if AF_Value >= AFMAX then AF_Value = AFMAX;
				}
			}

			Infx_CSAR = SAR_Value;
		}
		else
		{
			if Direction == 0 then
			{
				if Close > Close[1] then Direction = 1;
				else 
					if Close < Close[1] then Direction = -1;

			}
			else 
			{
				if Direction == 1 then
				{
					if Close < Close[1] then
					{
						Direction = -1;
						SAR_Value = HighValue;
						Infx_CSAR = SAR_Value;
					}
				}

				if Direction == -1 then
				{
					if Close > Close[1] then
					{
						Direction = 1;
						SAR_Value = LowValue;
						Infx_CSAR = SAR_Value;
					}
				}
			}

			LowValue 	= min(Low, 	LowValue);
			HighValue 	= max(High, HighValue);
		}
	}	
}
EndFunction

input : af(0.02),maxaf(0.2);
var : CSarv(0);

CSarv = Infx_CSAR(af,maxaf);

Plot1(CSarv);

<aside> 💡 뒤로가기는 좌측상단의 목차 버튼을 눌러주세요.

</aside>