답변완료
문의 드립니다.
아래는 게시판 80595 질답 내용입니다.
180분 캔들을 매매에 사용중인데 180분봉 완성시 그다음 시가 청산후
30분후에 진입신호가 적용되질 않습니다.
보완해야할 것이 있는지 문의 드립니다.
1
현재 진입이 완성봉에서 값이 셋팅되서 다음봉 미완성시에 발생하는 내용입니다.
atstop,atlimit으로 봉완성시 값이 셋팅이 되면
다음봉 미완성시에 신호발생을 제어할 수 없습니다.
또한 if문이 봉완성기준입니다.
미완성시에 청산시점에서 30분이후로 지정이 불가능합니다.
문의하신 내용이면 시가에 청산이 발생하면
봉단위로 30분이후 봉부터 진입이 발생하게만 작성이 됩니다.
올리신 식이 봉완성시 진입이 있으면 다음봉 시가에서 청산을 모두 하므로
봉완성시 진입이 있으면 다음진입은 30분봉 이상 경과한 다음봉부터 신호가 발생하게 됩니다.
input : starttime(160000),endtime(80000),n(30);
var : Tcond(false),hh(0),h1(0),ll(0),l1(0);
var : s1(0),d1(0),tm(0),trade(False),tt(0);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
hh = h;
ll = l;
h1 = hh[1];
l1 = ll[1];
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
Trade = true;
}
if D1 > 0 then
{
if NextBarSdate == D1 Then
TM = TimeToMinutes(NextBarStime)-S1;
Else
TM = TimeToMinutes(NextBarStime)+1440-S1;
}
input : 익절틱수(0),손절틱수(0);
if MarketPosition != 0 Then
{
Trade = False;
TT = TM;
}
Else
{
Trade = true;
}
if Trade == False and TM >= TT+30 Then
Trade = true;
if NextBarSdate != sDate and Trade == true Then
{
if NextBarOpen != C Then
{
Buy("b",AtStop,NextBarOpen+PriceScale*5);
}
}
ExitLong("bx",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b1",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx1",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b2",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx2",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b3",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx3",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b4",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx4",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b5",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx5",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b6",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx6",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b7",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx7",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b8",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx8",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b9",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx9",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b10",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx10",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b11",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx11",AtMarket);
if NextBarSdate != sDate and Trade == true Then
{
if NextBarOpen != C Then
{
Sell("s",AtStop,NextBarOpen-PriceScale*5);
}
}
ExitShort("sx",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s1",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx1",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s2",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx2",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s3",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx3",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s4",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx4",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s5",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx5",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s6",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx6",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s7",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx7",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s8",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx8",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s9",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx9",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s10",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx10",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s11",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx11",AtMarket);
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
------------------
input : starttime(160000),endtime(80000),n(30);
var : Tcond(false),hh(0),h1(0),ll(0),l1(0);
var : s1(0),d1(0),tm(0),trade(False),tt(0);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= endtime) or
(sdate == sdate[1] and stime >= endtime and stime[1] < endtime) then
{
Tcond = false;
}
if (sdate != sdate[1] and stime >= starttime) or
(sdate == sdate[1] and stime >= starttime and stime[1] < starttime) then
{
Tcond = true;
hh = h;
ll = l;
h1 = hh[1];
l1 = ll[1];
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
Trade = true;
}
if D1 > 0 then
{
if NextBarSdate == D1 Then
TM = TimeToMinutes(NextBarStime)-S1;
Else
TM = TimeToMinutes(NextBarStime)+1440-S1;
}
input : 익절틱수(0),손절틱수(0);
if MarketPosition != 0 Then
{
Trade = False;
TT = TM;
}
Else
{
Trade = true;
}
if Trade == False and TM >= TT+30 Then
Trade = true;
if NextBarSdate != sDate and Trade == true Then
{
if NextBarOpen != C Then
{
Buy("b",AtStop,NextBarOpen+PriceScale*5);
}
}
ExitLong("bx",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b1",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx1",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b2",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx2",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b3",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx3",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b4",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx4",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Buy("b5",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx5",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b6",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx6",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b7",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx7",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b8",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx8",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b9",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx9",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b10",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx10",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Buy("b11",AtStop,NextBarOpen+PriceScale*5);
}
ExitLong("bx11",AtMarket);
if NextBarSdate != sDate and Trade == true Then
{
if NextBarOpen != C Then
{
Sell("s",AtStop,NextBarOpen-PriceScale*5);
}
}
ExitShort("sx",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s1",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx1",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s2",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx2",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s3",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx3",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s4",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx4",AtMarket);
if NextBarOpen != C and Trade == true Then
{
Sell("s5",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx5",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s6",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx6",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s7",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx7",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s8",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx8",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s9",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx9",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s10",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx10",AtMarket);
if NextBarOpen == C and Trade == true Then
{
Sell("s11",AtStop,NextBarOpen-PriceScale*5);
}
ExitShort("sx11",AtMarket);
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
위 수식어의 캔들이 180분봉으로 가정했을때 시가청산후
진입신호를
매수는 동일상품의 캔들 1분봉 골든(5,20) 3회시 주문, 청산은 180분봉 완성후 시가청산
매도는 동일상품의 캔들 1분봉 데드(20,5) 3회시 주문, 청산은 180분봉 완성후 시가청산
으로 된 수식어를 추가로 부탁드리고자 합니다.
2023-02-02
778
글번호 165931
시스템
답변완료
수식 변환 요청드립니다
아래는 트레이딩 뷰에서 Mansfield Relative Strength지표입니다.
변환 부탁드립니다
//@version=3
// Use this indicator to compare how security is performing in compare with prefered index (SPX by default).
// > 0 outperforming
// < 0 underperforming
// Works best for weekly, but can be applied to monthly and daily charts. It will be rather useless to use it in smaller timeframes
// Apply it to SPX, industry index, sector index or other security in similar sector
// UPDAT E 1: Added sector and industry as optional params. Leave them same as index if you don't want to use them
study("Mansfield Relative Strength indicator")
index = input(title="Index", type=symbol, defval="SP:SPX")
sector = input(title="Sector (optional)", type=symbol, defval="SP:SPX")
industry = input(title="Industry (optional)", type=symbol, defval="SP:SPX")
ma_type = input(title="Which moving average to use?", defval="SMA", options=["SMA", "WMA", "EMA"])
len_daily = input(title="MA length for Daily", defval=200)
len_weekly = input(title="MA length for Weekly", defval=52)
len_monthly = input(title="MA length for Monthly", defval=10)
len_other = input(title="MA length for all other periods", defval=52)
val = close
len = period == "W" ? len_weekly : (period == "D" ? len_daily : (period == "M" ? len_monthly : len_other))
ma_func(x, length) =>
ma_type == "WMA" ? wma(x, length) : (ma_type == "SMA" ? sma(x, length) : ema(x, length))
calc_mrs_func(x, ind, length) =>
((x / security(ind, period, x)) / ma_func((x / security(ind, period, x)), length) - 1) * 10
mrs_index = calc_mrs_func(val, index, len)
mrs_sector = calc_mrs_func(val, sector, len)
mrs_industry = calc_mrs_func(val, industry, len)
c = sign(mrs_index) + sign(mrs_sector) + sign(mrs_industry)
bgcolor(c == 3 ? color(green, 80) : c == 2 ? color(green, 75) : c == 1 ? color(green, 70) : c == -1 ? color(red, 70) : c == -2 ? color(red, 75) : c == -3 ? color(red, 80) : gray)
plot(mrs_index, linewidth=3, title="MRS index")
plot(mrs_sector != mrs_index ? mrs_sector : na, linewidth=2, title="MRS sector")
plot(mrs_industry != mrs_index ? mrs_industry : na, linewidth=1, title="MRS industry")
hline(price=0, linestyle=dashed, title="Zero baseline")
2023-02-02
905
글번호 165930
지표
답변완료
수식요청합니다.
지그재그차트에서 상승변곡점(상승후 하락시 꼭지점)을 돌파하는 종목검색식 요청합니다.
(첨부자료)
Input:전환비율(5);
Var:j(0),jj(0),HH(0),LL(0),hiBar(0),loBar(0),최종꼭지점(""),처리구분(""),TL1(0),Text1(0),ADXV1(0);
Array:고[10,4](0),저[10,4](0);
HH=H;
LL=L;
If Index==0 Then
{
고[1,1]=HH;
고[1,2]=0;
고[1,3]=sDate;
고[1,4]=sTime;
저[1,1]=LL;
저[1,2]=0;
저[1,3]=sDate;
저[1,4]=sTime;
}
If Index>0 Then
{
hiBar=hiBar+1;
loBar=loBar+1;
}
If HH[hiBar]<HH Then hiBar=0;
If LL[loBar]>LL Then loBar=0;
Condition1=저[1,1]*(1+(전환비율/100))<HH and hiBar==0;
Condition2=고[1,1]*(1-(전환비율/100))>LL and loBar==0;
처리구분="";
If Condition1 and Condition2 Then//고점과저점조건동시만족
{
If 최종꼭지점=="저점" Then
{
If 저[1,1]>LL Then 처리구분="저점처리";
Else 처리구분="고점처리";
}
Else If 최종꼭지점=="고점" Then
{
If 고[1,1]<HH Then 처리구분="고점처리";
Else 처리구분="저점처리";
}
}
Else If Condition1 Then 처리구분="고점처리";
Else If Condition2 Then 처리구분="저점처리";
If 처리구분=="고점처리" Then
{
If 최종꼭지점=="저점" Then
{
For j=10 DownTo 2
{
For jj=1 To 4
{
고[j,jj]=고[j-1,jj];
}
}
고[1,1]=HH[hiBar];
고[1,2]=Index-hiBar;
고[1,3]=sDate[hiBar];
고[1,4]=sTime[hiBar];
hiBar=-1;
loBar=-1;
TL1=TL_New(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
TL_SetSize(TL1,1);
TL_SetColor(TL1,RED);
}
Else If 고[1,1]<HH[hiBar] Then//1번고점보다높은고가출현
{
고[1,1]=HH[hiBar];
고[1,2]=Index-hiBar;
고[1,3]=sDate[hiBar];
고[1,4]=sTime[hiBar];
hiBar=-1;
loBar=-1;
TL_SetEnd(TL1,고[1,3],고[1,4],고[1,1]);
}
최종꼭지점="고점";
}
If 처리구분=="저점처리" Then
{
If 최종꼭지점=="고점" Then
{
For j=10 DownTo 2
{
For jj=1 To 4
{
저[j,jj]=저[j-1,jj];
}
}
저[1,1]=LL[loBar];
저[1,2]=Index-loBar;
저[1,3]=sDate[loBar];
저[1,4]=sTime[loBar];
hiBar=-1;
loBar=-1;
TL1=TL_New(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
TL_SetSize(TL1,1);
TL_SetColor(TL1,BLUE);
}
Else If 저[1,1]>LL[loBar] Then
{
저[1,1]=LL[loBar];
저[1,2]=Index-loBar;
저[1,3]=sDate[loBar];
저[1,4]=sTime[loBar];
hiBar=-1;
loBar=-1;
TL_SetEnd(TL1,저[1,3],저[1,4],저[1,1]);
}
최종꼭지점="저점";
}
2023-02-01
1186
글번호 165929
종목검색
답변완료
추세선 고저가라인
input : Period(35),선두께(2);
Var:상승색(Red), 하락색(Blue);
Var:j(0),T(0);
Var: date11(0),date12(0),time11(0),time12(0),TL1(0),TL(0),tl9(0),
date21(0),date22(0),time21(0),time22(0),
date31(0),date32(0),time31(0),time32(0),tx(0),tx1(0),tl4(0);
Array:HiVal[20](0),LoVal[20](0),HiBar[20](0),LoBar[20](0);
Array:r[7](0),fr[7](0),TL2[7](0),TL3[7](0),TX2[7](0),TX3[7](0);
Plot1(0);
For j = 0 To 19
{
HiBar[j] = HiBar[j] + 1;
LoBar[j] = LoBar[j] + 1;
}
if crossup(c,highest(H,Period)[1]) Then
T = 1;
if CrossDown(c,Lowest(L,Period)[1]) Then
T = -1;
If T == -1 Then
{
If T[1] != -1 Then
{
For j = 18 DownTo 0
{
LoVal[j+1] = LoVal[j];
LoBar[j+1] = LoBar[j];
}
LoVal[0] = L;
LoBar[0] = 0;
date11 = date[HiBar[0]];
time11 = stime[HiBar[0]];
Value11 = HiVal[0];
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
TL_Delete(tl);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
TL1 = TL_New(date11,time11,Value11,date12,time12,Value12);
TL_SetColor(TL1,하락색);
date21 = date[HiBar[0]];
time21 = stime[HiBar[0]];
date22 = date[0];
time22 = stime[0];
for j = 0 to 6
{
fr[j] = LoVal[1] + ((HiVal[0] - LoVal[1]) * r[j]);
}
}
If LoVal[0] > L Then
{
LoVal[0] = L;
LoBar[0] = 0;
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
TL_SetEnd(TL1, date12,time12,Value12);
date22 = date[0];
time22 = stime[0];
TL_Delete(tl);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
}
}
If T == 1 Then
{
If T[1] != 1 Then
{
For j = 18 DownTo 0
{
HiVal[j+1] = HiVal[j];
HiBar[j+1] = HiBar[j];
}
HiVal[0] = H;
HiBar[0] = 0;
date11 = date[LoBar[0]];
time11 = stime[LoBar[0]];
Value11 = LoVal[0];
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
TL_Delete(tl);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
TL1 = TL_New(date11,time11,Value11,date12,time12,Value12);
TL_SetColor(TL1,상승색);
date31 = date[LoBar[0]];
time31 = stime[LoBar[0]];
date32 = date[0];
time32 = stime[0];
for j = 0 to 5
{
fr[j] = LoVal[0] + ((HiVal[1] - LoVal[0]) * r[j]);
}
}
If HiVal[0] < H Then
{
HiVal[0] = H;
HiBar[0] = 0;
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
TL_SetEnd(TL1, date12,time12,Value12);
date32 = date[0];
time32 = stime[0];
TL_Delete(tl);
TL = TL_New(sdate,stime,Value12,NextBarSdate,NextBarStime,NextBarOpen);
}
}
TL_SetSize(TL1,선두께);
당일 추세선의 고저가 갱신될 때마다 새로운 고저 수평라인 부탁드립니다.
2023-02-01
1180
글번호 165927
지표