예스스탁
예스스탁 답변
2020-04-09 09:25:44
안녕하세요
예스스탁입니다,
차트 마지막봉 위에 표시되게 작성해 드립니다.
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);
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 (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");
}
}
if Tcond == true then
{
if marketposition == 0 and crossup(var1,var2) Then {
buy("B1");
}
if marketposition == 0 and crossdown(var1,var2) Then {
sell("S1");
}
if marketposition == 0 and crossup(var2,var3) and var3[1] < var3 Then {
buy("B2");
}
if marketposition == 0 and crossdown(var3,var4) and var3[1] > var3 Then {
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
{
lcnt = lcnt+1;
XX[0] = 0;
for cnt = 1 to 199
{
XX[cnt] = XX[cnt-1][1];
}
if Floor((trcnt+lcnt)*0.2) > 1 then
{
sum = 0;
for cnt = 0 to Floor((trcnt+lcnt)*0.2)-1
{
if XX[cnt] == 1 Then
sum = sum+1;
}
R = sum/Floor((trcnt+lcnt)*0.2)*100;
}
tt = tt +1 ;
if tt > ht Then
{
ht = tt;
}
tx = Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(ht,0)+"◆");
Text_SetSize(tx,20);
Text_Setstyle(tx,2,1);
Text_SetColor(tx,GREEN);
}
if IsExitName("StopTrailing",1) == true then
{
trcnt = trcnt+1;
XX[0] = 1;
for cnt = 1 to 199
{
XX[cnt] = XX[cnt-1][1];
}
if Floor((trcnt+lcnt)*0.2) > 1 then
{
sum = 0;
for cnt = 0 to Floor((trcnt+lcnt)*0.2)-1
{
if XX[cnt] == 1 Then
sum = sum+1;
}
R = sum/Floor((trcnt+lcnt)*0.2)*100;
}
tt = tt + 1;
ht = tt;
tx = Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(ht,0)+"◆");
Text_SetSize(tx,20);
Text_Setstyle(tx,2,1);
Text_SetColor(tx,GREEN);
}
}
Text_Delete(tx1);
tx1 = Text_New(NextBarSdate,NextBarStime,H,NumToStr(trcnt/(trcnt+lcnt)*100,1)+NewLine+NumToStr(R,1));
Text_SetStyle(tx1,0,1);
즐거운 하루되세요
> 라떼처럼 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> 항상 감사드립니다.
아래와 같이 ##카운트를 추가하고 싶습니다.
1) 전략창 전체의: [(StopTrailing 개수) / (StopLoss+StopTrailing) 개수] x100
2) 청산시점 포함하여 최근 20% 개수에 대한 : [(StopTrailing 개수) / (StopLoss+StopTrailing) 개수] x100
예_1
전체 청산 개수 20개(StopTrailing 10개, StopLoss 10개)
최근20% 청산개수 4개(StopTrailing 1개, StopLoss 3개)
1) 전체 개수(20개)= 11010101001010110001 --> 수식 : [10개/(10개+10개)]x100 = 50.0
2) 20% 개수(4개)= 0001 --> 수식 : [1개/(1개+3개)]x100 = 25.0
예_2
전체 청산 개수 25개(StopTrailing 13개, StopLoss 12개)
최근20% 청산개수 5개(StopTrailing 2개, StopLoss 3개)
1) 전체 개수(25개) = 1101011010101001010110001 --> 수식 : [13/(13+12)]x100 = 52.0
2) 20% 개수(5개) = 10001 --> 수식 : [2/(2+3)]x100 = 40.0
(StopTrailing:1, StopLoss:0로 표현)
1),2)를 텍스트 표시하고 싶습니다.
텍스트는 1)이 위 2)는 아래에 위치하게 부탁드립니다.
1)값(위)
2)값(아래)
값은 소수 한자리 수까지 표현 부탁드립니다.
input : 손절(20),익절(15),익절하락(3);
input : P1(30), P2(120), p3(240);
input : StartTime(090000),EndTime(050000);
var : tt(0),tx(0),X(false);
var: Tcond(false),ht(0);
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 (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");
}
}
if Tcond == true then
{
if marketposition == 0 and crossup(var1,var2) Then {
buy("B1");
}
if marketposition == 0 and crossdown(var1,var2) Then {
sell("S1");
}
if marketposition == 0 and crossup(var2,var3) and var3[1] < var3 Then {
buy("B2");
}
if marketposition == 0 and crossdown(var3,var4) and var3[1] > var3 Then {
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
{
tt = tt +1 ;
if tt > ht Then
{
ht = tt;
}
Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(ht,0)+"◆");
Text_SetSize(tx,20);
Text_Setstyle(tx,2,20);
Text_SetColor(tx,GREEN);
}
}
if IsExitName("StopTrailing",1) == true then
{
tt = tt + 1;
ht = tt;
}
Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(ht,0)+"◆");
Text_SetSize(tx,20);
Text_Setstyle(tx,2,20);
Text_SetColor(tx,GREEN);
}
}
}