답변완료
수정 부탁드립니다.
안녕하세요?
아래의 수식에서 두가지 수정을 하고싶습니다.
1. 이평선 삭제
2. 재진입 부분수정 (재진입은 1회만하고, 손/익절 이후 정상매매)
--> 정상진입후, 손/익절 범위내에서 반대신호가나면 1회만 재진입.
(매수 포지션보유시 매도신호에만 재진입, 또는 매도 포지션보유시 매수신호에만 재진입)
부탁드립니다.
감사합니다.
input : P1(5),P2(20),n(1);
input : 익절틱수(50),손절틱수(50);
var1 = ma(C,P1);
Var2 = ma(C,P2);
var3 = abs(C-O);
if MarketPosition == 0 and
countif(var1 > Var2 and C < O,3) == 3 and
Var3 == Var3[2] Then
Sell("s");
if MarketPosition == 0 and
countif(var1 > Var2 and C > O,3) == 3 and
Var3 == Var3[2] Then
Buy("b");
if MarketPosition == -1 and IsEntryName("s") == true and BarsSinceEntry <= n and C > O Then
Buy("sb");
if MarketPosition == 1 and IsEntryName("b") == true and BarsSinceEntry <= n and C < O Then
Sell("bs");
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
2020-12-07
556
글번호 144472
시스템
답변완료
TS OHLCPeriodsAgo (Function) 의 YES 변환 문의
수고하십니다.
TS의 함수중 지정 주기의 시고저종가를 반환하는 함수입니다.
YES 초보라서 좀 어렵네요.
YES 랭귀지 함수로 변환을 부탁드립니다.
감사합니다.
inputs:
PeriodType( numericsimple ),
PeriodsAgo( numericsimple ),
oPeriodOpen( numericref ),
oPeriodHigh( numericref ),
oPeriodLow( numericref ),
oPeriodClose( numericref ) ;
variables:
var0( 0 ), sess_last_bar(false) ;
arrays:
arr0[ 4, 50 ]( -1 ) ;
sess_last_bar = sessionlastbar;
condition1 = PeriodsAgo > 50 or BarType > IFF(PeriodType<>0, PeriodType + 1, PeriodType + 2) or BarType > 4 ;
if condition1 then
begin
oPeriodOpen = -1 ;
oPeriodHigh = -1 ;
oPeriodLow = -1 ;
oPeriodClose = -1 ;
OHLCPeriodsAgo = -1 ;
end
else
begin
if PeriodType = 0 then
Condition1 = sess_last_bar[1]
else if PeriodType = 1 then
Condition1 = Date <> Date[1]
else if PeriodType = 2 then
Condition1 = DayOfWeek( Date ) < DayOfWeek( Date[1] )
else if PeriodType = 3 then
Condition1 = Month( Date ) <> Month( Date[1] )
else if PeriodType = 4 then
Condition1 = Year( Date ) <> Year( Date[1] ) ;
condition1 = CurrentBar = 1 or Condition1 ;
if condition1 then
begin
var0 = var0 - 1 ;
if var0 = -1
then var0 = 50 ;
arr0[ 1, var0 ] = O ;
arr0[ 2, var0 ] = H ;
arr0[ 3, var0 ] = L ;
arr0[ 4, var0 ] = C ;
end
else
begin
condition1 = H > arr0[ 2, var0 ] ;
if condition1 then arr0[ 2, var0 ] = H ;
condition1 = L < arr0[ 3, var0 ] ;
if condition1 then arr0[ 3, var0 ] = L ;
arr0[ 4, var0 ] = C ;
end ;
oPeriodOpen = arr0[ 1, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodHigh = arr0[ 2, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodLow = arr0[ 3, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodClose = arr0[ 4, Mod( var0 + PeriodsAgo, 51 ) ] ;
OHLCPeriodsAgo = 1 ;
end ;
if false then
Value1 = OHLCPeriodsAgo[1] ;
--------------------------------------------------------------------------
아래는 함수 설명입니다.
OHLCPeriodsAgo (Function)
image₩trumpet2.gif Disclaimer
The OHLCPeriodsAgo series function returns the Open, High, Low, and Close of a specified time segment, a specified number of periods ago.
Syntax
OHLCPeriodsAgo(PeriodType, PeriodsAgo, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose)
Returns (Integer)
The oPeriodOpen, oPeriodHigh, oPeriodLow, and oPeriodCLose output parameters returns the Open, High, Low, and Close from a time segment. The OHLCPeriodsAgo function itself returns 1 if the specified time segment was available, and -1 if not.
Parameters
Name
Type
Description
PeriodType
Numeric
Sets the time period on which to base values (1=Day, 2=Week, 3=Month, 4=Year)
PeriodsAgo
Numeric
Sets the number of PeriodType periods ago
oPeriodOpen
Numeric
Outputs the open of the specified time segment
oPeriodHigh
Numeric
Outputs the high of the specified time segment
oPeriodLow
Numeric
Outputs the low of the specified time segment
oPeriodClose
Numeric
Outputs the close of the specified time segment
Remarks
See Multiple Output Function for more information on using output parameters to return values.
Example
Assigns to Value2 through Value5 the Open, High, Low, and Close of the last 20 weeks. Value1 is assigned a value of 1.
vars: oPeriodOpen(0), oPeriodHigh(0), oPeriodLow(0), oPeriodClose(0);
Value1 = OHLCPeriodsAgo(2, 20, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose);
Value2 = oPeriodOpen;
Value3 = oPeriodHigh;
Value4 = oPeriodLow;
Value5 = oPeriodClose;
2020-12-06
836
글번호 144461
사용자 함수
답변완료
개별요인에 의한 순 수익률 작성
타종목 참조를 활용하여,
개별종목의 순수익률을 반영한 종가를 작성하고 싶습니다.
EXCEL로는 표현을 할수 있겠는데, YL은 자기참조 표현을 잘못하겠네요.
첨부 excel의 G 행의 값처럼 표현하고 싶습니다 (첨부참조)
주종목(DATA1)에는 개별종목 (EX.삼성전자)
타종목(DATA2)에는 타종목 (EX. KOSPI 지수)
표현하고자하는 지표 : 주종목차트의 최초의 종가를 시작으로
하기 '개별순수익률'을 반영한, 주종목의 종가(CLOSE)
//======작성수식====
Input:base(1.5),Length(60), 차트상의첫종가(100);
Var:x(0),y(0),Beta(0),Alpha(0) , 개별순수익률 (0) ;
y = (C - C[1])*100/C[1]; //종목변동률
x = (data2(C) - data2(C[1]))*100/data2(C[1]); //시장변동률, data2는 코스피 또는 코스닥 지수
Beta = (ma(x*y, length) - ma(x,length) * ma(y,length)) /
(ma(x^2,length) - (ma(x,length)^2));
Alpha = ma(y,length) - (ma(x*y, length) - ma(x,length) * ma(y,length)) /
(ma(x^2,length) - (ma(x,length)^2)) * ma(x,length);
PLOTBASELINE1 (0,"0");
Plot1(Beta,"베타",iff(Beta>base,RED,BLUE));
Plot2(Alpha,"알파",iff(Alpha>base,RED,BLUE));
/*===========개별요인에 의한 순 수익률
* 종목의 주가 변화 = 종합지수 변화 + 종목의 개별요인 ---- (식-1)
종목의 개별요인 = 종목의 주가 변화 - 종합지수 변화
개별요인에 의한 순 수익률 = 주가의 수익률 - 베타 * 종합지수의 수익률 ---- (식-2)
*/
개별순수익률 = (Y -Beta* X)*0.01; // <=식-2
개별순수익주가 = ; //???? <=표현하고자하는 지표.
//------------------
2020-12-06
802
글번호 144460
지표