커뮤니티
함수 및 지표 수식 수정
2019-09-23 23:30:22
310
글번호 132157
아래 함수와 지표를 사용하면 선이 하나만 출력되는대 함수값 및 지표 수정부탁드립니다.
<1>함수
inputs: ATRLength(NumericSimple), ATRMult(NumericSimple), Strength(NumericSimple), STrend(NumericRef);
vars: ATR(0), avg(0), dn(0), up(0), trend(1), flag(0), flagh(0), ST(0),hl(0);
hl = Highest(High, ATRLength) - Lowest(Low, ATRLength);
ATR = ema(hl, ATRLength);
avg = (ema(high, Strength) + ema(low, Strength))/2;
up = avg + ATR;
dn = avg - ATR;
if c > up[1] and c > Highest(High, Strength)[1] then trend = 1;
else if c < dn[1] and c < Lowest(Low, Strength)[1] then trend = -1;
if trend < 0 and trend[1] > 0 then flag=1; else flag=0;
if trend > 0 and trend[1] < 0 then flagh = 1; else flagh = 0;
if trend > 0 and dn < dn[1] then dn=dn[1];
if trend < 0 and up > up[1] then up=up[1];
if flag = 1 then up = avg + ATR;
if flagh = 1 then dn = avg - ATR; if trend = 1 then ST = dn; else ST = up;
SuperTrend = ST;
STrend = trend;
<2>지표
inputs: ATRLength(9), ATRMult(1), Strength(9);
vars: strend(0),st(0);
st = SuperTrend(ATRLength, ATRMult, Strength, strend);
Plot1(st,"Up");
Plot2(st,"Down");
Plot3(st,"SuperTrend",iff(strend == 1,red,blue));
답변 1
예스스탁 예스스탁 답변
2019-09-24 14:49:27
안녕하세요
예스스탁입니다.
사용자함수에 문법과 다른내용이 있어 수정했습니다.
상하단에 atr을 추가해서 그려지게 수정해 드립니다.
1 사용자함수
inputs: ATRLength(NumericSimple), ATRMult(NumericSimple), Strength(NumericSimple), STrend(NumericRef);
vars: ATR(0), avg(0), dn(0), up(0), trend(1), flag(0), flagh(0), ST(0),hl(0);
hl = Highest(High, ATRLength) - Lowest(Low, ATRLength);
ATR = ema(hl, ATRLength);
avg = (ema(high, Strength) + ema(low, Strength))/2;
up = avg + ATR;
dn = avg - ATR;
if c > up[1] and c > Highest(High, Strength)[1] then trend = 1;
else if c < dn[1] and c < Lowest(Low, Strength)[1] then trend = -1;
if trend < 0 and trend[1] > 0 then flag=1; else flag=0;
if trend > 0 and trend[1] < 0 then flagh = 1; else flagh = 0;
if trend > 0 and dn < dn[1] then dn=dn[1];
if trend < 0 and up > up[1] then up=up[1];
if flag == 1 then up = avg + ATR;
if flagh == 1 then dn = avg - ATR;
if trend == 1 then ST = dn; else ST = up;
SuperTrend = ST;
STrend = trend;
2
inputs: ATRLength(9), ATRMult(1), Strength(9);
vars: strend(0),st(0);
st = SuperTrend(ATRLength, ATRMult, Strength, strend);
Plot1(st+atr(ATRLength)*ATRMult,"Up",iff(strend == 1,red,blue));
Plot2(st-atr(ATRLength)*ATRMult,"Down",iff(strend == 1,red,blue));
Plot3(st,"SuperTrend",iff(strend == 1,red,blue));
즐거운 하루되세요
> 이대표 님이 쓴 글입니다.
> 제목 : 함수 및 지표 수식 수정
> 아래 함수와 지표를 사용하면 선이 하나만 출력되는대 함수값 및 지표 수정부탁드립니다.
<1>함수
inputs: ATRLength(NumericSimple), ATRMult(NumericSimple), Strength(NumericSimple), STrend(NumericRef);
vars: ATR(0), avg(0), dn(0), up(0), trend(1), flag(0), flagh(0), ST(0),hl(0);
hl = Highest(High, ATRLength) - Lowest(Low, ATRLength);
ATR = ema(hl, ATRLength);
avg = (ema(high, Strength) + ema(low, Strength))/2;
up = avg + ATR;
dn = avg - ATR;
if c > up[1] and c > Highest(High, Strength)[1] then trend = 1;
else if c < dn[1] and c < Lowest(Low, Strength)[1] then trend = -1;
if trend < 0 and trend[1] > 0 then flag=1; else flag=0;
if trend > 0 and trend[1] < 0 then flagh = 1; else flagh = 0;
if trend > 0 and dn < dn[1] then dn=dn[1];
if trend < 0 and up > up[1] then up=up[1];
if flag = 1 then up = avg + ATR;
if flagh = 1 then dn = avg - ATR; if trend = 1 then ST = dn; else ST = up;
SuperTrend = ST;
STrend = trend;
<2>지표
inputs: ATRLength(9), ATRMult(1), Strength(9);
vars: strend(0),st(0);
st = SuperTrend(ATRLength, ATRMult, Strength, strend);
Plot1(st,"Up");
Plot2(st,"Down");
Plot3(st,"SuperTrend",iff(strend == 1,red,blue));
이전글