답변완료
문의드립니다.
안녕하세요
예스랭귀지로 변환 부탁드려도 될까요?
감사드립니다
study("Sell / Buy Rates", overlay = false, precision = 0)
prd = input(title="Period", defval = 34, minval = 1)
tw = high - max(open, close)
bw = min(open, close) - low
body = abs(close - open)
_rate(cond) => 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body)
volup = volume * _rate(open <= close)
voldown = volume * _rate(open >= close)
rate = linreg(volup - voldown, prd, 0)
col = rate > 0 ? (falling(rate, 5) ? green : lime) : rate < 0 ? rising(rate, 5) ? maroon : red : na
plot(rate, color = col, style = columns)
2021-11-16
630
글번호 153633
지표
답변완료
문의드립니다
안녕하세요
항상 도움주심 감사드리고 있습니다.
아래의 수식을 예스랭귀지로 변환 가능할지 문의드립니다.
감사합니다. 좋은 하루되세요!
Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
2021-11-16
613
글번호 153632
지표
답변완료
문의 드립니다.
항상 감사드립니다.
주신 수식에 조언 주신대로 시간 조정하고 거래횟수를 추가해서 데모를 해보았습니다.
거래횟수 제한 수식을 잘못 넣었는지 시간내내 계속 거래가 되었습니다.
수정 부탁드립니다.
아래 내용 조금 헷갈려서요.
아래 수식 주석 부탁드립니다.
그리고 BX. CX 부분을 신호나온 이전캔들 N개의 최고가, 최저가 돌파시 하는 수식도 부탁드립니다.
감사합니다.
input : n1(5);
input : StartTime(231000),EndTime(053000);
input : 익절틱수(80),손절틱수(0), 거래횟수(N);
var : Tcond(false), T(0), entry(0);
Array : H1[50](0),L1[50](0);
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;
{
T = 0;
Tcond = true;
entry = 0;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if Tcond == true and entry < 거래횟수 Then
{
if MarketPosition <= 0 and NextBarOpen <= Highest(H,n1) Then
Buy("b1",AtStop,Highest(H,n1)+PriceScale*1);
if MarketPosition >= 0 and NextBarOpen >= Lowest(L,N1) Then
Sell("s1",AtStop,Lowest(L,N1)-PriceScale*1);
if MarketPosition == 1 Then
ExitLong("bx",AtStop,L[BarsSinceEntry]-PriceScale*1);
if MarketPosition == -1 Then
ExitShort("sx",AtStop,H[BarsSinceEntry]+PriceScale*1);
}
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
2021-11-15
580
글번호 153624
시스템
답변완료
다시 문의 드립니다.
친절한 도움에 감사드립니다.
수식을 다시 데모해보았는데요...
진입과 청산에 차이가 있는 부분이 있어 남깁니다.
진입은 1번 캔들 종가에 매도가 들어가는 것이 맞는데.. 다음 캔들 종가에 들어갔습니다.
그리고 청산은 이해가 가지 않게 정리되었네요..
두번째 이미지 사진에서도 거래횟수로 1회로 해서 데모해보았는데요.
1번과 2번 두 번 진입이 되었습니다.
그리고 2번 진입한 것은 중간에 손절되지 않고 거래 종료시간에 청산(3번)했는데
이것도 맞지 않습니다.
이미지 남겨드립니다.
확인 부탁드립니다.
input : n1(5);
input : StartTime(233000),EndTime(013000);
input : 익절틱수(80),손절틱수(0),거래횟수(3);
var : Tcond(false), T(0), entry(0);
Array : H1[50](0),L1[50](0);
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
{
T = 0;
Tcond = true;
entry = 0;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if Tcond == true and entry < 거래횟수 Then
{
if H > Highest(H,n1)[1] and C > O Then
Buy("b");
if L < Lowest(L,N1)[1] and C < O Then
Sell("s");
if MarketPosition == 1 Then
ExitLong("bx",AtStop,L[BarsSinceEntry]-PriceScale*1);
if MarketPosition == -1 Then
ExitShort("sx",AtStop,H[BarsSinceEntry]+PriceScale*1);
}
SetStopProfittarget(PriceScale*익절틱수,PointStop);
SetStopLoss(PriceScale*손절틱수,PointStop);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
2021-11-15
755
글번호 153623
시스템
답변완료
수식검토 부탁드립니다
input : 카운팅시작일자(20211109), 카운팅시작시간(080000),Period(56);
var : Tcond(false);
var : sum(0);
var : TL(0), TL1(0);
if sdate >= 카운팅시작일자 and stime >= 카운팅시작시간 Then
Tcond = true;
if Tcond == true Then
{
if (sdate != sdate[1] and stime >= 카운팅시작시간) or
(sdate == sdate[1] and stime >= 카운팅시작시간 and stime[1] < 카운팅시작시간) Then
Variables: BullP(0), BearP(0);
if Bdate != Bdate[1] Then
sum = 0;
if C > O Then
sum = (sum+v*0.1);
if C < O Then
sum = (sum-v*0.1);
BullP = (HIGH - ema(h,Period));
BearP = (LOW - ema(l,Period));
if BullP>0 then
{
var1 = BullP;
}
Else
{
var2 = BearP;
if bullp > 80 Then
{
TL = TL_New(sDate,sTime,O,NextBarSdate,NextBarStime,O);
TL_SetExtRight(TL,True);
}
if bearp < -80 Then
{
TL1 = TL_New(sDate,sTime,O,NextBarSdate,NextBarStime,O);
TL_SetExtRight(TL1,True);
}}}
신속한 답변주셔서 대단히 감사합니다.상기수식으로 실행한 결과 캡쳐1에서 80 이상 일때
수평선 라인이 표현되어야 하는데 80 미만에서 라인이 형성됩니다
마찬가지로 캡쳐2에서 -80 이하일때 수평선이 형성되어야하는데 -80 이상일때 수평선이 형성되어 수식수정 부탁 드립니다..
2021-11-16
532
글번호 153621
지표