예스스탁
예스스탁 답변
2023-12-04 15:43:23
안녕하세요
예스스탁입니다.
input : rsiSource(close);
input : rsiLength(7);
input : rsiOverbought(70);
input : rsiOvesold(30);
var : rsiValue(0),isOverbought(False),isOversold(False);
var : T(0),HH(0),HD(0),HT(0),LL(0),LD(0),LT(0),HH1(0),LL1(0);
var : TL(0),TX(0),Hstr(""),Lstr("");
rsiValue = rsi(rsiLength);
isOverbought = rsiValue >= rsiOverbought;
isOversold = rsiValue <= rsiOvesold;
if T <= 0 and isOverbought == true Then
{
T = 1;
HH = H;
HD = sDate;
HT = sTime;
HH1 = HH[1];
if LL > 0 Then
{
TL = TL_New(LD,LT,LL,HD,HT,HH);
TL_SetColor(TL,Blue);
}
if HH1 > 0 and HH > HH1 Then
Hstr = "HH";
Else
Hstr = "LH";
TX = Text_New(HD,HT,HH,Hstr);
Text_SetStyle(tx,2,1);
Text_SetColor(tx,Red);
Text_SetSize(tx,14);
Text_SetBold(tx,1);
}
if T >= 0 and isOversold == true Then
{
T = -1;
LL = L;
LD = sDate;
LT = sTime;
LL1 = LL[1];
if HH > 0 Then
{
TL = TL_New(HD,HT,HH,LD,LT,LL);
TL_SetColor(TL,Blue);
}
if LL1 > 0 and LL < LL1 Then
Lstr = "LL";
Else
Lstr = "HL";
TX = Text_New(LD,LT,LL,Lstr);
Text_SetStyle(tx,2,0);
Text_SetColor(tx,Green);
Text_SetSize(tx,14);
Text_SetBold(tx,1);
}
if T == 1 Then
{
if H > HH Then
{
HH = H;
HD = sDate;
HT = sTime;
TL_SetEnd(TL,HD,HT,HH);
if HH1 > 0 and HH > HH1 Then
Hstr = "HH";
Else
Hstr = "LH";
Text_SetString(TX,Hstr);
Text_SetLocation(TX,HD,HT,HH);
}
}
if T == -1 Then
{
if L < LL Then
{
LL = L;
LD = sDate;
LT = sTime;
TL_SetEnd(TL,LD,LT,LL);
if LL1 > 0 and LL < LL1 Then
Lstr = "LL";
Else
Lstr = "HL";
Text_SetString(TX,Lstr);
Text_SetLocation(TX,LD,LT,LL);
}
}
즐거운 하루되세요
> 기찬주 님이 쓴 글입니다.
> 제목 : 부탁드립니다
> 안녕하세요.
항상 큰 도움을 주셔서 감사드립니다.
아래의 TV지표를 YS지표로 사용하고 싶습니다.
부탁드립니다.
//@version=4
study("RSI Swing Indicator", overlay=true, max_bars_back=1000)
// RSI Settings for user
rsiSource = input(title="RSI Source", type=input.source, defval=close)
rsiLength = input(title="RSI Length", type=input.integer, defval=7)
rsiOverbought = input(title="RSI Overbought", type=input.integer, defval=70, minval=51, maxval=100)
rsiOvesold = input(title="RSI Oversold", type=input.integer, defval=30, minval=1, maxval=49)
// RSI value based on inbuilt RSI
rsiValue = rsi(rsiSource, rsiLength)
// Get the current state
isOverbought = rsiValue >= rsiOverbought
isOversold = rsiValue <= rsiOvesold
// State of the last extreme 0 for initialization, 1 = overbought, 2 = oversold
var laststate = 0
// Highest and Lowest prices since the last state change
var hh = low
var ll = high
// Labels
var label labelll = na
var label labelhh = na
// Swing lines
var line line_up = na
var line line_down = na
var last_actual_label_hh_price = 0.0
var last_actual_label_ll_price = 0.0
// FUNCTIONS
obLabelText() =>
if(last_actual_label_hh_price < high)
"HH"
else
"LH"
//plot(last_actual_label_hh_price)
osLabelText() =>
if(last_actual_label_ll_price < low)
"HL"
else
"LL"
// Create oversold or overbought label
createOverBoughtLabel(isIt) =>
if(isIt)
label.new(x=bar_index, y=na ,yloc=yloc.abovebar, style=label.style_label_down, color=color.red, size=size.tiny, text=obLabelText())
else
label.new(x=bar_index, y=na ,yloc=yloc.belowbar, style=label.style_label_up, color=color.green, size=size.tiny, text=osLabelText())
// Move the oversold swing and label
moveOversoldLabel() =>
label.set_x(labelll, bar_index)
label.set_y(labelll, low)
label.set_text(labelll, osLabelText())
line.set_x1(line_down, bar_index)
line.set_y1(line_down, low)
moveOverBoughtLabel() =>
label.set_x(labelhh, bar_index)
label.set_y(labelhh, high)
label.set_text(labelhh, obLabelText())
line.set_x1(line_up, bar_index)
line.set_y1(line_up, high)
// We go from oversold straight to overbought NEW DRAWINGS CREATED HERE
if(laststate == 2 and isOverbought)
hh := high
labelhh := createOverBoughtLabel(true)
last_actual_label_ll_price := label.get_y(labelll)
labelll_ts = label.get_x(labelll)
labelll_price = label.get_y(labelll)
line_up := line.new(x1=bar_index, y1=high, x2=labelll_ts, y2=labelll_price, width=1)
// We go from overbought straight to oversold NEW DRAWINGS CREATED HERE
if(laststate == 1 and isOversold)
ll := low
labelll := createOverBoughtLabel(false)
last_actual_label_hh_price := label.get_y(labelhh)
labelhh_ts = label.get_x(labelhh)
labelhh_price = label.get_y(labelhh)
line_down := line.new(x1=bar_index, y1=high, x2=labelhh_ts, y2=labelhh_price, width=1)
// If we are overbought
if(isOverbought)
if(high >= hh)
hh := high
moveOverBoughtLabel()
laststate := 1
// If we are oversold
if(isOversold)
if(low <= ll)
ll := low
moveOversoldLabel()
laststate := 2
// If last state was overbought and we are overbought
if(laststate == 1 and isOverbought)
if(hh <= high)
hh := high
moveOverBoughtLabel()
//If we are oversold and the last state was oversold, move the drawings to the lowest price
if(laststate == 2 and isOversold)
if(low <= ll)
ll := low
moveOversoldLabel()
// If last state was overbought
if(laststate == 1)
if(hh <= high)
hh := high
moveOverBoughtLabel()
// If last stare was oversold
if(laststate == 2)
if(ll >= low)
ll := low
moveOversoldLabel()