예스스탁
예스스탁 답변
2020-04-09 14:11:16
안녕하세요
예스스탁입니다,
1
현재 청산(StopLoss, StopTrailing)이 발생하는 부분 ◆표시가 있어
같은 봉일 경우 위치 잡기가 어렵습니다.
최대한 겹치지 않게 작성해 드립니다. 차트의 크기에 따라 다를수 있으므로
겹치면 해당 부분은 사용자분이 텍스트함수 조절하셔야 합니다.
2
수식내에 Text_Delete(tx1);를 삭제하시면 모든 청산에 표시됩니다.
3
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);
Text_Delete(tx1);
tx1 = Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(trcnt/(trcnt+lcnt)*100,1)+NewLine+NumToStr(R,1)+NewLine+NewLine);
Text_SetStyle(tx1,2,1);
}
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(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(trcnt/(trcnt+lcnt)*100,1)+NewLine+NumToStr(R,1)+NewLine+NewLine);
Text_SetStyle(tx1,2,1);
}
}
즐거운 하루되세요
> 라떼처럼 님이 쓴 글입니다.
> 제목 : 부탁드립니다.
> 감사드립니다.
마지막 청산된 (StopLoss, StopTrailing) 봉 위에 표시되게 요청드립니다.
모든 청산된 (StopLoss, StopTrailing) 봉 위에 표시되게 하는 방법도 설명 부탁드립니다.
차트 마지막봉 위에 표시되게 작성해 드립니다.
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);