답변완료
시스템식 요청드립니다.
전에 아래와 같이 질문을 남겼었는데 답변을 주셨는데 안되는 부분이 있어
다시 올려봅니다.
1번에 2번에 답변을 보면 이전 직전에 대한 청산이 있어야 처음 매수매도진입이
가능한 걸로 나오는데....
처음에 시스템을 적용했더니. 가장 처음에 청산이 없다보니
아예 매수매도 진입이 안되더라구요
가능한 방법이 있는지 확인 부탁드리겠습니다.
------------------------------------------------------------------------------
질문 1)
아래의 해당식에서 조건을 추가하고 싶은 내용이 있는데 확인 부탁 드리겠습니다.
if MarketPosition == 0 and CrossDown(C,var3) Then
buy("매수1");
위 식에서는 포지션 가지고 있는게 없고, 변수3을 종가가 하향 돌파하면 매수하는 식인데,
추가하고 싶은 조건은
청산한지 30분 후 부터 적용 입니다.
예를들어
오후 11시 20분에 '익절청산' 이 되었다면, 11시 50분 전까지는
변수3을 종가가 하향 돌파하면 매수되지 않다가 50분 이후부터
적용하게 되도록 부탁드립니다.
질문 2)
if MarketPosition == 0 and CrossDown(C,var3) Then
buy("매수1");
if MarketPosition == 0 and CrossUp(C,var1) Then
Sell("매도2");
위의 식처럼 진입식이 있고,
ExitLong("매수-손절",AtStop,AvgEntryPrice-100);
ExitShort("매도-손절",AtStop,AvgEntryPrice+100);
위의 식처럼 손절청산 식이 있습니다.
매수 진입 후 매수-손절 로 청산 되었다면 그 다음은 매도 포지션으로 진입하고 싶어서
진입식을 아래와 같이 수정했습니다.
if MarketPosition == 0 and CrossDown(C,var3)
and IsExitName("매도-손절",1) == true Then
buy("매수1");
이렇게 수정하였더니, 가장 처음 시스템 적용했을때, 앞에 청산이 없어서
적용이 안됩니다.ㅜ.ㅜ
어떻게 적용해야 할까요??
------------------------------------------------------------------------------
답변
----------------------------------------------------------------------------
1
if MarketPosition == 0 and CrossDown(C,var3) and
(TotalTrades == 0 or (TotalTrades == 1 and TimeToMinutes(sTime) >= TimeToMinutes(ExitTime(1))+30)) Then
buy("매수1");
2
if MarketPosition == 0 and CrossDown(C,var3) and
(TotalTrades == 0 or (TotalTrades >= 1 and IsExitName("매도-손절",1) == true)) Then
buy("매수1");
if MarketPosition == 0 and CrossUp(C,var1) and
(TotalTrades == 0 or (TotalTrades >= 1 and IsExitName("매수-손절",1) == true)) Then
Sell("매도2");
ExitLong("매수-손절",AtStop,AvgEntryPrice-100);
ExitShort("매도-손절",AtStop,AvgEntryPrice+100);
-----------------------------------------------------------------------------------
2023-05-04
1235
글번호 168694
시스템
답변완료
수식 문의
아래의 트뷰 지표를 변환하고 싶습니다.
안되는 부분이 있다면 설명해 주시면
다시 찾아 보겠습니다.
항상 감사드립니다.
overlay=true,max_bars_back=1000,max_lines_count=500,max_labels_count=500)
length = input.float(500,'Window Size',maxval=500,minval=0)
h = input.float(8.,'Bandwidth')
mult = input.float(3.)
src = input.source(close,'Source')
up_col = input.color(#39ff14,'Colors',inline='col')
dn_col = input.color(#ff1100,'',inline='col')
disclaimer = input(false, 'Hide Disclaimer')
//----
n = bar_index
var k = 2
var upper = array.new_line(0)
var lower = array.new_line(0)
lset(l,x1,y1,x2,y2,col)=>
line.set_xy1(l,x1,y1)
line.set_xy2(l,x2,y2)
line.set_color(l,col)
line.set_width(l,2)
if barstate.isfirst
for i = 0 to length/k-1
array.push(upper,line.new(na,na,na,na))
array.push(lower,line.new(na,na,na,na))
//----
line up = na
line dn = na
//----
cross_up = 0.
cross_dn = 0.
if barstate.islast
y = array.new_float(0)
sum_e = 0.
for i = 0 to length-1
sum = 0.
sumw = 0.
for j = 0 to length-1
w = math.exp(-(math.pow(i-j,2)/(h*h*2)))
sum += src[j]*w
sumw += w
y2 = sum/sumw
sum_e += math.abs(src[i] - y2)
array.push(y,y2)
mae = sum_e/length*mult
for i = 1 to length-1
y2 = array.get(y,i)
y1 = array.get(y,i-1)
up := array.get(upper,i/k)
dn := array.get(lower,i/k)
lset(up,n-i+1,y1 + mae,n-i,y2 + mae,up_col)
lset(dn,n-i+1,y1 - mae,n-i,y2 - mae,dn_col)
if src[i] > y1 + mae and src[i+1] < y1 + mae
label.new(n-i,src[i],'▼',color=#00000000,style=label.style_label_down,textcolor=dn_col,textalign=text.align_center)
if src[i] < y1 - mae and src[i+1] > y1 - mae
label.new(n-i,src[i],'▲',color=#00000000,style=label.style_label_up,textcolor=up_col,textalign=text.align_center)
cross_up := array.get(y,0) + mae
cross_dn := array.get(y,0) - mae
alertcondition(ta.crossover(src,cross_up),'Down','Down')
alertcondition(ta.crossunder(src,cross_dn),'Up','Up')
//----
var tb = table.new(position.top_right, 1, 1
, bgcolor = #35202b)
if barstate.isfirst and not disclaimer
table.cell(tb, 0, 0, 'Nadaraya-Watson Envelope [LUX] Repaints'
, text_size = size.small
, text_color = #cc2f3c)
2023-05-03
1356
글번호 168689
지표
답변완료
수식문의
최근값만 수평으로 표시하려면 추세선 함수를 이용해야 합니다.
추세선을 점그래프로 지정하고 굵기가 굵으면 선처럼 보이게 됩니다.
수식내 굵기는 0으로 처리해 드립니다.
굵기 조정해 보시기 바랍니다.
input : N(26),굵기(0);
var : hh(0),ll(0),tl1(0),tl2(0),cnt(0);
if Bdate != Bdate[1] Then
{
TL_Delete(tl1);
TL_Delete(tl2);
var1 = sDate;
Var2 = sTime;
hh = 0;
ll = 0;
For cnt = 0 to N-1
{
if hh == 0 or (hh > 0 and DayHigh(cnt) > hh) Then
hh = DayHigh(cnt);
if ll == 0 or (ll > 0 and DayLow(cnt) < ll) Then
ll = DayLow(cnt);
}
tl1 = TL_New(var1,Var2,hh,NextBarSdate,NextBarStime,hh);
tl2 = TL_New(var1,Var2,ll,NextBarSdate,NextBarStime,ll);
TL_SetExtLeft(tl1,true);
TL_SetExtLeft(tl2,true);
TL_SetExtRight(tl1,true);
TL_SetExtRight(tl2,true);
TL_SetColor(tl1,Red);
TL_SetColor(tl2,Blue);
TL_SetStyle(tl1,3);
TL_SetStyle(tl2,3);
TL_SetSize(tl1,굵기);
TL_SetSize(tl2,굵기);
}
Else
{
if hh > 0 and DayHigh(0) > hh Then
{
hh = DayHigh(0);
TL_SetBegin(tl1,var1,Var2,hh);
}
if ll > 0 and DayLow(0) < ll Then
{
ll = DayLow(0);
TL_SetBegin(tl1,var1,Var2,hh);
}
TL_SetEnd(tl1,NextBarSdate,NextBarStime,hh);
TL_SetEnd(tl2,NextBarSdate,NextBarStime,ll);
}
알려 주신 26일 최고, 최저 라인입니다
이 수식을 분봉에 적용할 수 있게 수정 부탁드립니다
행복한 하루 되세요
감사합니다
2023-05-03
1158
글번호 168688
지표
답변완료
추세선 직저
input : Period(150),선두께(2);
Var:상승색(Red), 하락색(Blue);
Var:j(0),T(0);
Var: date11(0),date12(0),time11(0),time12(0),TL1(0),TL(0),tl9(0),
date21(0),date22(0),time21(0),time22(0),
date31(0),date32(0),time31(0),time32(0),tx(0),tx1(0),tl4(0);
Array:HiVal[20](0),LoVal[20](0),HiBar[20](0),LoBar[20](0);
Plot1(0);
For j = 0 To 19
{
HiBar[j] = HiBar[j] + 1;
LoBar[j] = LoBar[j] + 1;
}
if crossup(c,highest(H,Period)[1]) Then
T = 1;
if CrossDown(c,Lowest(L,Period)[1]) Then
T = -1;
If T == -1 Then
{
If T[1] != -1 Then
{
For j = 18 DownTo 0
{
LoVal[j+1] = LoVal[j];
LoBar[j+1] = LoBar[j];
}
LoVal[0] = L;
LoBar[0] = 0;
date11 = date[HiBar[0]];
time11 = stime[HiBar[0]];
Value11 = HiVal[0];
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
TL_Delete(tl);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
TL1 = TL_New(date11,time11,Value11,date12,time12,Value12);
TL_SetColor(TL1,하락색);
date21 = date[HiBar[0]];
time21 = stime[HiBar[0]];
date22 = date[0];
time22 = stime[0];
}
If LoVal[0] > L Then
{
LoVal[0] = L;
LoBar[0] = 0;
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
TL_SetEnd(TL1, date12,time12,Value12);
date22 = date[0];
time22 = stime[0];
TL_Delete(tl);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
}
}
If T == 1 Then
{
If T[1] != 1 Then
{
For j = 18 DownTo 0
{
HiVal[j+1] = HiVal[j];
HiBar[j+1] = HiBar[j];
}
HiVal[0] = H;
HiBar[0] = 0;
date11 = date[LoBar[0]];
time11 = stime[LoBar[0]];
Value11 = LoVal[0];
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
TL_Delete(tl);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
TL1 = TL_New(date11,time11,Value11,date12,time12,Value12);
TL_SetColor(TL1,상승색);
date31 = date[LoBar[0]];
time31 = stime[LoBar[0]];
date32 = date[0];
time32 = stime[0];
}
If HiVal[0] < H Then
{
HiVal[0] = H;
HiBar[0] = 0;
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
TL_SetEnd(TL1, date12,time12,Value12);
date32 = date[0];
time32 = stime[0];
TL_Delete(tl);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
}
}
TL_SetSize(TL1,선두께);
하락중인 추세선이 바로 직전 하락추세선 저점의 +2틱부터 -3틱 사이 도달시 네모 표시.
네모 삭제; a.직저 -4틱 도달 전에 양전환시 삭제.
b.추가 하락하여 직전 하락추세선 저점의 -4틱 도달시 삭제.
네모 표시는 직전저점의 +2틱 ~ -3틱 사이에서만 존재 (쌍바닥). 감사합니다.
2023-05-03
1622
글번호 168672
지표