답변완료
수식 부탁드립니다
매번 도와주셔서 감사합니다. 지표식 부탁드립니다.
study("Price Trend", overlay = true)
dlen = input(defval = 100, title = "Price Channel Period", minval = 10)
lwidth = input(defval = 3, title = "Line Width", minval = 1, maxval = 4)
dchannel(len)=>
float hh = highest(len)
float ll = lowest(len)
int trend = 0
trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
[hh, ll, trend]
dchanneltr(len)=>
float hh = highest(len)
float ll = lowest(len)
int trend = 0
trend := close >= hh[1] ? 1 : close <= ll[1] ? -1 : nz(trend[1])
[upper, lower, maintrend] = dchannel(dlen)
tt = maintrend == 1 ? 10 : -10
[u1, l1, t1] = dchannel(dlen -1 )
tt := tt - (sign(dchanneltr(dlen - 1)) != sign(maintrend) ? int(sign(maintrend)) : 0)
tt := tt - (sign(dchanneltr(dlen - 2)) != sign(maintrend) ? int(sign(maintrend)) : 0)
tt := tt - (sign(dchanneltr(dlen - 3)) != sign(maintrend) ? int(sign(maintrend)) : 0)
tt := tt - (sign(dchanneltr(dlen - 4)) != sign(maintrend) ? int(sign(maintrend)) : 0)
tt := tt - (sign(dchanneltr(dlen - 5)) != sign(maintrend) ? int(sign(maintrend)) : 0)
tt := tt - (sign(dchanneltr(dlen - 6)) != sign(maintrend) ? int(sign(maintrend)) : 0)
tt := tt - (sign(dchanneltr(dlen - 7)) != sign(maintrend) ? int(sign(maintrend)) : 0)
tt := tt - (sign(dchanneltr(dlen - 8)) != sign(maintrend) ? int(sign(maintrend)) : 0)
tt := tt - (sign(dchanneltr(dlen - 9)) != sign(maintrend) ? int(sign(maintrend)) : 0)
getcolor(trend)=>
_ret = trend >= 10.0 ? #00FF00ff :
trend >= 9.0 ? #00FF00e5 :
trend >= 8.0 ? #00FF00cc :
trend >= 7.0 ? #00FF00b2 :
trend >= 6.0 ? #00FF0099 :
trend >= 5.0 ? #00FF007f :
trend >= 4.0 ? #00FF0066 :
trend >= 3.0 ? #00FF004c :
trend >= 2.0 ? #00FF0033 :
trend >= 1.0 ? #00FF0019 :
trend == 0.0 ? color.new(color.white, 100) :
trend >= -1.0 ? #FF000019 :
trend >= -2.0 ? #FF000033 :
trend >= -3.0 ? #FF00004c :
trend >= -4.0 ? #FF000066 :
trend >= -5.0 ? #FF00007f :
trend >= -6.0 ? #FF000099 :
trend >= -7.0 ? #FF0000b2 :
trend >= -8.0 ? #FF0000cc :
trend >= -9.0 ? #FF0000e5 : #FF0000ff
tline = maintrend == 1 ? lower : upper
tcol = (maintrend == 1 and nz(maintrend[1]) == 1) or
(maintrend == -1 and nz(maintrend[1]) == -1) ? getcolor(tt) :
na
plot(tline, color = tcol, linewidth = lwidth)
plotchar(maintrend == 1 and tt > 2 and (tt < 10 or low == lower) ? lower : na,
char = "↑",
color = color.green,
location = location.absolute,
size = size.small)
plotchar(maintrend == -1 and tt < -2 and (tt > -10 or high == upper) ? upper : na,
char = "↓",
color = color.red,
location = location.absolute,
size = size.small)
2024-03-10
732
글번호 177337
지표
답변완료
부탁드립니다
안녕하세요
항상 성심껏 만들어 주셔서 감사드립니다.
아래 기준의 2가지 옵션 피보나치 지표 부탁드립니다.
공통적으로...
- 선,칼라 선택 가능
- 0.0%, 23.6%, 38.2%, 50.0%, 61.8%, 76.4%, 100% 기본수열 표시
- 가능하다면 변화된 과거선 없이 최종 발생한 수평선만 표시
옵션 1번
- (변수-n봉전)기준 당일 최고점(0.0%)에서 (변수-n봉전)기준 당일 최저점(38.2%)를 표시하고 나머지 수열(23.6%, 50.0%, 61.8%, 76.4%, 100%)을 하향으로 표시
옵션 2번
- (변수-n봉전)기준 당일 최저점(0.0%)에서 (변수-n봉전)기준 당일 최고점(38.2%)를 표시하고 나머지 수열(23.6%, 50.0%, 61.8%, 76.4%, 100%)을 상향으로 표시
설명이 부족하지 않았는지 모르겠네요...오늘도 부탁드리고 미리 감사드립니다.
좋은 하루되시길 바랍니다.
2024-03-10
744
글번호 177334
지표
답변완료
수식 요 청
Inputs : Period(20), Sence(1.5), CC_DN(Yellow);
Vars:
VLineUp(0),
VLineDn(0),
HHighest(0),
LLowest(0),
JustChanged(FALSE),
VLine(0), DBN(0),T(0);
Array:
Highs[35](0),
Lows[35](0),
RRange[35](0),
UpWave[1](FALSE),
DnWave[1](FALSE);
If STime == 180000 Then
DBN = 0;
DBN = DBN + 1;
Var1 = Period;
Var2 = Var1 - 1;
Var3 = Var1 - 2;
Var5 = Sence;
Var6 = H-L;
JustChanged = FALSE;
if CurrentBar <= Var2 then begin
Highs[CurrentBar] = Close;
Lows[CurrentBar] = Close;
RRange[CurrentBar] = (H-L) /2;
end;
if CurrentBar == Var1 then begin
if Highs[Var2] >= Highs[Var3] then begin
UpWave[1] = TRUE;
HHighest = Highs[Var2];
VLineUp = HHighest - (Var5 * MA(Var6,Var2));
#Plot1(VLineUp,"VLineUp");
end;
if Highs[Var2] < Highs[Var3] then begin
DnWave[1] = TRUE;
LLowest = Lows[Var2];
VLineDn = LLowest + (Var5 * MA(Var6,Var2));
#Plot2(VLineDn,"VLineDn");
end;
end;
if CurrentBar > Var1 then begin
if DnWave[1] and Close > VLineDn then begin
DnWave[1] = FALSE;
UpWave[1] = TRUE;
JustChanged = TRUE;
HHighest = Close;
LLowest = 0;
end;
if UpWave[1] and Close < VLineUp and JustChanged == FALSE then begin
UpWave[1] = FALSE;
DnWave[1] = TRUE;
JustChanged = TRUE;
LLowest = Close;
HHighest = 0;
end;
if JustChanged == FALSE then begin
if Close > HHighest then
HHighest = Close;
else if Close < LLowest then
LLowest = Close;
end;
VLineUp = HHighest - (Var5 * MA(Var6,Var2));
VLineDn = LLowest + (Var5 * MA(Var6,Var2));
if UpWave[1] then
T = 1;
else if DnWave[1] then
T = -1;
end;
Input : BBP(120), MultiD(2);
var : BBmd(0),BBup(0),BBdn(0);
BBmd = ma(C,Period);
BBup = BollBandUp(BBP,MultiD);
BBdn = BollBandDown(BBP,MultiD);
if CrossDown(C,BBup) and t == -1 Then
sell();
if crossup(C,BBdn) and t == 1 Then
buy();
안녕하세요
위식에서 수정부탁드림니다
매수조건
HP선이 이평60 선위에있는 상태에서
Hp선을 터치나 하락후 상승돌파시
sw2선이 양선일때 매수
손절청산 이평60.hp선하향돌파시.
매도
HP선이 이평60 선아래에있고
sw2선이 음선일때 매도
손절청산 이평60.hp선 상향돌파시
2024-03-11
826
글번호 177333
시스템
답변완료
시스템식 요청드립니다.
안녕하세요 수식을 작성하는데 어려움이 있어 이렇게 글을 남깁니다.
위의 그림 2, 3번을 보시면 대략적으로 그림으로 작성하였습니다.
타점 에서 100주 매수후 30주 매도 하고 중간에 30주 매도 해서 총 40주가 남은
상태에서 타점 1로 60주 매수해서 다시 100주가 되도록 맞췄습니다.
그런데 타점1 5% 익절에서 30주만 매도가 되어야 하는데
그림 1 성능보고서를 보시면, 타점에서 30주매도, 타점 1에서 30주 매도 총 60주가
매도 되었습니다.
타점, 타점 1이 따로따로 시스템식이 적용 되는것 같은데
어떻게 해야 할지 부탁드리겠습니다.
input : 베팅금(1000000);
input : 시작날짜 (20240113),Xtime(110000) ;
input : 타점(5000),손절(1000);
var : P618(0),P5(0),P382(0),HH(0),LL(0);
Var : day(0),EntryDay(0),entry(False),dd(0),ED(0);
if sDate >= 시작날짜 Then
{
if Bdate != Bdate[1] Then
{
entry = true;
day = day+1;
dd = dd+1;
}
if HH == 0 or (HH > 0 and H > HH) Then
HH = H;
#고점갱신용 수식
if LL == 0 or (LL > 0 and L < LL) Then
LL = L;
#저점갱신용 수식
}
P618 = LL+(HH-LL)*0.618;
P5 = LL+(HH-LL)*0.5;
P382 = LL+(HH-LL)*0.382;
if MarketPosition == 0 and entry == true and c > 타점 Then
Buy("타점",AtLimit,타점,Floor((베팅금)/타점));
if MarketPosition == 1 Then
{
Condition1 = False;
If C >= HH[1] AND LatestExitName(0) == "타점 5%익절 P5청산" Then
{
Condition1 = true;
Buy("타점1",OnClosE,DeF,Floor((베팅금)/타점*0.6));
}
If C >= HH[1] AND LatestExitName(0) == "타점 10%익절 P618청산" Then
{
Condition1 = true;
Buy("타점2",OnClosE,DeF,Floor((베팅금)/타점*0.8));
}
#전봉대비 수량 감소(일부 청산발생을 위미)
if CurrentContracts < CurrentContracts[1] Then
{
#청산가 저장
var1 = LatestExitPrice(0);
if LatestExitName(0) == "타점 5%익절" or LatestExitName(0) == "타점1 5%익절" or LatestExitName(0) == "타점2 5%익절" Then
Condition11 = true;
if LatestExitName(0) == "타점 5%익절 P5청산" or LatestExitName(0) == "타점 10%익절" or LatestExitName(0) == "타점1 5%익절 P618청산"
or LatestExitName(0) == "타점1 10%익절" or LatestExitName(0) == "타점2 5%익절 P618청산" or LatestExitName(0) == "타점2 10%익절" Then
Condition22 = true;
if LatestExitName(0) == "타점 5%익절 P382청산" or LatestExitName(0) == "타점 10%익절 P618청산" or LatestExitName(0) == "타점1 5%익절 P5청산"
or LatestExitName(0) == "타점1 10%익절 P618청산" or LatestExitName(0) == "타점2 5%익절 P5청산" or LatestExitName(0) == "타점2 10%익절 P618청산" Then
Condition33 = true;
if LatestExitName(0) == "타점 10%익절 P5청산" or LatestExitName(0) == "타점1 10%익절 P5청산" or LatestExitName(0) == "타점2 10%익절 P5청산" Then
Condition44 = true;
}
#전봉대비 수량 증가(추가 진입발생을 의미)
if CurrentContracts > CurrentContracts[1] Then
{
#현재수량 저장
Var3 = CurrentContracts;
Var4 = AvgEntryPrice;
Condition11 = False;
Condition22 = False;
Condition33= False;
Condition44 = False;
}
if (LatestEntryName(0) == "타점") and Condition1 == False Then
ExitLong("타점 5%익절",AtLimit,AvgEntryPrice*1.05,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점 5%익절") and c <= P5 Then
ExitLong("타점 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점 5%익절 P5청산") and c <= P382 Then
ExitLong("타점 5%익절 P382청산",AtLimit,P382,"",Floor(베팅금/타점)*0.4);
if (LatestEntryName(0) == "타점") and Condition1 == False Then
ExitLong("타점 10%익절",AtLimit,AvgEntryPrice*1.2,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점 10%익절") and c <= P618 Then
ExitLong("타점 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2);
if (LatestExitName(0) == "타점 10%익절 P618청산") and c <= P5 Then
ExitLong("타점 10%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.2);
if (LatestEntryName(0) == "타점1")Then
ExitLong("타점1 5%익절",AtLimit,latestEntryPrice*1.05,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점1 5%익절") and c <= P618 Then
ExitLong("타점1 5%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점1 5%익절 P618청산") and c <= 5 Then
ExitLong("타점1 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.4);
if (LatestEntryName(0) == "타점1") Then
ExitLong("타점1 10%익절",AtLimit,latestEntryPrice*1.1,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점1 10%익절") and c <= P618 Then
ExitLong("타점1 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2);
if (LatestExitName(0) == "타점1 10%익절 P618청산") and c <= P5 Then
ExitLong("타점1 10%익절 P5청산",AtLimit,P5,"",(베팅금/타점)*0.2);
if (LatestEntryName(0) == "타점2")Then
ExitLong("타점2 5%익절",AtLimit,latestEntryPrice*1.05,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점2 5%익절") and c <= P618 Then
ExitLong("타점2 5%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점2 5%익절 P618청산") and c <= 5 Then
ExitLong("타점2 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.4);
if (LatestEntryName(0) == "타점2") Then
ExitLong("타점2 10%익절",AtLimit,latestEntryPrice*1.1,"",(베팅금/타점)*0.3);
if (LatestExitName(0) == "타점2 10%익절") and c <= P618 Then
ExitLong("타점2 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2);
if (LatestExitName(0) == "타점2 10%익절 P618청산") and c <= P5 Then
ExitLong("타점2 10%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.2);
}
if MarketPosition == 1 and sTime > xtime and 손절 >= c Then
ExitLong("손절");
if MarketPosition == 1 and (LatestEntryName(0) == "타점1") and c <= latestEntryPrice*0.96 Then
ExitLong("5%돌파손절");
if MarketPosition == 1 and (LatestEntryName(0) == "타점2") and c <= latestEntryPrice*0.96 Then
ExitLong("10%돌파손절");
2024-03-10
803
글번호 177327
시스템