답변완료
문의 드립니다
안녕하세요
1. 다음 슈퍼트랜드 지표에 일목 기준선을 추가하고 uptrand가 기준선위에 있으면
노랑색으로 채우고 downtrand가 기준선 아래 있으면 파랑색으로 두선사이을 색으로
채우고자합니다
input : Periods(10);
input : Multiplier(3.0);
input : changeATR(1);#1:SMA 0:RMA
var : src(0),alpha(0),source(0),ATR1(0),ATR2(0),ATRV(0);
var : up(0),up1(0),dn(0),dn1(0),trend(0),tx(0);
src = (H+L)/2;
alpha = 1 / Periods;
atr1 = IFf(IsNan(atr1[1]) == true , ma(TrueRange, Periods) , alpha * TrueRange + (1 - alpha) * atr1[1]);
atr2 = ATR(Periods);
atrv = IFf(changeATR == 1 , atr1 , atr2);
up=src-(Multiplier*atrv);
up1 = IFf(IsNan(up[1]) == False,up[1],up);
up = iff(close[1] > up1 , max(up,up1) , up);
dn=src+(Multiplier*atrv);
dn1 = IFf(IsNan(dn[1]) == False,dn[1], dn);
dn = iff(close[1] < dn1 , min(dn, dn1) , dn);
trend = 1;
trend = IFf(IsNan(trend[1]) == False,trend[1], trend);
trend = IFf(trend == -1 and close > dn1 , 1 , iff(trend == 1 and close < up1 , -1 , trend));
if trend == 1 Then
plot1(up,"UpTrend",White);
Else
NoPlot(1);
if trend == -1 then
Plot2(dn,"Down Trend",Black);
Else
NoPlot(2);
if trend == 1 and trend[1] == -1 Then
{
tx =Text_New(sDate,sTime,up,"●");
Text_SetStyle(tx,1,1);
Text_SetColor(tx,Red);
}
if trend == -1 and trend[1] == 1 Then
{
tx =Text_New(sDate,sTime,dn,"●");
Text_SetStyle(tx,1,1);
Text_SetColor(tx,Blue);
}
2.다음 트레이딩뷰 지표 전환입니다
period=input(title="Period", defval=10)
len=input(title="Period", defval=10)
smaHigh=sma(high, len)
smaLow=sma(low, len)
Hlv = na
Hlv := close > smaHigh ? 1 : close < smaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? smaHigh: smaLow
sslUp = Hlv < 0 ? smaLow : smaHigh
plot(sslDown, linewidth=2, color=red)
plot(sslUp, linewidth=2, color=lime)
감사합니다
2024-10-24
677
글번호 184551
지표
답변완료
문의드립니다
Input : Period(20), MultiD(2);
var : MAv(0),BBup(0),BBdn(0);
MAv = ma(C,Period);
BBup = BollBandUp(Period,MultiD);
BBdn = BollBandDown(Period,MultiD);
Plot1(MAv, "이평");
Plot2(BBup, "상단밴드");
Plot3(BBdn, "하단밴드");
............................................................
1.
Plot2(BBup, "상단밴드")를 증감을 표현할 수 있는 막대그래프(상단 밴드값이 증가하면 빨간색, 감소하면 파란색 막대)로 구현하고 싶습니다
2.
Plot3(BBdn, "하단밴드");를 증감을 표현할 수 있는 막대그래프(하단 밴드값이 증가하면 빨간색, 감소하면 파란색 막대)로 구현하고 싶습니다
상단밴드, 하단밴드 각각 단독의 지표로 구현해주세요
감사합니다.
2024-10-24
782
글번호 184550
지표
답변완료
진입 수량 관련 질문
어느덧 가을이네요. 항상 건강하시길 바랍니다.
진입 수량 관련 도움 요청드립니다.
수식은 아래와 같습니다.
----
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
683
글번호 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
687
글번호 184544
시스템