답변완료
자동 진입 및 청산 디버깅 가능할까요?
페어전략차트에서 시스템트레이딩으로 실행 즉시 자동 매도/매수 진입하고 수익조건이 되면 일괄청산하고 싶습니다.
모의ID로 아래 실행시 페어 종목의 현재가로 MarketPosition(0)=-1, MarketPosition(1) = 1로 변경은 되는데 미체결 내역에 나오지 않고 엉뚱한 진입가를 받아오는데 디버깅 도와주세요.
If Date == 매수하루전 && MarketPosition(0) == 0 Then {
Sell("매도",AtStop,D1현재가,D1_수량);
Buy("매수",AtStop,D2현재가,D2_수량);
D1진입가 = data1(EntryPrice);
D2진입가 = data2(EntryPrice);
}
맨 마지막 아래 부분도 디버깅 가능할까요?
If MarketPosition > 0 Then {
If 순수익 > 최소수익 Then {
If MarketPosition(0) == -1 Then {
ExitShort("모든매도청산",AtLimit,D1현재가); //매수
ExitLong("모든매수청산",AtLimit,D2현재가); //매도
}
} Else if 순수익 < -200 && 진입주문명에 "매도2"가 없으면 Then {
Sell("매도2",AtStop,D1현재가,D1_수량);
Buy("매수2",AtStop,D2현재가,D2_수량);
}
}
2023-05-10
1465
글번호 168835
시스템
답변완료
수식작성 부탁드립니다
트레이딩뷰 코드 수식입니다. 예스랭귀지는 생소하다보니 도움 부탁드리겠습니다
F로 시작하는 문은 사용자 정의 함수이고요,
중간에 보시면 함수를 중첩해서 사용하고 있습니다.
F_Dynamic_shift(value, len) =>
result = float(na)
if len >= 1
for i = 0 to len by 1
if na(result) or not na(value[i])
result := value[i]
result
result
F_X_MA(src, len, wei) =>
sum = 0.0
ma = 0.0
result = 0.0
sum := nz(sum[1]) - nz(src[len]) + src
ma := na(src[len]) ? na : sum / len
result := na(result[1]) ? ma : (src * wei + result[1] * (len - wei)) / len
result
BNK_len = input.int(defval=10, group=group_BNK, title='banker len')
BNK_threshold1 = input.int(defval=2, group=group_BNK, title='banker entry threshold')
BNK_threshold2 = input.int(defval=3, group=group_BNK, title='banker ready threshold')
F_Banker_Flow(len)=>
bankerflow = 2 * F_X_MA((close - ta.lowest(low, len)) / (ta.highest(high, len) - ta.lowest(low, len)) * 20, 2, 1)
- 5 * F_X_MA(F_X_MA((close - ta.lowest(low, len)) / (ta.highest(high, len) - ta.lowest(low, len)) * 20, 2, 1), 2, 1)
bankerflow
Banker_Flow = F_Banker_Flow(BNK_len)
F_Banker_LongAttack(len, threshold1, threshold2) =>
bankerflow = F_Banker_Flow(len)
long_attack = ta.crossover(bankerflow, threshold1)
long_entry = bankerflow <= threshold1
long_ready = bankerflow < threshold2
[long_attack, long_entry, long_ready]
[BNK_attack_long, BNK_entry_long, BNK_ready_long] = F_Banker_LongAttack(BNK_len, BNK_threshold1, BNK_threshold2)
p_long_attack = plot(BNK_attack_long ? 30 : 0, title='long-attack', color=BNK_attack_col, linewidth=1, style=plot.style_area) //model banker pump or dump start soon
2023-05-09
1947
글번호 168830
지표
답변완료
타주기 쌍바닥
input : N(15);
var : S1(0),D1(0),TF(0),box(0),idx(0),T(0),T1(0),T2(0),tx(0);
var : oo(0),hh(0),ll(0),TL1(0),TL2(0),clr(0),ii(0),TL(0);
Plot1(0);
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
idx = 0;
}
Else
idx = idx+1;
if D1 > 0 then
{
TF = idx%N;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and TF < TF[1]) Then
{
oo = O;
hh = H;
ll = L;
box = Box_New(sDate,sTime,oo,NextBarSdate,NextBarStime,c);
ii = 1;
if C[1] > OO[1] Then
T = 1;
if C[1] < OO[1] Then
T = -1;
if T != T[1] Then
{
Text_Delete(tx);
if T == 1 Then
{
tx = Text_New(sDate[1],sTime[1],OO[1]-PriceScale*1,"●");
Text_SetStyle(tx,2,2);
Text_SetColor(tx,Red);
Text_SetSize(tx,20);
}
if T == -1 Then
{
tx = Text_New(sDate[1],sTime[1],OO[1]+PriceScale*1,"●");
Text_SetStyle(tx,2,2);
Text_SetColor(tx,Blue);
Text_SetSize(tx,20);
}
}
}
Else
{
ii = ii +1;
if h > hh Then
hh = h;
if l < ll Then
ll = l;
var1 = Round(ii/2,1);
Box_SetEnd(box,sDate,sTime,C);
}
if C > oo Then
clr = Red;
else if C < oo Then
clr = Blue;
Else
clr = Green;
Box_SetColor(box,clr);
Box_SetSize(box,1);
Box_SetFill(box,true,255);
}
몸통만 있고 꼬리가 없는 수식입니다. 종가 기준 박스 하단이 쌍바닥일 때 동그라미 표시.
직전 박스 하단에서 -1틱부터 +1틱 사이이고, 상하 폭은 각각 설정.
박스 하단이 당일 고점으로부터 -1p 아래일 때만 표시. 감사합니다.
2023-05-09
1365
글번호 168804
지표