답변완료
문의드립니다
Input:length(5);
Var:j(0),lastHiVal(0),lastLoVal(0),sBar(0),eBar(0),TL1(0),TL2(0),TL3(0),Text1(0),처리구분(""),
TL_Val1(0),TL_Val2(0);
Var:TL11(0),TL12(0),TL13(0),TL14(0),TL15(0),TL16(0),TL17(0),TL18(0),TL19(0),TL20(0);
Var:TL21(0),TL22(0),TL23(0),TL24(0),TL25(0),TL26(0),TL27(0),TL28(0),TL29(0),TL30(0),mav(0),T(0);
Array:고점[10,2](0),저점[10,2](0);
처리구분 = "";
If Highest(H,length) == H and lastHiVal <> H and Lowest(L,length) == L and lastLoVal <> L Then
{ If 저점[1,1] > L Then 처리구분 = "저점처리";
If 고점[1,1] < H Then 처리구분 = "고점처리";
}
Else If Highest(H,length) == H and lastHiVal <> H Then 처리구분 = "고점처리";
Else If Lowest(L,length) == L and lastLoVal <> L Then 처리구분 = "저점처리";
If 처리구분 == "고점처리" Then
{
lastHiVal = H;
If 고점[1,2] < 저점[1,2] Then
{
For j = 10 DownTo 2
{
고점[j,1] = 고점[j-1,1];
고점[j,2] = 고점[j-1,2];
}
}
If 고점[1,2] < 저점[1,2] or 고점[1,1] < H Then
{
고점[1,1] = H;
고점[1,2] = Index;
sBar = Index - 저점[1,2];
eBar = 0;
TL_Delete(TL1);
TL_Delete(TL2);
If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then
{
Text_Delete(Text1);
If 고점[3,1][1] < 고점[2,1][1] and 고점[2,1][1] > 고점[1,1][1]and 저점[2,1][1] < 저점[1,1][1] Then
TL_Delete(TL2);
}
TL1 = TL_New(sDate[sBar],sTime[sBar],저점[1,1],sDate[eBar],sTime[eBar],고점[1,1]);
TL2 = TL_New(sDate[eBar+1],sTime[eBar+1],고점[1,1]+ PriceScale*1,sDate[eBar],sTime[eBar],고점[1,1]+PriceScale*1);
TL_SetExtRight(Tl2,true);
TL_SetColor(Tl2,LGREEN);
TL_SetSize(TL2,2);
TL_SetColor(TL1,BLACK);
TL_SetSize(TL1,0);
If 고점[3,1] < 고점[2,1] and 고점[2,1] > 고점[1,1] and 저점[2,1] < 저점[1,1] Then
{
sBar = Index - 저점[2,2];
eBar = Index - 저점[1,2];
}
}
}
If 처리구분 == "저점처리" Then
{
lastLoVal = L;
If 저점[1,2] < 고점[1,2] Then
{
For j = 10 DownTo 2
{
저점[j,1] = 저점[j-1,1];
저점[j,2] = 저점[j-1,2];
}
}
If 저점[1,2] < 고점[1,2] or 저점[1,1] > L Then
{
저점[1,1] = L;
저점[1,2] = Index;
sBar = Index - 고점[1,2];
eBar = 0;
TL_Delete(TL1);
TL_Delete(TL2);
If TL_GetBeginDate(TL1) == sDate[sBar] and TL_GetBeginTime(TL1) == sTime[sBar] Then
{
Text_Delete(Text1);
If 저점[2,1][1] < 저점[1,1][1] and 저점[2,1][1] < 저점[3,1][1] and 고점[2,1][1] > 고점[1,1][1] Then
TL_Delete(TL3);
}
TL1 = TL_New(sDate[sBar],sTime[sBar],고점[1,1],sDate[eBar],sTime[eBar],저점[1,1]);
TL2 = TL_New(sDate[eBar+1],sTime[eBar+1],저점[1,1]- PriceScale*1,sDate[eBar],sTime[eBar],저점[1,1]-PriceScale*1);
TL_SetExtRight(Tl2,true);
TL_SetColor(Tl2,YELLOW);
TL_SetSize(TL2,2);
TL_SetColor(TL1,BLACK);
TL_SetSize(TL1,0);
If 저점[2,1] < 저점[1,1] and 저점[2,1] < 저점[3,1] and 고점[2,1] > 고점[1,1] Then
{
sBar = Index - 고점[2,2];
eBar = Index - 고점[1,2];
}
}
}
mav = ma(C,20);
위수식에서 틱수를 고점봉의50프로 저점봉의 50프로 로 하고십습니다 ,부탁드립니다.
2020-04-06
559
글번호 137600
지표
답변완료
문의드립니다.
//@version=4
study(BB MACD)
inp_Source = input(title = "Source", type = input.source, defval = close)
inp_Sensitivity = input(title = "Sensitivity", type = input.float, defval = 0.01)
inp_HiLo_Lookback = input(title = "Hi/Lo Lookback", type = input.integer, defval = 5)
inp_Slow_MA_Period = input(title = "Slow MA: Period", type = input.integer, defval = 26)
inp_Slow_MA_Method = input(title = "Slow MA: Type", defval = 'EMA', options = ['SMA', 'EMA', 'LWMA', 'RMA'])
inp_Fast_MA_Period = input(title = "Fast MA: Period", type = input.integer, defval = 12)
inp_Fast_MA_Method = input(title = "Fast MA: Type", defval = 'EMA', options = ['SMA', 'EMA', 'LWMA', 'RMA'])
inp_Signal_MA_Period = input(title = "Signal MA: Period", type = input.integer, defval = 9)
inp_Signal_MA_Method = input(title = "Signal MA: Type", defval = 'SMA', options = ['SMA', 'EMA', 'WMA', 'RMA'])
f_Get_MA(MA_Type, MA_Source, MA_Period) =>
MA = 0.0
MA := MA_Type == 'SMA' ? sma(MA_Source, MA_Period) : MA_Type == 'EMA' ? ema(MA_Source, MA_Period) : MA_Type == 'WMA' ? wma(MA_Source, MA_Period) : MA_Type == 'RMA' ? rma(MA_Source, MA_Period) : na
MA
f_Get_Std_Dev(MA_Type, MA_Source, MA_Period) =>
MA = 0.0
MA := f_Get_MA(MA_Type, MA_Source, MA_Period)
Price = 0.0
Price := sma(MA_Source, 1)
Summation = 0.0
for i = 0 to MA_Period - 1
Summation := Summation + (Price[i] - MA) * (Price[i] - MA)
Std_Dev = 0.0
Std_Dev := sqrt(Summation / MA_Period)
Std_Dev
f_Get_TR() =>
TR = max(high, close[1]) - min(low, close[1])
TR
f_Get_ATR(Period) =>
TR = f_Get_TR()
Summation = 0.0
for i = 1 to Period
Summation := Summation + TR[i]
ATR = 0.0
ATR := Summation / Period
ATR
MA_Fast = f_Get_MA(inp_Fast_MA_Method, inp_Source, inp_Fast_MA_Period)
HiLo_Range = abs(barssince(high == highest(high, inp_HiLo_Lookback)) - barssince(low == lowest(low, inp_HiLo_Lookback))) * syminfo.mintick * 100000
MA_Slow = f_Get_MA(inp_Slow_MA_Method, inp_Source, inp_Slow_MA_Period)
MA_Slow_Deviation = f_Get_Std_Dev(inp_Slow_MA_Method, inp_Source, inp_Slow_MA_Period)
MA_Slow_ATR = f_Get_ATR(inp_Slow_MA_Period)
Histogrm = MA_Slow_Deviation - MA_Slow_ATR
Main_Line = Histogrm
Signal_Line = f_Get_MA(inp_Signal_MA_Method, Main_Line, inp_Signal_MA_Period)
Histogrm_Color = color.green
if MA_Fast >= MA_Fast[1]
if HiLo_Range >= inp_Sensitivity
Histogrm_Color := color.green
else
Histogrm_Color := color.yellow
else
if HiLo_Range >= inp_Sensitivity
Histogrm_Color := color.red
else
Histogrm_Color := color.blue
plot(Histogrm, title = "BB MACD", color = Histogrm_Color, style = plot.style_histogram)
plot(Histogrm, title = "BB MACD", color = color.blue, style = plot.style_line)
--------------------------------------------------------------------
Slow MA, Fast MA Method에서 type은 EMA로,
Signal MA Method에서 type은 SMA로 부탁드립니다.
그리고
f_Get_MA(MA_Type, MA_Source, MA_Period) =>
MA = 0.0
MA := MA_Type == 'SMA' ? sma(MA_Source, MA_Period) : MA_Type == 'EMA' ? ema(MA_Source, MA_Period) : MA_Type == 'WMA' ? wma(MA_Source, MA_Period) : MA_Type == 'RMA' ? rma(MA_Source, MA_Period) : na
MA
에서 SMA와 EMA만 남겨주실수 있을지
수식에서 적용되는 MA가 SMA와 EMA만 적용될 수 있었으면 좋겠습니다.
항상 감사합니다.
2020-04-06
562
글번호 137586
지표