답변완료
지표식 수정
바로 아래는 키움식인데 이것을 예스식으로 바꾸려고합니다.
s=sum(1);
A=valuewhen(1, s%봉수==1, O);
As=valuewhen(1, s%봉수==1, S);
B=valuewhen(1, s%봉수==0, C);
Bs=valuewhen(1, s%봉수==0, S);
AA=VALUEWHEN(1,AS<BS,A),-봉수+1;
BB=VALUEWHEN(1,AS<BS,B),-봉수+1;
LL=VALUEWHEN(1, S%봉수==0, lowest(l,봉수));
흰선1=min(aa,bb);
음고1=valuewhen(1,As<Bs, A),-봉수+1;
양고1=valuewhen(1,As<Bs, B),-봉수+1;
평고1=if(음고1>=양고1,-(음고1-흰선1), +(양고1-흰선1));
qq1=sum(평고1, n2)/1000;
qq2=crossup(qq1, 0) or crossdown(qq1, 0);
qq3=if(qq2, 50, 0);
valuewhen(1, qq3, h)
에서 위 고가 선과
위 식 유사부분은 생략....
valuewhen(1, qq3, l)
저 저가 선 사이에 봉(차트상의 봉사이에 그 바음 고저선이 나타나지 전까지 사이에 색상은 유지) 고저에 선이 그어지고 그 사이 색을 입히고 싶습니다.
( 봉수, n1, n2 는 변수로 설정하여 각각 100, 30, 70으로 임의로 우선 설정한다)
아래는 만들어 본 것인데... 에러가 너무 많아요 수정보다는 전체적으로 다시 작성을 부탁합니다.
input : 봉수(75), n1(30), n2(200); // 변수 설정
var : s(0), A(0), As(0), B(0), Bs(0), AA(0), BB(0), LL(0), 흰선1(0), 음고1(0), 양고1(0), 평고1(0), qq1(0), qq2(false), qq3(0), qq33(0), qq22(false);
// 카운터 변수 업데이트
s = s + 1;
// 봉수와 관련된 가격 계산
A = iff(s % 봉수 == 1, Open, A); // 봉수마다 매수 가격 (시가)
As = iff(s % 봉수 == 1, s, As); // 봉수마다 매수 시점
B = iff(s % 봉수 == 0, Close, B); // 봉수마다 종가
Bs = iff(s % 봉수 == 0, s, Bs); // 봉수마다 매도 시점
// 조건에 맞는 A, B값 계산
AA = iff(As < Bs, A, AA);
BB = iff(As < Bs, B, BB);
LL = iff(s % 봉수 == 0, lowest(Low, 봉수), LL); // 봉수만큼의 최저가 계산
// 흰선1 설정: AA와 BB 중 작은 값
흰선1 = min(AA, BB);
// 음고1과 양고1 조건 설정
음고1 = iff(As < Bs, A, 음고1);
양고1 = iff(As < Bs, B, 양고1);
// 평고1 계산
평고1 = iff(음고1 >= 양고1, -(음고1 - 흰선1), 양고1 - 흰선1);
// qq1 계산: n2 기간 동안 평고1 합산 값 계산
qq1 = sumN(평고1, n2) / 1000;
// 교차 여부 체크
qq2 = CrossUp(qq1, 0); // qq1 값이 0을 상향 교차하는지 확인
qq22 = CrossDown(qq1, 0); // qq1 값이 0을 하향 교차하는지 확인
// 교차 신호 발생 시 50, 그렇지 않으면 0
qq3 = iff(qq2, 50, 0);
qq33 = iff(qq22, 50, 0);
// 최종 출력
plot1 = iff(qq3 == 50, High, 0); // 상향 교차 고가 값
plot2 = iff(qq33 == 50, Low, 0); // 하향 교차 저가 값
Plot(plot1, "상향 교차 고가 값", colorRed);
Plot(plot2, "하향 교차 저가 값", colorBlue);
2024-11-13
667
글번호 185218
지표
답변완료
수정부탁드립니다.
수고하십니다.
아래수식을 시뮬레이션 해보면 틱의 동일봉에서 동일시간으로 매수,매도 청산까지
이루어질때도 있는데 다음봉부터 청산이나 매매스위칭 되게 수정부탁드립니다.
첨부그림 참조해주세요.
---------------------------------------------------------------------
INPUT : LENGTH(1), PRO(0.35), LOSS(0.4),T(144900),TICK(1);
VAR : TCHAN(0), BCHAN(0);
var : bs1(0),ss1(0);
var : bs2(0),ss2(0);
var : bs3(0),ss3(0);
var : bl(0),bh(0), sh(0), sl(0);
TCHAN = HIGHEST(HIGH, LENGTH)[1];
BCHAN = LOWEST(LOW, LENGTH)[1];
// TCHAN 보다 크면 매수 1단계
if TCHAN[1] < H[1] then {bs1 = 1;}
if BCHAN[1] > L[1] then {ss1 = 1;}
// 만약 매수 1단계 진행중 BCHAN의 저가를 깨면 매수단계 초기화
if bs1 == 1 and BCHAN > L then {bs1=0; }
if ss1 == 1 and TCHAN < H then {ss1=0; }
//진입
if bs1 == 1 then {buy("매수",atlimit,TCHAN-PriceScale*TICK); }
if ss1 == 1 then {sell("매도",atlimit,BCHAN+PriceScale*TICK); }
SetStopProfittarget(PRO,PointStop);
SetStopLoss(LOSS,PointStop);
2024-11-13
591
글번호 185216
시스템
답변완료
예스지표 변환 요청 드립니다.
수고 많으십니다.
트레이딩뷰 지표입니다.
예스지표로 변환 및 Buy 신호시 검색 되도록 검색식 부탁 드립니다.
수고하세요.
//@version=5
indicator(shorttitle='FL', title='Follow Line', overlay=true)
// --- settings
ATRperiod = input.int(defval=5, title='ATR Period', minval=1)
BBperiod = input.int(defval=21, title='Bollinger Bands Period', minval=1)
BBdeviation = input.float(defval=1.00, title='Bollinger Bands Deviation', minval=0.1, step=0.1)
UseATRfilter = input(defval=true, title='ATR Filter On/Off') // false = 0, true = 1
showsignals = input(title='Show Signals ', defval=true)
// --- end of settings
// Bollinger Bands calculation
BBUpper = ta.sma(close, BBperiod) + ta.stdev(close, BBperiod) * BBdeviation
BBLower = ta.sma(close, BBperiod) - ta.stdev(close, BBperiod) * BBdeviation
// ATR calculation
atrValue = ta.atr(ATRperiod)
// Signal initialization
var float FollowLine = na
var int BBSignal = 0
// Determine BB signal
if (close > BBUpper)
BBSignal := 1
else if (close < BBLower)
BBSignal := -1
// Buy signal logic
if (BBSignal == 1)
if (UseATRfilter)
FollowLine := low - atrValue
else
FollowLine := low
if (FollowLine < nz(FollowLine[1]))
FollowLine := nz(FollowLine[1])
// Sell signal logic
if (BBSignal == -1)
if (UseATRfilter)
FollowLine := high + atrValue
else
FollowLine := high
if (FollowLine > nz(FollowLine[1]))
FollowLine := nz(FollowLine[1])
// Trend direction determination
var int iTrend = 0
if (nz(FollowLine) > nz(FollowLine[1]))
iTrend := 1
else if (nz(FollowLine) < nz(FollowLine[1]))
iTrend := -1
// Trend line color based on trend direction
lineColor = iTrend > 0 ? color.rgb(9, 98, 232) : color.new(color.rgb(220, 20, 60), 0)
//buy & sell conditions
buy=0.0
sell=0.0
buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na
sell:=iTrend[1]==1 and iTrend==-1? 1 : na
//alerts
alertcondition(sell == 1 ,title="Sell",message="Follow Line Sell")
alertcondition(buy == 1 ,title="Buy",message="Follow Line Buy")
alertcondition(buy == 1 or sell == 1 ,title="Signal",message="Follow Line Signal")
// Plot the trend line and signals
plot(FollowLine, color=lineColor, linewidth=2, title="Follow Line")
plotshape(buy == 1 and showsignals ? FollowLine-atrValue :na, text='BUY', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto)
plotshape(sell == 1 and showsignals ? FollowLine+atrValue:na, text='SELL', style=shape.labeldown, location=location.absolute, color=color.rgb(102, 15, 15), textcolor=color.white, offset=0, transp=0,size=size.auto)
2024-11-12
672
글번호 185203
지표