답변완료
문의드립니다.
1. 국선에서 5계약을 진입하는데 아래 청산식에서 최소수익 달성후 수익감소시 청산을 1개씩만 하고 싶은데 B_2 청산이 한번 나오고 그 이후 봉에서 다시 B_2 청산이 나옵니다.
매수든 매도든 1개 진입신호에서 아래 청산식은 딱 1개씩만 적용되게 하고 싶습니다.
수정 부탁 드립니다.
var : 최소수익1(30),수익감소1(15);
var : 최소수익2(50),수익감소2(25);
var : HH(0),LL(0);
if MarketPosition == 1 Then
{
HH = Highest(H,BarsSinceEntry);
if HH >= EntryPrice+PriceScale*최소수익1 and HH < EntryPrice+PriceScale*최소수익2 Then
ExitLong("B_1",AtStop,HH-PriceScale*수익감소1,"",1,1);
if HH >= EntryPrice+PriceScale*최소수익2 Then
ExitLong("B_2",AtStop,HH-PriceScale*수익감소2,"",1,1);
}
if MarketPosition == -1 Then
{
LL = lowest(L,BarsSinceEntry);
if LL <= EntryPrice-PriceScale*최소수익1 and LL > EntryPrice-PriceScale*최소수익2 Then
ExitShort("S_1",AtStop,LL+PriceScale*수익감소1,"",1,1);
if LL <= EntryPrice-PriceScale*최소수익2 Then
ExitShort("S_2",AtStop,LL+PriceScale*수익감소2,"",1,1);
}
2. 그리고 atstop 대신에 atlimit를 쓰면 시뮬레이션에서 수익이 더 많이 나오던데
이유도 설명 부탁드립니다.
3. 음봉 또는 양봉이 연속해서 10개 나오면 현재 계약수에 관계없이 전량 청산하는 식도 부탁드립니다.
2024-09-23
575
글번호 183635
시스템
답변완료
검색식 부탁합니다
색상이 변하는 지점(적석에서 녹색으로 바뀌는 변곡점)에서 종목검색식 부탁드립니다.
SuperTrend
input : factor(3), AtrPeriod(10);
var : src(0), AtrV(0),upperBand(0),lowerBand(0), prevLowerBand(0), prevUpperBand(0);
var : prevSuperTrend(0), superTrend(C), direction(0),alpha(0),source(0);
if CurrentBar > 1 Then {
src = (H+L)/2;
// ATR계산(ATR 계산시 지수가중이동평균(rma)이용)
alpha = 1 / AtrPeriod ;
source = max(high - low, abs(high - close[1]), abs(low - close[1]));
ATrV = alpha * source + (1 - alpha) * ATrV[1];
upperBand = src + factor * AtrV;
lowerBand = src - factor * AtrV;
prevLowerBand = lowerBand[1];
prevUpperBand = upperBand[1];
if lowerBand > prevLowerBand or close[1] < prevLowerBand Then
lowerBand = lowerBand;
Else
lowerBand = prevLowerBand;
if upperBand < prevUpperBand or close[1] > prevUpperBand Then
upperBand = upperBand;
Else
upperBand = prevUpperBand;
if C > UpperBand Then
direction = 1;
if C < LowerBand Then
direction = -1;
if direction == 1 Then
supertrend = lowerband;
Else
supertrend = upperband;
}
if C > superTrend Then {
Plot1(superTrend,"UpTrend", GREEN, 0, 1);
NoPlot(2);
}
Else {
Plot2(superTrend,"DnTrend", RED, 0, 1);
NoPlot(1);
}
if direction == 1 and direction[1] == -1 Then
plot3(superTrend,"BuyStart",green,0,8);
if direction == -1 and direction[1] == 1 Then
plot4(superTrend,"SellStart",RED,0,8);
2024-10-10
795
글번호 183634
종목검색
답변완료
수식문의입니다
1. 다중조건의 IF함수
input : 가격(C), 기간S(17), 시그널S(52);
var : EmavS(0);
EmavS = Ema(가격,기간S);
Var3 = highest(iff(C>O, EmavS, 0), 시그널S);
if Var3 > 0 Then
Plot4(Var3, "세력선S");
>> "세력선S"에 증감에 따른 색상 표시를 하기 위한 IF함수에 대한 문의입니다.
Var3가 전일대비 하락시에는 파란색을, 변동이 없으면 노란색을, 상승하는 경우는
빨강색으로 표시하고자 하면 어케해야 하나요?
색상은 INPUT변수처리 부탁합니다.
2. 보조지표상 거래량관련입니다.
input : v기간1(5),v기간2(20);
var1 = MA(V,v기간1);
var2 = MA(V,v기간2);
If C > O Then
{
Plot1(V, "양봉거래량");
Plot2(0, "음봉거래량");
}
Else
{
Plot1(0, "양봉거래량");
Plot2(V, "음봉거래량");
}
>>PLOT1 또는 PLOT2의 거래량은 숫자로 조회표시됩니다.
커서를 해당 거래량 막대에 갖다놓으면 거래량은 표시되는데 전일대비 또는 전일이평
선량대비 몇 퍼센트(%) 증감되었는지 표시가 되지 않는데 되게 할려면 추가해야할
수식을 알려주세요.
2024-09-23
755
글번호 183633
지표
답변완료
문의 드립니다
안녕하세요
다음 트레이딩뷰 코딩을 전환해주세요
//@version=5
indicator("Nadaraya-Watson Envelope [LuxAlgo]", "LuxAlgo - Nadaraya-Watson Envelope", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back=500)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
h = input.float(8.,'Bandwidth', minval = 0)
mult = input.float(3., minval = 0)
src = input(close, 'Source')
repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an effect where the indicators historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoints of the calculations')
//Style
upCss = input.color(color.teal, 'Colors', inline = 'inline1', group = 'Style')
dnCss = input.color(color.red, '', inline = 'inline1', group = 'Style')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
//Gaussian window
gauss(x, h) => math.exp(-(math.pow(x, 2)/(h * h * 2)))
//-----------------------------------------------------------------------------}
//Append lines
//-----------------------------------------------------------------------------{
n = bar_index
var ln = array.new_line(0)
if barstate.isfirst and repaint
for i = 0 to 499
array.push(ln,line.new(na,na,na,na))
//-----------------------------------------------------------------------------}
//End point method
//-----------------------------------------------------------------------------{
var coefs = array.new_float(0)
var den = 0.
if barstate.isfirst and not repaint
for i = 0 to 499
w = gauss(i, h)
coefs.push(w)
den := coefs.sum()
out = 0.
if not repaint
for i = 0 to 499
out += src[i] * coefs.get(i)
out /= den
mae = ta.sma(math.abs(src - out), 499) * mult
upper = out + mae
lower = out - mae
//-----------------------------------------------------------------------------}
//Compute and display NWE
//-----------------------------------------------------------------------------{
float y2 = na
float y1 = na
nwe = array.new<float>(0)
if barstate.islast and repaint
sae = 0.
//Compute and set NWE point
for i = 0 to math.min(499,n - 1)
sum = 0.
sumw = 0.
//Compute weighted mean
for j = 0 to math.min(499,n - 1)
w = gauss(i - j, h)
sum += src[j] * w
sumw += w
y2 := sum / sumw
sae += math.abs(src[i] - y2)
nwe.push(y2)
sae := sae / math.min(499,n - 1) * mult
for i = 0 to math.min(499,n - 1)
if i%2
line.new(n-i+1, y1 + sae, n-i, nwe.get(i) + sae, color = upCss)
line.new(n-i+1, y1 - sae, n-i, nwe.get(i) - sae, color = dnCss)
if src[i] > nwe.get(i) + sae and src[i+1] < nwe.get(i) + sae
label.new(n-i, src[i], '▼', color = color(na), style = label.style_label_down, textcolor = dnCss, textalign = text.align_center)
if src[i] < nwe.get(i) - sae and src[i+1] > nwe.get(i) - sae
label.new(n-i, src[i], '▲', color = color(na), style = label.style_label_up, textcolor = upCss, textalign = text.align_center)
y1 := nwe.get(i)
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
var tb = table.new(position.top_right, 1, 1
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if repaint
tb.cell(0, 0, 'Repainting Mode Enabled', text_color = color.white, text_size = size.small)
//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------}
plot(repaint ? na : out + mae, 'Upper', upCss)
plot(repaint ? na : out - mae, 'Lower', dnCss)
//Crossing Arrows
plotshape(ta.crossunder(close, out - mae) ? low : na, "Crossunder", shape.labelup, location.absolute, color(na), 0 , text = '▲', textcolor = upCss, size = size.tiny)
plotshape(ta.crossover(close, out + mae) ? high : na, "Crossover", shape.labeldown, location.absolute, color(na), 0 , text = '▼', textcolor = dnCss, size = size.tiny)
//-----------------------------------------------------------------------------}
감사합니다
2024-09-22
608
글번호 183630
지표