답변완료
부탁드립니다.
수식 변형 부탁 드립니다.
indicator('HIGH AND LOW Optimized Trend Tracker', 'HL OTT', overlay=true)
length = input.int(2, 'OTT Period', minval=1)
percent = input.float(0.6, 'OTT Optimization Coeff', step=0.1, minval=0)
hllength = input.int(10, 'Highest and Lowest Length', minval=1)
src = ta.highest(high, hllength)
srcl = ta.lowest(low, hllength)
highlighting = input(title='Highlighter On/Off ?', defval=true)
mav = input.string(title='Moving Average Type', defval='VAR', options=['SMA', 'EMA', 'WMA', 'DEMA', 'TMA', 'VAR', 'WWMA', 'ZLEMA', 'TSF', 'HULL'])
Var_Func(src, length) =>
getMA(src, length) =>
ma = 0.0
if mav == 'SMA'
ma := ta.sma(src, length)
ma
if mav == 'EMA'
ma := ta.ema(src, length)
ma
if mav == 'WMA'
ma := ta.wma(src, length)
ma
if mav == 'DEMA'
ma := DEMA
ma
if mav == 'TMA'
ma := ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)
ma
if mav == 'VAR'
ma := VAR
ma
if mav == 'WWMA'
ma := WWMA
ma
if mav == 'ZLEMA'
ma := ZLEMA
ma
if mav == 'TSF'
ma := TSF
ma
if mav == 'HULL'
ma := HMA
ma
ma
getMAl(srcl, length) =>
mal = 0.0
if mav == 'SMA'
mal := ta.sma(srcl, length)
mal
if mav == 'EMA'
mal := ta.ema(srcl, length)
mal
if mav == 'WMA'
mal := ta.wma(srcl, length)
mal
if mav == 'DEMA'
mal := DEMAl
mal
if mav == 'TMA'
mal := ta.sma(ta.sma(srcl, math.ceil(length / 2)), math.floor(length / 2) + 1)
mal
if mav == 'VAR'
mal := VARl
mal
if mav == 'WWMA'
mal := WWMAl
mal
if mav == 'ZLEMA'
mal := ZLEMAl
mal
if mav == 'TSF'
mal := TSFl
mal
if mav == 'HULL'
mal := HMAl
mal
mal
2023-07-04
1064
글번호 170300
지표
답변완료
문의드립니다
어제 질문드린 수식값(수정)에 복리 적용하려고 하니 아래의 b1, b2, b3 에서 에러가 뜹니다. 정확히는 b1, b2, b3 값에 복리적용이 되지 않습니다. 어떻게 변경해야할까요? 아래 수식 보시고 미흡한 점도 함께 보완 부탁드립니다.
input : 원금(0),시작일0),시작시간(0);
var : Tcond(False),수량(0);
if sDate == 시작일 and sTime >= 시작시간 Then
수량 = (원금+NetProfit)/NextBarOpen;
input : P1(0),P2(0),P3(0);
input : short1(0),long1(0),sig1(0);
input : shor(0),long(0),sig(0);
input : sho(0),lon(0),si(0);
if Tcond == true Then
var : mav1(0),mav2(0),mav3(0);
var : macdv1(0),macdv2(0),macdv3(0),macds1(0),macds2(0),macds3(0);
mav1 = ma(C,P1);
mav2 = ma(C,P2);
mav3 = ma(C,P3);
macdv1 = macd(short1,long1);
macdv2 = macd(shor,long);
macdv3 = macd(sho,lon);
macds1 = Ema(macdv1,sig1);
macds2 = Ema(macdv2,sig);
macds3 = Ema(macdv3,si);
if MarketPosition <= 0 and CrossUp(macdv1,0) Then
{
Buy("b",AtMarket,Def,수량);
}
If macdv1 > 0 and CrossUp(macdv1, macds1) Then
{
Buy("bx",AtMarket,Def,수량);
}
if MarketPosition == 0 and CountIf(macdv1<0,BarsSinceExit(1)) < 1 Then
{
if IsExitName("s1",1) == true Then
Buy("b1",AtLimit,EntryPrice(1)*0.05);
if IsExitName("s2",1) == true Then
Buy("b2",AtLimit,EntryPrice(1)*0.05);
if IsExitName("s3",1) == true Then
Buy("b3",AtLimit,ExitPrice(1)*0.05);
}
If macdv1 > 0 and macdv2 > 0 and CrossDown(macdv3, 0) Then
{
Buy("b5",AtMarket,Def,수량);
}
If macdv1 > 0 and macdv2 > 0 and CrossUp(macdv3,macds3) Then
{
Buy("b6",AtMarket,Def,수량);
}
If macdv1 > 0 and macdv2 < 0 Then
{
ExitLong("sx");
}
if MarketPosition == 1 Then
{
if mav3 > mav2 and mav2 > mav1 Then
{
ExitLong("s1",AtLimit,EntryPrice*0.15);
}
if mav3 > mav1 and mav1 > mav2 Then
{
ExitLong("s2",AtLimit,EntryPrice*0.20);
}
if mav1 > mav3 and mav3 > mav2 Then
{
ExitLong("s3",AtLimit,EntryPrice*0.30);
}
}
감사합니다.
2023-07-04
912
글번호 170298
시스템