답변완료
부탁드립니다.
항상 감사드립니다.
다시좀 부탁드리겠습니다.
R3값이 20이하가 되면 T3값이 40이 될때 까지만 ■가 포함된 진입으로 표시가 되어야 하는데 한번 R3값이 20 이하가 되면 계속 ■가 포함진 진입으로 표시됩니다.
R3값이 20이하가 되면 T3값이 40 이상이 될때 까지만 ■포함 요청드립니다.
아래는 요청사항입니다.
2. 최근 N(10)개의 R3의 값이 30 이하가 되면
"10개를 포함하여 누적으로 T3가 40 까지 도달" 할때까지
■가 포함된 신호 (B■,S■)로 표현하고 싶습니다. (3,4,5번에 설명)
"T3"값이 50까지 도달 되면 다시 B,S 으로 표시
3. "T3" : "10개를 포함"하여 stoploss, stoptrailing 수 누적 된 값
R3의 값이 30 이하가 되면 R3의 값을 30으로 만들어준 10개를 포함하여
이후 청산되는 stoploss, stoptrailing 수를 누적시켜 T3 값을 만들고 싶습니다.
R3 = [(STrailing개수)/(N(10)개)] x100
T3 = [(누적STrailing개수)/(누적SLoss+누적STrailing)개수] x100
T3전체모수: (누적SLoss+누적STrailing)개수 = 10개+1개, 10개+2개, 10개+3개 ...
표시 예)
-------------------------------------------------------------
R3 = 20.0 =(2개/10개*100) <- STrailing 2개, SLoss 8개, 분모모수: 10개 *R3 < 20 조건만족 (■포함시작)
T3= 27.2 = (3개/11개*100) <- STrailing 3개, SLoss 8개, 분모모수: 11개 *T3 < 40
T3= 33.3 = (4개/12개*100) <- STrailing 4개, SLoss 8개, 분모모수: 12개 *T3 < 40
T3= 38.4 = (5개/13개*100) <- STrailing 5개, SLoss 8개, 분모모수: 13개 *T3 < 40
T3= 35.7 = (5개/14개*100) <- STrailing 5개, SLoss 9개, 분모모수: 14개 *T3 < 40
T3= 40.0 = (6개/15개*100) <- STrailing 6개, SLoss 9개, 분모모수: 15개 *T3 >= 40 (■포함종료)
R3= [(STrailing개수)/(N(10)개)] x100 <- 최근 N(10)개의 R3의 값 분모모수: 10개
------------------------------------------------------------
*R3 30 이하가 되고 T3가 40이 될때 까지는 R3 값은 무시
(T3가 40이 될때 까지 R3값에 의한 조건발생 없음)
(T3가 40 도달 이후에 최근 10개에 대한 R3값에 의해 조건 발생)
4. T3값 표시(빨강): ■가 포함된 신호발생 후 청산(stoploss, stoptrailing) 다음 봉에 T3가 40이 될때 까지 만 표시
input : 시작(20), 종료(40), N(10);
input : 손절(20),익절(15),익절하락(3);
input : P1(30), P2(120), p3(240);
input : StartTime(090000),EndTime(050000);
var : tt(0),tx(0),X(false),tx1(0),cnt(0),sum(0);
var: Tcond(false),ht(0),lcnt(0),trcnt(0),R(-1);
Array : XX[200](-1);
var : tx3(0),cnt3(0),sum3(0),lcnt3(0),trcnt3(0),R3(-1),TR3(0),GR3(0), tx4(0),T3(0);
Array : XX3[200](-1);
var1 = ma(C, P1);
var2 = ma(C, P2);
var3 = ma(C, P3);
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
Tcond = true;
tt = 0;
X = false;
}
if Tcond == true then
{
if marketposition == 0 and crossup(var1,var2) Then {
if Condition3 == true then ####
buy("B1■");
Else
buy("B1");
}
if marketposition == 0 and crossdown(var1,var2) Then {
if Condition3 == true then ####
sell("S1■");
Else
sell("S1");
}
if marketposition == 0 and crossup(var2,var3) and var3[1] < var3 Then {
if Condition3 == true then ####
buy("B2■");
Else
buy("B2");
}
if marketposition == 0 and crossdown(var3,var4) and var3[1] > var3 Then {
if Condition3 == true then ####
sell("S2■");
Else
sell("S2");
}
if MarketPosition == 1 then
{
SetStopTrailing(익절하락,익절,PointStop);
SetStopLoss(손절,PointStop);
}
if MarketPosition == -1 Then
{
SetStopTrailing(익절하락,익절,PointStop);
SetStopLoss(손절,PointStop);
}
}
### 수정 요청 (삭제해도 무방합니다.)
if TotalTrades > TotalTrades[1] then
{
if IsExitName("StopLoss",1) == true then
{
lcnt3 = lcnt3+1;
XX3[0] = 0;
for cnt3 = 1 to 199
{
XX3[cnt3] = XX3[cnt3-1][1];
}
if (trcnt3+lcnt3) >= N then
{
sum3 = 0;
for cnt3 = 0 to N-1
{
if XX3[cnt3] == 1 Then
sum3 = sum3 + 1;
}
R3 = sum3/N*100;
if Condition3 == false and R3 <= 시작 and R3[1] > 시작 Then
{
Condition3 = true;
value1 = sum3;
value2 = 1;
}
else
{
if Condition3 == true Then
{
value1 = value1 + 0;
value2 = value2 + 1;
T3 = value1/value2*100; ## T3 추가
if value1/value2*100 >= 종료 Then
Condition3 = true;
}
}
}
}
if IsExitName("StopTrailing",1) == true then
{
trcnt3 = trcnt3+1;
XX3[0] = 1;
for cnt3 = 1 to 199
{
XX3[cnt3] = XX3[cnt3-1][1];
}
if (trcnt3+lcnt3) >= N then
{
sum3 = 0;
for cnt3 = 0 to N-1
{
if XX3[cnt3] == 1 Then
sum3 = sum3+1;
}
R3 = sum3/N*100;
if Condition3 == false and R3 <= 시작 and R3[1] > 시작 Then
{
Condition3 = true;
value1 = sum3;
value2 = 1;
}
else
{
if Condition3 == true Then
{
value1 = value1 + 1;
value2 = value2 + 1;
T3 = value1/value2*100; ## T3 추가
if value1/value2*100 >= 종료 Then
Condition3 = true;
}
}
}
}
TR3 = trcnt3/(trcnt3+lcnt3)*100 ;
}
Text_Delete(tx3);
tx3 = Text_New(NextBarSdate,NextBarStime,H,NumToStr(TR3,1)+NewLine+NumToStr(R3,1));
Text_SetSize(tx3,15);
Text_Setstyle(tx3,2,20);
#### ■일때 T3 표시 추가
/*
t4 = Text_New(NextBarSdate,NextBarStime,H,+NewLine+NumToStr(T3,1));
Text_SetSize(tx3,15);
Text_Setstyle(tx3,2,20);
*/
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
{
Tcond = false;
if MarketPosition == 1 Then
{
ExitLong("BE6");
}
if MarketPosition == -1 Then
{
ExitShort("SE6");
}
}
2020-04-27
1000
글번호 138402
시스템
답변완료
청산 수식 부탁드려요( 국내 주식)
지금 사용하고 있는 분할매수 일괄 청산 수식인데요...
분할매수는 유지하고 일괄 청산을 --> 분할 청산으로 하고 있습니다.
전체 매수 금액의 평균값에서
5% 수익시 25% 청산
10% 수익시 50% 청산
15% 수익시 75% 청산
20% 수익시 100% 청산
하는 분할 매수 청산 하는 수식을 반영부탁드릴께요..
사용하는 수식입니다.
참고로 분봉 매매입니다. 국내 주식
input : n(200),하락퍼센트(0.95),하락퍼센트률(0.05);
input : p(20),MFI값(70), MFI값하락률(5);
input : 전일대비하락률(0.5);
input : 매매수(300),금액1(10),금액2(20),금액3(30),금액4(100),금액5(200),금액6(200),금액7(300),금액8(300);
input : 일괄청산률(9);
var1 = highest(H,n);
var2 = mfi(P);
if stime < 143000 then
{
if MaxEntries < 매매수 and
c < var1*하락퍼센트 and
var2 < MFI값 and
c < o and
c <= c[1]*(100-전일대비하락률)/100 Then
buy("b1",OnClose,def,Floor(금액1*10000/c));
if MaxEntries < 매매수 and
c < var1*(하락퍼센트- 하락퍼센트률) and
var2 < (MFI값- MFI값하락률) and
c < o and
c <= c[1]*(99.4-전일대비하락률)/100 Then
buy("b2",OnClose,def,Floor(금액2*10000/c));
if MaxEntries < 매매수 and
c < var1*(하락퍼센트- 하락퍼센트률*2) and
var2 < (MFI값- MFI값하락률*2) and
c < o and
c <= c[1]*(100-전일대비하락률*2)/100 Then
buy("b3",OnClose,def,Floor(금액3*10000/c));
if MaxEntries < 매매수 and
c < var1*(하락퍼센트- 하락퍼센트률*3) and
var2 < (MFI값- MFI값하락률*3) and
c < o and
c <= c[1]*( 100-전일대비하락률*3)/100 Then
buy("b4",OnClose,def,Floor(금액4*10000/c));
if MaxEntries < 매매수 and
c < var1*(하락퍼센트- 하락퍼센트률*4) and
var2 < (MFI값- MFI값하락률*4) and
c < o and
c <= c[1]*( 100-전일대비하락률*4)/100 Then
buy("b5",OnClose,def,Floor(금액5*10000/c));
if MaxEntries < 매매수 and
c < var1*(하락퍼센트- 하락퍼센트률*5) and
var2 < (MFI값- MFI값하락률*5) and
c < o and
c <= c[1]*( 100-전일대비하락률*5)/100 Then
buy("b6",OnClose,def,Floor(금액6*10000/c));
if MaxEntries < 매매수 and
c < var1*(하락퍼센트- 하락퍼센트률*6) and
var2 < (MFI값- MFI값하락률*6) and
c < o and
c <= c[1]*( 100-전일대비하락률*6)/100 Then
buy("b7",OnClose,def,Floor(금액6*10000/c));
if MaxEntries < 매매수 and
c < var1*(하락퍼센트- 하락퍼센트률*7) and
var2 < (MFI값- MFI값하락률*7) and
c < o and
c <= c[1]*( 100-전일대비하락률*7)/100 Then
buy("b8",OnClose,def,Floor(금액6*10000/c));
ExitLong("bx",atlimit,AvgEntryPrice*(1+일괄청산률*0.01));
}
Else
SetStopProfittarget(0);
2020-04-27
1202
글번호 138385
시스템
답변완료
문의드립니다.
// INPUT VARIABLES FOR VORTEX:
vortexLen = input(30, title="Length for Vortex", minval=1)
emaLen = input(10, title="Length of Positive and Negative EMA's", type=input.integer, minval=1)
colorBars = input(true, title="Color Price Bars Based on Vortex?")
plotVLines = input(false, title="Plot VI+ and VI- Lines?")
// VORTEX CALCULATION:
//Returns positive and negative trendlines.
vortex(posSum, negSum, vLen)=>
tRange = sum(atr(1), vLen)
vmPlus = posSum / tRange
vmNeg = negSum / tRange
[vmPlus, vmNeg]
[vPlus, vNeg] = vortex(sum(abs(high - low[1]), vortexLen), sum(abs(low - high[1]), vortexLen), vortexLen)
plusEMA = ema(vPlus, emaLen)
negEMA = ema(vNeg, emaLen)
vDiff = abs(plusEMA - negEMA)
// PLOTTING:
var color vColor = na
vColor := plusEMA > negEMA and plusEMA >= plusEMA[1] ? #1b5e20 : plusEMA > negEMA and plusEMA < plusEMA[1] ? #a5d6a7 : negEMA >= plusEMA and negEMA > negEMA[1] ? #b71c1c : negEMA > plusEMA and negEMA < negEMA[1] ? #c76a72 : nz(vColor[1])
plot(vDiff, style=plot.style_histogram, color=vColor, linewidth=3, transp=0)
plot(plotVLines ? plusEMA : na, title="VI +", color=color.green, linewidth=2)
plot(plotVLines ? negEMA : na, title="VI -", color=color.red, linewidth=2)
barcolor(colorBars ? vColor : na)
항상 도움주심을 감사드립니다.
좋은 하루 되세요
2020-04-27
1373
글번호 138381
지표