답변완료
점검 부탁드립니다.
수식 감사드립니다.
아래 수식은,
이동평균선(300일선)을 돌파하고 전일종가를 돌파하면 매수,
이동평균선(300일선)을 이탈하고 전일종가를 이탈하면 매도
하는 두가지 조건 만족식인데요, 진입/청산 모두 조건만족즉시가 하니고 봉완성후로 부탁합니다.
그리고 100% 이익일때 50%청산하고 나머지는 홀딩하는 수식인데요,
input : profit(100);
var1 = ma(C,300);
Condition1 = C > var1 and C > DayClose(1);
Condition2 = C < var1 and C < DayClose(1);
if Condition1 == true and Condition1[1] == false Then
buy("b");
if MarketPosition == 1 then
{
ExitLong("bp",atlimit,EntryPrice*(1+profit/100),"",Floor(MaxContracts*0.5),1);
if Condition2 == true and Condition2[1] == false Then
ExitLong("bx");
}
위 수식이 현물용인데, 선물(코인)에서 사용할 수 있도록 매수진입/매수청산, 매도진입/매도청산으로 변경 부탁드리고요,
한가지 더,
매수 또는 매도 진입 후, 전일종가를 이탈하면 손절할 수 있도록 조정해 주시면 감사하겠습니다!
2020-03-16
418
글번호 136890
시스템
답변완료
질문 올립니다.
안녕하세요. 늘 감사드립니다.
올리는 질문마다 항상 상세하고 친절하게 답을 주셔서, 그 것을 보며 공부하면서 아주 많이 배우게 되어 대단히 감사합니다.
지금,
둘 내지 세 개의 기준(조건)을 순차적으로(즉, 동시가 아니라 차례대로...) 충족시키고 나면 즉시(AtLimit, AtStop 활용) 주문이 나가서 체결가능하게 하는 매매식을 만드는 방법에 대해 공부하고 있습니다.
이런 예제 소스를 보여 주시면, 보고 열심히 공부하고자 합니다.
잘 부탁드립니다.
예로서,
A. 이평선들 Max Min 돌파이탈 지지저항 전략
변수들:
5개의 이평선들(기간값 각각 input: ii(50), jj(100), kk(150), ll(200), mm(250); 외부변수)의
최대값(var: Max(0))과 최소값(var: Min(0)),
그 것의 중심선 (var: Center(0); Center = (Max+Min)/2); )
Max와 Min의 차이 (var: Dif(0); Dif = Max-Min;)
// 매수1 ((돌파 매수)):
(제1조건:) (C가 Min 아래에 있다가) C가 Min을 뚫고 올라 간 후
(제2조건:) C가 Center를 nn(7)(외부변수)틱보다 더 높게 올라 가면
[ = 즉, C가 Center+nn*PriceScale을 CrossUp 또는 C > Center+nn*PriceScale ],
then 즉시(AtStop?) 매수
[ = Buy("B1", AtStop...); ].
(제3조건) 제1조건, 제2조건 충족 후, C가 Max를 pp(5)(외부변수)보다 더 높게 올라 가면,
[ = 즉, C가 Max+pp*PriceScale을 CrossUp 또는 C > Max+pp*PriceScale],
then 즉시((AtStop?) 매수
[ = Buy("B2", AtStop...); ] // 즉 피라미딩 가능.
// 매수2 ((지지 매수)):
(제1조건): C가 Max의 uu(7)((외부변수)) 틱 위에 있었다가
(제2조건): C가 Max의 아래 위 각 vv(2)((외부변수))틱 범위 속에 들어 갔다가 ((즉, Max에 접근했다가))
(제3조건): C가 Max의 ww(8)((외부변수)) 틱 위로 올라 가는 순간 즉시 매수
[ = Buy("B3", AtStop...); ].
// 매수청산
C가 EMA(ee)(=ee(2)=기간값 2. 외부변수로)를 하향 이탈하는 즉시 ExitLong("EL1", AtStop?...);
// 매도1, 매도2, 매도청산은 매수의 경우와 정 반대로... ((외부변수는 그 대로 같이 사용))
B. 볼린저 밴드 급등 매매 전략
// 매수
(제1조건) C가 하단선을 아래에서 위로 돌파
(제2조건) C가 중간선(EMA(bb) (bb(12)는 볼밴 중심선인 EMA의 기간값 외부변수)을 cc(3)(=외부변수)틱 돌파 ((즉 중간선+cc틱을 상향돌파)) 즉시 매수
[ = Buy("BB", AtStop...); ]
//매수청산1
(제1조건) C가 볼밴 상단선 위에 있다
(제2조건) C가 볼밴 상단선을 dd 틱 (input: dd(3); // 외부변수)만큼 하회하는 즉시 ExitLong("EL1", AtLimit?...);
//매수청산2
(제1조건) C가 볼밴 중심선과 상단선 사이에 있다.
(제2조건) C가 볼밴 중심선을 ff틱(ff(2)=외부변수) 하회하는 즉시 매수청산 = ExitLong("EL2", AtStop?)
//매도와 매도청산은 매수의 경우와 정반대로...
대단히 감사합니다!
2020-03-16
399
글번호 136889
시스템
답변완료
부탁드립니다
지표전환 부탁드립니다
OverBought = input(70, minval=10)
OverSold = input(30, maxval=70)
band1 = hline(70, title="Upper Line", linestyle=dashed, linewidth=1, color=red)
band0 = hline(30, title="Lower Line", linestyle=dashed, linewidth=1, color=green)
// Super Trend
sLines = input(true, "Show Super-Trend Lines")
Factor1=input(1,type =float, minval=1,maxval = 100)
Factor2=input(2,type =float, minval=1,maxval = 100)
Factor3=input(3,type =float, minval=1,maxval = 100)
Pd1=10 //input(10,minval=1,maxval = 100)
Pd2=10 //input(10,minval=1,maxval = 100)
Pd3=10 //input(10,minval=1,maxval = 100)
// ST1
Up1=hlc3-(Factor1*atr(Pd1))
Up2=hlc3-(Factor2*atr(Pd2))
Up3=hlc3-(Factor3*atr(Pd3))
Dn1=hlc3+(Factor1*atr(Pd1))
Dn2=hlc3+(Factor2*atr(Pd2))
Dn3=hlc3+(Factor3*atr(Pd3))
// ST1.2
TrendUp1=na
TrendUp2=na
TrendUp3=na
TrendUp1:=close[1]>TrendUp1[1]? max(Up1,TrendUp1[1]) : Up1
TrendUp2:=close[1]>TrendUp2[1]? max(Up2,TrendUp2[1]) : Up2
TrendUp3:=close[1]>TrendUp3[1]? max(Up3,TrendUp3[1]) : Up3
TrendDown1=na
TrendDown2=na
TrendDown3=na
TrendDown1:=close[1]<TrendDown1[1]? min(Dn1,TrendDown1[1]) : Dn1
TrendDown2:=close[1]<TrendDown2[1]? min(Dn2,TrendDown2[1]) : Dn2
TrendDown3:=close[1]<TrendDown3[1]? min(Dn3,TrendDown3[1]) : Dn3
Trend1 = na
Tsl1 = na
Trend2 = na
Tsl2 = na
Trend3 = na
Tsl3 = na
Trend1 := close[1] > TrendDown1[1] ? 1: close[1] < TrendUp1[1]? -1: nz(Trend1[1],1)
Tsl1 := Trend1==1 ? TrendUp1: TrendDown1
Trend2 := close[1] > TrendDown2[1] ? 1: close[1] < TrendUp2[1]? -1: nz(Trend2[1],1)
Tsl2 := Trend2==1 ? TrendUp2: TrendDown2
Trend3 := close[1] > TrendDown3[1] ? 1: close[1] < TrendUp3[1]? -1: nz(Trend3[1],1)
Tsl3 := Trend3==1 ? TrendUp3: TrendDown3
len=input(14)
x=rsi(Tsl2,len)
// Plotting
linecolor = Tsl1 < Tsl2 and Tsl2 < Tsl3 ? red : Tsl1 > Tsl2 and Tsl2 > Tsl3 ? lime : orange
plot(x , color = linecolor , style = line , linewidth = 3 ,title = "SuperTrend")
tgreen=crossover(close, Tsl2)
tred=crossunder(close, Tsl2)
plotchar(tgreen, title="buy", char='b', location=location.bottom, color=black, transp=0, offset=0,size=size.tiny)
plotchar(tred, title="sell", char='s', location=location.top, color=black, transp=0, offset=0,size=size.tiny)
2020-03-16
389
글번호 136888
지표
답변완료
지표수식 전환부탁드립니다.
아래 지표를 예스 지표로 전환부탁드립니다.
//The volume price trend ( VPT ) indicator helps determine a security’s price direction and strength of price change. The indicator consists of a cumulative volume line that adds or subtracts a multiple of the percentage change in a share price’s trend and current volume , depending upon the security’s upward or downward movements.
//https://www.tradingview.com/script/i8FO3CyP-VPT-v4/
source = close
hilow = ((high - low)*100)
openclose = ((close - open)*100)
vol = (volume / hilow)
spreadvol = (openclose * vol)
VPT = spreadvol + cum(spreadvol)
window_len = 28
v_len = 14
price_spread = stdev(high-low, window_len)
v = spreadvol + cum(spreadvol)
smooth = sma(v, v_len)
v_spread = stdev(v - smooth, window_len)
shadow = (v - smooth) / v_spread * price_spread
out = shadow > 0 ? high + shadow : low + shadow
//plot(out, style=line,linewidth=3, color=color)
len=input(10)
vpt=ema(out,len)
//lineColor = vpt > vpt[1] ? color.green : color.red
//plot(vpt, linewidth=3, color=lineColor)
//x=crossover(vpt , vpt[1]) and vpt > vpt[1]
//z=crossunder(vpt , vpt[1]) and vpt <vpt[1]
//plotshape(crossover(vpt , vpt[1]) and vpt > vpt[1], "up arrow", shape.triangleup, location.belowbar, color.green,size=size.tiny)
//plotshape(crossunder(vpt , vpt[1]) and vpt <vpt[1] , "down arrow", shape.triangledown, location.abovebar, color.red,size=size.tiny)
//
// INPUTS //
st_mult = input(1, title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)
st_period = input(100, title = 'SuperTrend Period', minval = 1)
// CALCULATIONS //
up_lev = vpt - (st_mult * atr(st_period))
dn_lev = vpt + (st_mult * atr(st_period))
up_trend = 0.0
up_trend := close[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev
down_trend = 0.0
down_trend := close[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev
// Calculate trend var
trend = 0
trend := close > down_trend[1] ? 1: close < up_trend[1] ? -1 : nz(trend[1], 1)
// Calculate SuperTrend Line
st_line = trend ==1 ? up_trend : down_trend
// Plotting
plot(st_line[1], color = trend == 1 ? color.green : color.red , style = plot.style_cross, linewidth = 2, title = "SuperTrend")
buy=crossover( close, st_line)
sell=crossunder(close, st_line)
//plotshape(crossover( close, st_line), location = location.belowbar, color = color.green,size=size.tiny)
//plotshape(crossunder(close, st_line), location = location.abovebar, color = color.red,size=size.tiny)
plotshape(buy,title="Buy", color=color.blue, style=shape.arrowup,location=location.belowbar, text="Buy")
plotshape(sell,title="Sell", color=color.black, style=shape.arrowdown,text="Sell")
/////// Alerts /////
alertcondition(buy,title="buy")
alertcondition(sell,title="sell")
2020-03-16
508
글번호 136887
지표
답변완료
지표수식 전환부탁
다음 수식을 예스지표로 전환부탁드려요.
ATRlength = input(200, minval=1)
ATRMult = input(2.272, minval=1)
ATR = rma(tr(true), ATRlength)
len = input(26, minval=1, title="EMA Length")
src = input(close, title="Source")
out = ema(src, len)
plot(out, title="EMA", color=orange,transp=85)
emaup = out+(ATR*ATRMult)
emadw = out-(ATR*ATRMult)
plot(emaup, title="EMAUP", color=red)
plot(emadw, title="EMADW", color=green)
conversionPeriods = input(5, minval=1),
basePeriods = input(26, minval=1)
laggingSpan2Periods = input(52, minval=1),
displacement = input(26, minval=1)
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
kjuncol = conversionLine > baseLine ? blue : conversionLine < baseLine ? red : orange
plot(conversionLine, color=red, title="Conversion Line")
plot(baseLine, color=kjuncol,linewidth=2,transp=5, title="Base Line")
p1 = plot(leadLine1, offset = displacement, color=green,transp=85,
title="Lead 1")
p2 = plot(leadLine2, offset = displacement, color=red,transp=85,
title="Lead 2")
fill(p1, p2,silver)
2020-03-16
389
글번호 136886
지표
답변완료
부탁 드립니다.
도움에 감사 드립니다.
타주기(분용)으로 부탁 드립니다.
미리 감사 드립니다.
input:p(20),sig(3);;
var1=iff(c>o,c,0);
var2=iff(c>o,1,0);
var3=AccumN(var1,p);
var4=accumn(var2,p);
var5=iff(var1==0 or var2==0 ,c[p-1],var1/var2);
var11=iff(c<o,c,0);
var12=iff(c<o,1,0);
var13=AccumN(var11,p);
var14=accumn(var12,p);
var15=iff(var11==0 or var12==0 ,c[p-1],var11/var12);
var51=(var5+var15)/2;
var61=c-var33;
var71=ma(var61,sig);
2020-03-16
328
글번호 136885
지표