답변완료
부탁드립니다.
항상 감사드립니다.
아래식을 수정하여 진입 계약 수를 조절하고 싶습니다.
그럼 부탁드립니다.
tt가
1) -30 < tt <= 0 인 경우 1계약
2) -30 도달 되면 tt가 0이 될때까지 2계약
==> -30<=tt 가 되면, -60 < tt <= 0 까지 2계약,
0 까지 도달 시 계약수 1로 변경 ==> 1)수행
3) -60 도달 되면 tt가 -30이 될때까지 3계약
==> -60<=tt 가 되면, tt <=-60 or -60 <= tt <-30 까지 3계약,
-30 이상 도달 시 계약수 2로 변경 ==> 2)수행
input: BB(0), AA(-40);
Input : 손절(3),익절(3),익절하락(1);
input : P1(30), P2(120), p3(240);
input : StartTime(090300),EndTime(151500);
var : tx(0),X(false),Tcond(false),tt(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;
}
if (sdate != sdate[1] and stime >= Endtime) or
(sdate == sdate[1] and stime >= Endtime and stime[1] < Endtime)Then
{
Tcond = false;
}
## 진입
if Tcond == true and marketposition == 0
and crossup(var1,var2) Then
{
buy("B1");
}
if Tcond == true and marketposition == 0
and crossdown(var1,var2) Then
{
sell("S1");
}
if Tcond == true and marketposition == 0
and crossup(var2,var3) and var3[1] < var3 Then
{
buy("B2");
}
if Tcond == true and marketposition == 0
and crossdown(var3,var4) and var3[1] > var3 Then
{
sell("S2");
}
#### Target 청산
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 - 10;
if tt >= 0 Then
{
tt = 0;
Condition1 = false;
}
if tt > AA then ###
{
tx = Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(tt,0));
Text_SetSize(tx,20);
Text_Setstyle(tx,2,20);
}
else
{
Condition1 = true;
tx = Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(tt,0)+"★");
Text_SetSize(tx,20);
Text_Setstyle(tx,2,20);
}
}
if IsExitName("StopTrailing",1) == true then
{
tt = tt + 10;
if tt >= 0 Then
{
tt = 0;
X = true;
Condition1 = false;
}
if Condition1 == true and tt >= BB then ###
Condition1 = false; ###
if tt > AA then ###
{
tx = Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(tt,0));
Text_SetSize(tx,20);
Text_Setstyle(tx,2,2);
}
else
{
tx = Text_New(ExitDate(1),ExitTime(1),h[BarsSinceExit(1)],NumToStr(tt,0)+"★");
Text_SetSize(tx,20);
Text_Setstyle(tx,2,2);
}
}
}
if ((sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime)) Then {
if MarketPosition == 1 Then
ExitLong("BE6");
if MarketPosition == -1 Then
ExitShort("SE6");
}
2020-04-10
581
글번호 137812
시스템
답변완료
문의드립니다.
n = input(title="Periods", defval=2, minval=2, type=input.integer)
fractalBars = input(title="3 or 5 Bar Fractal", defval="3", options=["3", "5"])
colorcandles = input(title="Color candles?", defval=true)
dnFractal = if fractalBars == "5"
dnFractal5 = (high[n-2] < high[n]) and (high[n-1] < high[n]) and (high[n+1] < high[n]) and (high[n+2] < high[n])
else
if fractalBars == "3"
dnFractal3 = (high[n-1] < high[n]) and (high[n+1] < high[n])
upFractal = if fractalBars == "5"
upFractal5 = (low[n-2] > low[n]) and (low[n-1] > low[n]) and (low[n+1] > low[n]) and (low[n+2] > low[n])
else
if fractalBars == "3"
upFractal3 = (low[n-1] > low[n]) and (low[n+1] > low[n])
캔들 색변화는 제외해주세요
구현은 검색식으로 [N] 캔들 위, 아래에 사각형이 구현되도록 부탁드립니다.
항상 감사합니다.
2020-04-10
238
글번호 137803
검색