답변완료
스토캐스틱에 대한 문의드립니다.
도움 많이 주셔서 벌써 3개째 지표를 등록했습니다.
4번째로 스토캐스틱에 대해 문의드리려고 합니다.
input : 모드("현재");
Input : period1(5), period2(3);
#모드 현재 또는 미래일때 표시
if 모드 == "현재" or 모드 == "미래" Then
{
Plot2((c-Lowest(l,period1))/(Highest(h,period1)-Lowest(l,period1))*100,"%k",rgb(244, 67, 54));
Plot3(ma((c-Lowest(l,period1))/(Highest(h,period1)-Lowest(l,period1))*100,period2),"%D",rgb(244, 67, 54));
}
이게 현재값입니다.
그런데 과거값을 만드려고 하다보니 이런 문제가 있습니다.
if 모드 == "과거" Then
{
if LastBarOnChart == 1 Then
Plot5((O-Lowest(l,period1))/(Highest(h,period1)-Lowest(l,period1))*100,"%k과거",rgb(244, 67, 54));
Else
Plot5((c-Lowest(l,period1))/(Highest(h,period1)-Lowest(l,period1))*100,"%k과거",rgb(244, 67, 54));
}
종가를 시가로 바꾸면 되는데, 문제는 저가와 고가가 변경되지 않아야 하기 때문에 이 경우 추가적인 정의가 필요합니다.
예를 들면 기간 중 전봉까지의 고가와 현재 시가 중 가장 높은 값을 고가로 하고, 기간 중 전봉까지의 가장 낮은 저가와 시가 중 가장 낮은 것을 저가로 합니다. 단 현재봉에서 움직인 것은 인정하지 않아야 하는데, 이 경우 수식으로 어떻게 표현해야 하는지 알려주시면 감사하겠습니다.
2023-08-19
857
글번호 171662
지표
답변완료
수식변환 부탁드립니다.
안녕하세요
항상 도움을 주셔서 감사드립니다.
파인스크립 수식을 예스 수식으로 부탁 드려봅니다.
종목검색식.지표식,시스템식 부탁합니다.
매번 부탁을 해서 송구 스럽습니다.
항상 가정에 건승과 건강이 함께 하시길 빕니다.
1.
// Inputs //
sl_type = input.string('%', options=['%', 'ATR', 'Absolute'])
sl_perc = input.float(500, title='% SL')
atr_length = input(500, title='ATR Length')
atr_mult = input.float(500, title='ATR Mult')
sl_absol = input.float(500, title='Absolute SL')
// BACKTESTING RANGE
// From Date Inputs
fromDay = input.int(defval=1, title='From Day', minval=1, maxval=31)
fromMonth = input.int(defval=1, title='From Month', minval=1, maxval=12)
fromYear = input.int(defval=2016, title='From Year', minval=1970)
// To Date Inputs
toDay = input.int(defval=1, title='To Day', minval=1, maxval=31)
toMonth = input.int(defval=1, title='To Month', minval=1, maxval=12)
toYear = input.int(defval=2100, title='To Year', minval=1970)
// Calculate start/end date and time condition
startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = time >= startDate and time <= finishDate
// CALCULATIONS //
// SL values
sl_val = sl_type == 'ATR' ? atr_mult * ta.atr(atr_length) : sl_type == 'Absolute' ? sl_absol : close * sl_perc / 100
// Init Variables
pos = 0
trailing_sl = 0.0
// Signals
long_signal = nz(pos[1]) != 1 and high > nz(trailing_sl[1])
short_signal = nz(pos[1]) != -1 and low < nz(trailing_sl[1])
// Calculate SL
trailing_sl := short_signal ? high + sl_val : long_signal ? low - sl_val : nz(pos[1]) == 1 ? math.max(low - sl_val, nz(trailing_sl[1])) : nz(pos[1]) == -1 ? math.min(high + sl_val, nz(trailing_sl[1])) : nz(trailing_sl[1])
// Position var
pos := long_signal ? 1 : short_signal ? -1 : nz(pos[1])
// PLOTINGS //
plot(trailing_sl, linewidth=2, color=pos == 1 ? color.green : color.red)
// STRATEGY //
if time_cond and pos != 1
strategy.entry('long', strategy.long, stop=trailing_sl)
if time_cond and pos != -1
strategy.entry('short', strategy.short, stop=trailing_sl)
----------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------
2.
atr_length = input(500)
start = input(500)
increment = input(500)
maximum = input(500)
entry_bars = input(500, title='Entry on Nth trend bar')
atr = ta.atr(atr_length)
atr := na(atr) ? ta.tr : atr
psar = 0.0 // PSAR
af = 0.0 // Acceleration Factor
trend_dir = 0 // Current direction of PSAR
ep = 0.0 // Extreme point
trend_bars = 0
sar_long_to_short = trend_dir[1] == 1 and close <= psar[1] // PSAR switches from long to short
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1] // PSAR switches from short to long
trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long
// Calculate trend direction
trend_dir := barstate.isfirst[1] and close[1] > open[1] ? 1 : barstate.isfirst[1] and close[1] <= open[1] ? -1 : sar_long_to_short ? -1 : sar_short_to_long ? 1 : nz(trend_dir[1])
trend_bars := sar_long_to_short ? -1 : sar_short_to_long ? 1 : trend_dir == 1 ? nz(trend_bars[1]) + 1 : trend_dir == -1 ? nz(trend_bars[1]) - 1 : nz(trend_bars[1])
// Calculate Acceleration Factor
af := trend_change ? start : trend_dir == 1 and high > ep[1] or trend_dir == -1 and low < ep[1] ? math.min(maximum, af[1] + increment) : af[1]
// Calculate extreme point
ep := trend_change and trend_dir == 1 ? high : trend_change and trend_dir == -1 ? low : trend_dir == 1 ? math.max(ep[1], high) : math.min(ep[1], low)
// Calculate PSAR
psar := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ? ep[1] : trend_dir == 1 ? psar[1] + af * atr : psar[1] - af * atr
plot(psar, style=plot.style_cross, color=trend_dir == 1 ? color.green : color.red, linewidth=2)
// Strategy
strategy.entry('Long', strategy.long, when=trend_bars == entry_bars)
strategy.entry('Short', strategy.short, when=trend_bars == -entry_bars)
2023-08-19
919
글번호 171661
지표
답변완료
부탁드립니다
1, 기본 콜, 보조1콜, 보조2콜, 보조3콜, 보조4콜과 보조5풋, 보조6풋, 보조7풋, 보조8풋, 보조9풋 간에 최고가로 서로 만난 봉이 발생하였을 경우, 기본차트 해당봉에 흰색으로 구현해 주세요, 또 최저가로 서로 만난 봉이 발생하였을 경우에는 노란색으로 구현해 주세요
2. 참조데이터의 개인선물순매수금액의 증감을 45분 간격으로 바탕화면에 표시하고 싶습니다.
전시간대보다 증가하였으면 빨강색으로, 전시간대보다 감소하였으면 파란색으로, 아니면 수직선으로 빨강색과 파란색으로 구현해 주세요
고맙습니다.
2023-08-19
648
글번호 171660
강조
답변완료
문의드립니다
Input : Period(20),dv(2);
Var : Ep1(0), wEma(0), DINDEX1(0), PrewEma(0);
var : cnt(0),Avgv(0),SumSqrt(0),Counter(0),Stdv(0),wBBup(0),wBBDn(0);
Array : CC[100](0);
Ep1 = 2/(Period+1);
if DayOfWeek(bdate) < DayOfWeek(bdate[1]) Then
{
DINDEX1 = DINDEX1 + 1;
PrewEma = wEma[1];
for cnt = 1 to 99
{
CC[cnt] = CC[cnt-1][1];
}
}
CC[0] = C;
if DINDEX1 <= 1 then
wEma = C;
else
wEma = C * EP1 + PrewEma * (1-EP1);
If CC[Period] > 0 Then
{
Avgv = wEma;
SumSqrt = 0;
For Counter = 0 To Period - 1
{
SumSqrt = SumSqrt + (CC[Counter] - Avgv) * (CC[Counter] - Avgv);
}
Stdv = SquareRoot(SumSqrt / Period);
wBBup = wEma + (Dv * Stdv);
wBBdn = wEma - (Dv * Stdv);
plot1(wBBup);
plot2(wEma);
plot3(wBBdn);
}
-------------------------
위식이 일봉에 주봉 볼린저밴드 적용한 식이 맞나요?
wema 는 지수이평으로 한건가요?
그냥 단순이평으로 적용하려면 어떻게 해야하나요?
2023-08-19
686
글번호 171656
지표
답변완료
수고하십니다.
사용자함수명 : Cha
반환값형 : 숫자형
var: yjp(0),forcast(0);
var : X1(0), X2(0), X3(0), X4(0), X5(0), X6(0), X7(0), X8(0), X9(0),X10(0);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
X1=0.009341;
X2=0.009773;
X3=0.009342;
X4=-0.00043;
X5=-0.00125;
X6=-0.00096;
X7=-0.00201;
X8=-0.00565;
X9=-0.00809;
X10=8.18E-06;
forcast=yjp+x1*Data2(c)+x2*Data3(c)+x3*Data4(c)+x4*Data5(c)+x5*Data6(c)+x6*Data7(c)+x7*Data8(c)+x8*Data9(c)+x9*Data10(c)+x10*Data15(c);
CHA=(C-forcast)
//문의 : 만약 Data2(c)가 기관선물매수금액이라면 어떻게 표현해야되죠..어떻게 불러오죠..
2023-08-18
1003
글번호 171648
사용자 함수