답변완료
변환부탁드립니다.
감사합니다.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BobRivera990
//@version=4
study(title = "Trend Type Indicator by BobRivera990", overlay = false)
//==========================================================================[Inputs]==========================================================================
useAtr = input(true, title = "Use ATR to detect Sideways Movements") // Use Average True Range (ATR) to detect Sideways Movements
atrLen = input(14, minval = 1, title = "ATR Length") // length of the Average True Range (ATR) used to detect Sideways Movements
atrMaType = input("SMA", options = ["SMA", "EMA"],
title = "ATR Moving Average Type") // Type of the moving average of the ATR used to detect Sideways Movements
atrMaLen = input(20, minval = 1, title = "ATR MA Length") // length of the moving average of the ATR used to detect Sideways Movements
useAdx = input(true, title = "Use ADX to detect Sideways Movements") // Use Average Directional Index (ADX) to detect Sideways Movements
adxLen = input(14, minval = 1, maxval = 50, title = "ADX Smoothing") // length of the Average Directional Index (ADX) used to detect Sideways Movements
diLen = input(14, minval = 1, title = "DI Length") // length of the Plus and Minus Directional Indicators (+DI & -DI) used to determine the direction of the trend
adxLim = input(25, minval = 1, title = "ADX Limit") // A level of ADX used as the boundary between Trend Market and Sideways Market
smooth = input(3, minval = 1, maxval = 5, title = "Smoothing Factor") // Factor used for smoothing the oscillator
lag = input(8, minval = 0, maxval = 15, title = "Lag") // lag used to match indicator and chart
//============================================================================================================================================================
//===================================================================[Initial Calculations]===================================================================
atr = atr(atrLen) // Calculate the Average True Range (ATR)
atrMa = atrMaType == "EMA" ? ema(atr, atrMaLen) : sma(atr, atrMaLen) // Calculate the moving average of the ATR
up = change(high) // Calculate parameter related to ADX, +DI and -DI
down = -change(low) // Calculate parameter related to ADX, +DI and -DI
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) // Calculate parameter related to ADX, +DI and -DI
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) // Calculate parameter related to ADX, +DI and -DI
trur = rma(tr, diLen) // Calculate parameter related to ADX, +DI and -DI
plus = fixnan(100 * rma(plusDM, diLen) / trur) // Calculate Plus Directional Indicator (+DI)
minus = fixnan(100 * rma(minusDM, diLen) / trur) // Calculate Minus Directional Indicator (-DI)
sum = plus + minus // Calculate parameter related to ADX
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxLen) // Calculate Average Directional Index (ADX)
//============================================================================================================================================================
//========================================================================[Conditions]========================================================================
cndNa = na(atr) or na(adx) or na(plus) or na(minus) or na(atrMaLen) // Conditions for lack of sufficient data for calculations
cndSidwayss1 = useAtr and atr <= atrMa // Sideways Movement condition (based on ATR)
cndSidwayss2 = useAdx and adx <= adxLim // Sideways Movement condition (based on ADX)
cndSidways = cndSidwayss1 or cndSidwayss2 // General Sideways Movement condition
cndUp = plus > minus // uptrend condition
cndDown = minus >= plus // downtrend condition
trendType = cndNa ? na : cndSidways ? 0 : cndUp ? 2 : -2 // Determine the type of trend
smoothType = na(trendType) ? na : round(sma(trendType, smooth) / 2) * 2 // Calculate the smoothed trend type oscillator
//============================================================================================================================================================
//=========================================================================[Drawing]==========================================================================
colGreen30 = color.new(color.green, 30) // Define the color used in the drawings
colGreen90 = color.new(color.green, 90) // Define the color used in the drawings
colGray = color.new(color.gray, 20) // Define the color used in the drawings
colWhite90 = color.new(color.white, 90) // Define the color used in the drawings
colRed30 = color.new(color.red, 30) // Define the color used in the drawings
colRed90 = color.new(color.red, 90) // Define the color used in the drawings
band3 = plot(+3, title = "Band_3", color=color.black) // Draw the upper limit of the uptrend area
band2 = plot(+1, title = "Band_2", color=color.black) // Draw the boundary between Sideways and Uptrend areas
band1 = plot(-1, title = "Band_1", color=color.black) // Draw the boundary between Sideways and Downtrend areas
band0 = plot(-3, title = "Band_0", color=color.black) // Draw the lower limit of the downtrend area
fill(band2, band3, title = "Uptrend area", color = colGreen90) // Highlight the Uptrend area
fill(band1, band2, title = "Sideways area", color = colWhite90) // Highlight the Sideways area
fill(band0, band1, title = "Downtrend area", color = colRed90) // Highlight the Downtrend area
var label lblUp = na
label.delete(lblUp)
lblUp := label.new(x = time, y = 2, text = "UP",
color = color.new(color.green, 100), textcolor = color.black,
style = label.style_label_left, xloc = xloc.bar_time,
yloc = yloc.price, size=size.normal, textalign = text.align_left) // Show Uptrend area label
var label lblSideways = na
label.delete(lblSideways)
lblSideways := label.new(x = time, y = 0, text = "SIDEWAYS",
color = color.new(color.green, 100), textcolor = color.black,
style = label.style_label_left, xloc = xloc.bar_time,
yloc = yloc.price, size = size.normal, textalign = text.align_left) // Show Sideways area label
var label lblDown = na
label.delete(lblDown)
lblDown := label.new(x = time, y = -2, text = "DOWN",
color = color.new(color.green, 100), textcolor = color.black,
style = label.style_label_left, xloc = xloc.bar_time,
yloc = yloc.price, size = size.normal, textalign = text.align_left) // Show Downtrend area label
var label lblCurrentType = na
label.delete(lblCurrentType)
lblCurrentType := label.new(x = time, y = smoothType,
color = color.new(color.blue, 30), style = label.style_label_right,
xloc = xloc.bar_time, yloc = yloc.price, size = size.small) // Show the latest status label
trendCol = smoothType == 2 ? colGreen30 : smoothType == 0 ? colGray : colRed30 // Determine the color of the oscillator in different conditions
plot(smoothType, title = "Trend Type Oscillator", color = trendCol,
linewidth = 3, offset = -lag, style = plot.style_stepline) // Draw the trend type oscillator
2021-09-27
1709
글번호 152500
지표
답변완료
시스템식 문의 드립니다.
여러번 질문드려 죄송합니다.ㅜ.ㅜ
아침에 송부해주신 식을 기준으로 다시 시뮬레이션을 돌려봤더니..
예를들어 아시아나 항공으로
1차 타점 : 28350
2차 타점 : 27800
3차 타점 : 27300
이렇게 타점을 걸어두고 매매를 진행되었을때
제가 생각하는 시뮬레이션은
28350에 매수해서 2프로 익절하고 , 그다음 27800원에 매수해서 2프로 익절하고,
27300원에서 매수해서 2프로 익절하는 식을 생각했었는데
아래의 그림을 보시면, 28350에 매수해서 2프로 익절후에 또 다시, 28350원에
진입하는걸 볼수 있습니다.
다시하면 조건을 적는다면..
요청조건은
-------------------------------------------------------------------
여기서 추가하고자 하는 조건은
전부다 동일한 조건으로 진행되는데, 1차매수 2프로 익절 했을 경우에만,
다음타점으로 매수진행되도록 조건을 추가하고 싶습니다.
예를들어 5000원에 매수해서 2프로 익절까지 했을경우, 다음 4500원이 매수타점으로 되어 진행되도록
조건을 추가하고자 합니다.
-------------------------------------------------------------------
입니다.
그럼 부탁드리겠습니다. 감사합니다.
요청식
-------------------------------------------------------------------
안녕하세요
예스스탁입니다.
기존식은 기존의 2차진입가격을 그대로 적용했습니다.
첫타점 다음가격으로 지정해 드립니다.
첫타점이 타점5이면 다음가격이 없어 진입할 수 없습니다.
input : 타점1(5000),타점2(4500),타점3(4000),타점4(3500),타점5(3000);
input : 투자금액1(1000000),투자금액2(2000000);
var : entry(0),HH(0),H1(0);
if Bdate != Bdate[1] Then
{
entry = 0;
#5개의 타점중 시가보다 작은것 중에 젤 큰값 계산
HH = 0;
H1 = 0;
if 타점1 < DayOpen*0.99 and 타점1 < DayClose(1) and 타점1 > HH Then
{
HH = 타점1;
H1 = 타점2;
}
if 타점2 < DayOpen*0.99 and 타점2 < DayClose(1) and 타점2 > HH Then
{
HH = 타점2;
H1 = 타점3;
}
if 타점3 < DayOpen*0.99 and 타점3 < DayClose(1) and 타점3 > HH Then
{
HH = 타점3;
H1 = 타점4;
}
if 타점4 < DayOpen*0.99 and 타점4 < DayClose(1) and 타점4 > HH Then
{
HH = 타점4;
H1 = 타점5;
}
if 타점5 < DayOpen*0.99 and 타점5 < DayClose(1) and 타점5 > HH Then
{
HH = 타점5;
}
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) and
(MarketPosition != MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
if MarketPosition == 0 and sTime < 133000 and entry == 0 Then
{
Buy("1차매수",AtLimit,HH,Floor(투자금액1/min(NextBarOpen,HH)));
}
if MarketPosition == 1 and entry == 1 Then
{
Buy("2차매수",AtLimit,HH*0.974,Floor(투자금액2/min(NextBarOpen,HH*0.974)));
}
if MarketPosition == 0 and sTime < 133000 and entry == 1 and IsexitName("1차매수 2프로익절",1) == true and H1 > 0 Then
{
Buy("2차매수A",AtLimit,H1,Floor(투자금액2/min(NextBarOpen,HH*0.974)));
}
if MarketPosition == 1 Then
{
if MaxEntries == 1 and IsEntryName("1차매수",0) == true Then
{
ExitLong("1차매수 1프로익절",AtLimit,avgEntryPrice*1.01,"",Floor(MaxContracts*0.4));
ExitLong("1차매수 2프로익절",AtLimit,avgEntryPrice*1.02);
}
if MaxEntries == 2 and IsEntryName("1차매수",0) == true Then
{
ExitLong("2차매수 0.3익절",AtLimit,avgEntryPrice*1.003,"",Floor(MaxContracts*0.5));
ExitLong("2차매수 0.5익절",AtLimit,avgEntryPrice*1.005);
}
if MaxEntries == 1 and IsEntryName("2차매수A",0) == true Then
{
ExitLong("2차매수A 0.3익절",AtLimit,avgEntryPrice*1.003,"",Floor(MaxContracts*0.5));
ExitLong("2차매수A 0.5익절",AtLimit,avgEntryPrice*1.005);
}
ExitLong("손절",AtStop,HH*0.96);
}
2021-09-28
1553
글번호 152499
시스템
답변완료
BB
항상감사합니다.
볼린져 해석도와주세요
1)MultiD의 의미알려주세요
2)MAv 의 의미 알려주세요
3)Bollinger Bands 따로 함수가 있나요(찾는법 알려주세요)
3-1)Bollinger Bands의 가준은 20개의 캔들종가의 평균값인가요?
4)ma(C, Period) - (D * std(C, Period));?
해석해주세요?
5)STD(value,length) 라인가격값,기간)인가요?
value=값
Length=시간의 길이
6)???Period와Length는 같은 의미인가요? 좀다른가요?
7)BollBandDown = ma(C, Period) - (D * std(C, Period));
???이동평균종가값에서 당일의 종가값 std을 뺀 가격?
----------------------------------------------------------
8)BollBandUp = ma(C, Period) + (D * std(C, Period));
???이동평균종가값에서 당일의 종가값 std을 더한 가격?
4.Bollinger Bands
Input : Period(20), MultiD(2);
var : MAv(0),BBup(0),BBdn(0);
MAv = ma(C,Period);
BBup = BollBandUp(Period,MultiD);
BBdn = BollBandDown(Period,MultiD);
Plot1(MAv, "이평");
Plot2(BBup, "상단밴드");
Plot3(BBdn, "하단밴드");
----------
볼린저 밴드
20개의 캔들이다
?MultiD(2) 멀티2개의 캔들
?MAv=이동평균선의 볼륨or거래량?
이동평균선의 종가20개의 평균값과 멀티2개의캔들 종가 평균값이다?
?BBup=상승돌파 20개의 종가평균값을 2개의 캔들종가의 값이 돌파하는 선?
?BBdn=하방추락 20개의 종가평균값을 2개의 캔들종가의 값이 추락하는 선?
Plot1(MAv, "이평");
MAv, "이평"---내부변수를 이평이라 한다
Plot1은 챠트에 가격과 라인을 표현한다.
-----------------------------------------------------------
Input : Period(Numeric), D(Numeric);
BollBandDown = ma(C, Period) - (D * std(C, Period));
---------------------------------------------------------------
???이동평균종가값에서 당일의 종가값 std을 뺀 가격?
Input : Period(Numeric), D(Numeric);
BollBandUp = ma(C, Period) + (D * std(C, Period));
???이동평균종가값에서 당일의 종가값 std을 더한 가격?
2021-09-27
1014
글번호 152497
지표