답변완료
진입 수량 관련 질문
어느덧 가을이네요. 항상 건강하시길 바랍니다.
진입 수량 관련 도움 요청드립니다.
수식은 아래와 같습니다.
----
2
input :
AccountCapital(1000000); //KRW
var :
x(0);
x = AccountCapital * (floor( TRIX(12)*100 )/100);
if MarketPosition <= 0 and x > 0 Then
Buy("b",OnClose,Def,x);
if MarketPosition >= 0 and x < 0 Then
Sell("s",OnClose,Def,abs(x));
if MarketPosition == 1 Then
{
if x >= 0 Then
{
if x > CurrentContracts Then
Buy("bb",OnClose,Def,x-CurrentContracts);
if x < CurrentContracts Then
ExitLong("bx",OnClose,Def,"",CurrentContracts-x,2);
}
}
if MarketPosition == -1 Then
{
if x <= 0 Then
{
if abs(x) > CurrentContracts Then
Sell("ss",OnClose,Def,abs(x)-CurrentContracts);
if abs(x) < CurrentContracts Then
ExitShort("sx",OnClose,Def,"",CurrentContracts-abs(x),2);
}
}
----
보시면 아시겠지만, Trix 값(X)에 따라서 수량을 늘리더나 줄이고 있습니다.
해당 전략은 Daily봉에서 사용할 예정입니다.
해당 전략을 복리로 구현하고 싶습니다.
AccountCapital을 100만원으로 했으니 시작 금액이 100만원입니다.
그러나 각 Dailby bar가 끝날 때 현재 손익 기준(미실현이든 실현이든)으로 AccountCapital이 재정산 되었으면 좋겠습니다.
롱 포지션 잡은 상태에서 가격이 올라가면 미실현 손익도 올라가니 해당 값이 AccountCapital에 반영될 수 있도록 수식 변경 부탁드립니다 (__)
2024-10-24
691
글번호 184547
시스템
답변완료
시스템식으로 변환 요청
안녕하세요
아래의 지표를 시스템매수식으로 변환하여 주시면 감사하겠습니다.
plot3 이면 매수 plot4면 매도하는 식으로 변경 부탁 간곡히 드립니다.
(참고페이지) https://blog.naver.com/chartist/222656653057
답변 미리 감사드립니다.
----------------------------------------------------------------------------------
input : SwingPeriod(2), AtrPeriod(10), ATrMult(3);
var : PH(0), PL(0), lastpp(0), center(0), alPHa(0), source(0), ATrV(0);
var : UpCh(0), DnCh(0), Trend(0), TuP(0), Tdown(0), TrailingSL(0);
# 스윙하이와 스윙로우를 이용하여 중심선 계산
PH = swingHigh(1,H,SwingPeriod,SwingPeriod,SwingPeriod*2+1);
PL = swingLow(1,L,SwingPeriod,SwingPeriod,SwingPeriod*2+1);
if PH <> -1 Then lastpp = PH;
if PL <> -1 Then lastpp = PL;
if PH <> -1 or PL <> -1 Then center = (center*2 + lastpp)/3;
# ATR계산(True Range를 RMA로 평균)
if CurrentBar > 0 Then {
alPHa = 1 / AtrPeriod ;
source = max(H - L, abs(H - C[1]), abs(L - C[1]));
ATrV = alPHa * source + (1 - alPHa) * ATrV[1];
}
# 상하단 채널과 추세에 따른 추세채널
UpCh = center - (ATrMult * ATrV);
DnCh = center + (ATrMult * ATrV);
Tup = IFf(C[1] > TUp[1],max(UpCh, TUp[1]),UpCh );
Tdown = IFf(C[1] < TDown[1],min(DnCh, TDown[1]),DnCh );
if C > TDown[1] Then Trend = 1;
if C < TuP[1] Then Trend = -1;
Trailingsl = IFf(Trend == 1, Tup, Tdown);
# 지표 출력
if C > Trailingsl Then {
Plot1(Trailingsl,"UpTrend", RED, 0, 1);
NoPlot(2);
}
Else {
Plot2(Trailingsl,"DnTrend", BLUE, 0, 1);
NoPlot(1);
}
if Trend == 1 and Trend[1] == -1 Then
plot3(Trailingsl,"BuyStart", RED,0,8);
if Trend == -1 and Trend[1] == 1 Then
plot4(Trailingsl,"SellStart", BLUE,0,8);
====================================================================================
swingHigh 와 swingLow 지표 설명
input : Length(5);
var : HighV(0), LowV(0);
var : Hdate0(0), Hdate1(0), Htime0(0), Htime1(0), Hval(0), TL1(0);
var : Ldate0(0), Ldate1(0), Ltime0(0), Ltime1(0), Lval(0), TL2(0);
HighV = SwingHigh(1, H, Length, Length, Length*2+1);
LowV = SwingLow(1, L, Length, Length, Length*2+1);
if HighV == -1 Then
HighV = HighV[1];
if LowV == -1 Then
LowV = LowV[1];
# 그래프 종류 속성 점그래프
Plot1(HighV,"swHigh",MAGENTA,0,4);
Plot2(LowV,"swLow",GREEN,0,4);
Plot3(HighV,"swHigh확장",MAGENTA,0,4);
Plot4(LowV,"swLow확장",GREEN,0,4);
FixPlotShift(1,-Length);
FixPlotShift(2,-Length);
2024-10-24
712
글번호 184544
시스템