예스스탁
예스스탁 답변
2024-09-23 17:07:25
안녕하세요
예스스탁입니다.
1
시뮬레이션 차트는 변수 최적화 기능이 있어
모든 외부변수가 숫자형이어야 합니다.
input : adaptive(false);
숫자형이 아닌 변수를 숫자로 대체하게 변경해 드립니다.
input : adaptive(1);#true면 1, 아니면 0 지정
2
input : length(13), mult(5.5), map(141);
input : lengthB(16), multB(6.76), mapB(121);
input : useClose(1);//1:종가기준, 2:고/저가 기준
input : Bolllimit(0.2);
input : src(close);
input : smooth(1);
input : length1(25);
input : SetStop(169), gamso(83), minMoney(194), 변수(0), 목표수익값(255), 수익포인트(108) ;
input : StartTime(145000),EndTime(034210);
var : Tcond(False);
var : A(0), longStop(0), longStopPrev(0), shortStop(0), shortStopPrev(0), AB(0), longStopB(0), longStopPrevB(0), shortStopB(0), shortStopPrevB(0), BollUp(0), Ma20(0), BWI(0), BollDown(0), Ma60(0), srcS(0), value(0) ;
var : dir(1), dirB(1);
var : offset(0.85),sigma1(7),pchange(0),avpchange(0);
var : buySignal(False), buyExit(False), sellSignal(False), sellExit(False);
offset = 0.85;
sigma1 = 7;
pchange = (src-src[smooth]) / src * 100;
var : i(0),mm(0),s(0),norm(0),sum(0),weight(0);
var : r(0),rsiL(False),rsiS(False);
var : length11(0),src1(0),momm(0);
var : m1(0),m2(0),sm1(0),sm2(0),chandeMO(0),cL(False),cS(False);
mm = offset * (length1 - 1);
s = length1 / sigma1;
norm = 0.0;
sum = 0.0;
for i = 0 to length1 - 1
{
weight = exp(-1 * pow(i - mm, 2) / (2 * pow(s, 2)));
norm = norm + weight;
sum = sum + pchange[length1 - i - 1] * weight;
}
avpchange = sum / norm;
//RSI
r = rsi(14);
rsiL = r > r[1];
rsiS = r < r[1];
//Chande Momentum
length11 = 9;
src1 = close;
momm = src1-src1[1];
m1 = iff(momm >= 0.0 , momm , 0.0);
m2 = iff(momm >= 0.0 , 0 , -momm);
sm1 = AccumN(m1, length11);
sm2 = AccumN(m2, length11);
chandeMO = 100 * (sm1-sm2) / (sm1+sm2);
cL = chandeMO > chandeMO[1];
cS = chandeMO < chandeMO[1];
//GAMA credit to author: © LeafAlgo https://www.tradingview.com/v/th7NZUPM/
input : lengthG(14);
input : adaptive(1);#true면 1, 아니면 0 지정
input : volatilityPeriod(20);
input : vv(1);
var : gma(0),sumOfWeights(0),sigma(0),valueG(0),gmaColor(0),tx(0);
// Calculate Gaussian Moving Average
gma = 0.0;
sumOfWeights = 0.0;
sigma = iff(adaptive == 1 , std(close, volatilityPeriod) ,vv);
for i = 0 to lengthG - 1
{
weight = exp(-pow(((i - (lengthG - 1)) / (2 * sigma)), 2) / 2);
valueG = highest(avpchange, i + 1) + lowest(avpchange, i + 1);
gma = gma + (valueG * weight);
sumOfWeights = sumOfWeights + weight;
}
gma = (gma / sumOfWeights)/2;
gma = ema(gma, 7);
gmaColor = iff(avpchange >= gma , rgb(0, 161, 5) , rgb(215, 0, 0));
var : currentSignal(0),barColor(Nan);
currentSignal = iff(avpchange >= gma , 1 , -1);
if currentSignal == 1 Then
barColor = rgb(0, 186, 6);
BollUp = BollBandUp(20, 2);
BollDown = BollBandDown(20, 2);
Ma20 = Average(C, 20);
BWI = (BollUp - BollDown)/Ma20*100;
Ma60 = Average(C, map);
srcS = close;
a = mult * atr(length);
ab = multB * atr(lengthB);
if MarketPosition == 1 and
highest(h,BarsSinceEntry) >= EntryPrice+수익포인트 Then
ExitLong("L_EvenBreak",AtStop,EntryPrice);
if MarketPosition == -1 and
lowest(l,BarsSinceEntry) <= EntryPrice-수익포인트 Then
ExitShort("S_EvenBreak",AtStop,EntryPrice);
longStop = IFf(useClose == 1, highest(close, length) ,highest(H,length)) - a;
longStopPrev = iff(IsNan(longStop[1]) == true, longStop,longStop[1]);
longStop = iff(close[1] > longStopPrev ,max(longStop, longStopPrev) , longStop);
shortStop = IFf(useClose == 1, lowest(close, length) , Lowest(L,length)) + a;
shortStopPrev = iff(IsNan(shortStop[1]) == true, shortStop,shortStop[1]);
shortStop = iff(close[1] < shortStopPrev , min(shortStop, shortStopPrev) , shortStop);
dir = iff(close > shortStopPrev , 1 , IFF(close < longStopPrev , -1 , dir));
longStopB = IFf(useClose == 1, highest(close, lengthB) ,highest(H,lengthB)) - aB;
longStopPrevB = iff(IsNan(longStopB[1]) == true, longStopB,longStopB[1]);
longStopB = iff(close[1] > longStopPrevB ,max(longStopB, longStopPrevB) , longStopB);
shortStopB = IFf(useClose == 1, lowest(close, lengthB) , Lowest(L,lengthB)) + aB;
shortStopPrevB = iff(IsNan(shortStopB[1]) == true, shortStopB,shortStopB[1]);
shortStopB = iff(close[1] < shortStopPrevB , min(shortStopB, shortStopPrevB) , shortStopB);
dirB = iff(close > shortStopPrevB , 1 , IFF(close < longStopPrevB , -1 , dirB));
buySignal = avpchange > gma and BWI >= Bolllimit and C > O and C > Ma60 and dir == 1 and (CrossUp(avpchange,gma) and dir[1] == -1 or crossUp(C, Ma60));
buyExit = CrossDown(avpchange,gma);
sellSignal = avpchange < gma and BWI >= Bolllimit and C < O and C < Ma60 and dirB == -1 and (CrossDown(avpchange,gma) and dirB[1] == 1 or crossUp(C, Ma60));
sellExit = CrossUp(avpchange,gma);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if Bdate != Bdate[1] Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
Tcond = true;
if Tcond == true Then
{
if buySignal == true Then
Buy("Buy");
if buyExit == true Then
ExitLong("BExit");
if sellSignal == true Then
Sell("Sell");
if sellExit == true Then
ExitShort("SExit");
}
//SetStopInactivity(최소가격,기간,PointStop);
SetStopProfittarget(목표수익값,PointStop);
SetStopLoss(SetStop,PointStop);
SetStopTrailing(gamso,minMoney,PointStop,변수);
즐거운 하루되세요
> 하날랑 님이 쓴 글입니다.
> 제목 : 89178로 요청했던 것에 대한 추가부탁드립니다.
> 먼저 89178번에 대하여 빠른 답변에 감사를 드립니다.
89178번에서 알려준 원본을 시스템에 탑재 하였더니 첨부파일과 같이 논리값(참/거짓)이 와야된다는 메세지가 발생하여 다음과 같이 기사용중인 로직에 같이 포함하여 작성 하여 보았지만 동일한 메세지가 뜨고 제가 어디에 표현을 해야될 지 몰라 재차 요청하오니 다시 한번더 부탁을 드립니다.
input : length(13), mult(5.5), map(141);
input : lengthB(16), multB(6.76), mapB(121);
input : useClose(1);//1:종가기준, 2:고/저가 기준
input : Bolllimit(0.2);
input : src(close);
input : smooth(1);
input : length1(25);
input : SetStop(169), gamso(83), minMoney(194), 변수(0), 목표수익값(255), 수익포인트(108) ;
input : StartTime(145000),EndTime(034210);
var : Tcond(False);
var : A(0), longStop(0), longStopPrev(0), shortStop(0), shortStopPrev(0), AB(0), longStopB(0), longStopPrevB(0), shortStopB(0), shortStopPrevB(0), BollUp(0), Ma20(0), BWI(0), BollDown(0), Ma60(0), srcS(0), value(0) ;
var : dir(1), dirB(1);
var : offset(0.85),sigma1(7),pchange(0),avpchange(0);
var : buySignal(False), buyExit(False), sellSignal(False), sellExit(False);
offset = 0.85;
sigma1 = 7;
pchange = (src-src[smooth]) / src * 100;
var : i(0),mm(0),s(0),norm(0),sum(0),weight(0);
var : r(0),rsiL(False),rsiS(False);
var : length11(0),src1(0),momm(0);
var : m1(0),m2(0),sm1(0),sm2(0),chandeMO(0),cL(False),cS(False);
mm = offset * (length1 - 1);
s = length1 / sigma1;
norm = 0.0;
sum = 0.0;
for i = 0 to length1 - 1
{
weight = exp(-1 * pow(i - mm, 2) / (2 * pow(s, 2)));
norm = norm + weight;
sum = sum + pchange[length1 - i - 1] * weight;
}
avpchange = sum / norm;
//RSI
r = rsi(14);
rsiL = r > r[1];
rsiS = r < r[1];
//Chande Momentum
length11 = 9;
src1 = close;
momm = src1-src1[1];
m1 = iff(momm >= 0.0 , momm , 0.0);
m2 = iff(momm >= 0.0 , 0 , -momm);
sm1 = AccumN(m1, length11);
sm2 = AccumN(m2, length11);
chandeMO = 100 * (sm1-sm2) / (sm1+sm2);
cL = chandeMO > chandeMO[1];
cS = chandeMO < chandeMO[1];
//GAMA credit to author: © LeafAlgo https://www.tradingview.com/v/th7NZUPM/
input : lengthG(14);
input : adaptive(true);
input : volatilityPeriod(20);
input : vv(1);
var : gma(0),sumOfWeights(0),sigma(0),valueG(0),gmaColor(0),tx(0);
// Calculate Gaussian Moving Average
gma = 0.0;
sumOfWeights = 0.0;
sigma = iff(adaptive , std(close, volatilityPeriod) ,vv);
for i = 0 to lengthG - 1
{
weight = exp(-pow(((i - (lengthG - 1)) / (2 * sigma)), 2) / 2);
valueG = highest(avpchange, i + 1) + lowest(avpchange, i + 1);
gma = gma + (valueG * weight);
sumOfWeights = sumOfWeights + weight;
}
gma = (gma / sumOfWeights)/2;
gma = ema(gma, 7);
gmaColor = iff(avpchange >= gma , rgb(0, 161, 5) , rgb(215, 0, 0));
var : currentSignal(0),barColor(Nan);
currentSignal = iff(avpchange >= gma , 1 , -1);
if currentSignal == 1 Then
barColor = rgb(0, 186, 6);
BollUp = BollBandUp(20, 2);
BollDown = BollBandDown(20, 2);
Ma20 = Average(C, 20);
BWI = (BollUp - BollDown)/Ma20*100;
Ma60 = Average(C, map);
srcS = close;
a = mult * atr(length);
ab = multB * atr(lengthB);
if MarketPosition == 1 and
highest(h,BarsSinceEntry) >= EntryPrice+수익포인트 Then
ExitLong("L_EvenBreak",AtStop,EntryPrice);
if MarketPosition == -1 and
lowest(l,BarsSinceEntry) <= EntryPrice-수익포인트 Then
ExitShort("S_EvenBreak",AtStop,EntryPrice);
longStop = IFf(useClose == 1, highest(close, length) ,highest(H,length)) - a;
longStopPrev = iff(IsNan(longStop[1]) == true, longStop,longStop[1]);
longStop = iff(close[1] > longStopPrev ,max(longStop, longStopPrev) , longStop);
shortStop = IFf(useClose == 1, lowest(close, length) , Lowest(L,length)) + a;
shortStopPrev = iff(IsNan(shortStop[1]) == true, shortStop,shortStop[1]);
shortStop = iff(close[1] < shortStopPrev , min(shortStop, shortStopPrev) , shortStop);
dir = iff(close > shortStopPrev , 1 , IFF(close < longStopPrev , -1 , dir));
longStopB = IFf(useClose == 1, highest(close, lengthB) ,highest(H,lengthB)) - aB;
longStopPrevB = iff(IsNan(longStopB[1]) == true, longStopB,longStopB[1]);
longStopB = iff(close[1] > longStopPrevB ,max(longStopB, longStopPrevB) , longStopB);
shortStopB = IFf(useClose == 1, lowest(close, lengthB) , Lowest(L,lengthB)) + aB;
shortStopPrevB = iff(IsNan(shortStopB[1]) == true, shortStopB,shortStopB[1]);
shortStopB = iff(close[1] < shortStopPrevB , min(shortStopB, shortStopPrevB) , shortStopB);
dirB = iff(close > shortStopPrevB , 1 , IFF(close < longStopPrevB , -1 , dirB));
buySignal = avpchange > gma and BWI >= Bolllimit and C > O and C > Ma60 and dir == 1 and (CrossUp(avpchange,gma) and dir[1] == -1 or crossUp(C, Ma60));
buyExit = CrossDown(avpchange,gma);
sellSignal = avpchange < gma and BWI >= Bolllimit and C < O and C < Ma60 and dirB == -1 and (CrossDown(avpchange,gma) and dirB[1] == 1 or crossUp(C, Ma60));
sellExit = CrossUp(avpchange,gma);
IF Endtime > starttime Then
SetStopEndofday(Endtime);
Else
{
if sDate != sDate[1] Then
SetStopEndofday(Endtime);
}
if Bdate != Bdate[1] Then
{
IF Endtime <= starttime Then
{
SetStopEndofday(0);
}
}
if (sdate != sdate[1] and stime >= EndTime) or
(sdate == sdate[1] and stime >= EndTime and stime[1] < EndTime) Then
Tcond = False;
if (sdate != sdate[1] and stime >= StartTime) or
(sdate == sdate[1] and stime >= StartTime and stime[1] < StartTime) Then
Tcond = true;
if Tcond == true Then
{
if buySignal == true Then
Buy("Buy");
if buyExit == true Then
ExitLong("BExit");
if sellSignal == true Then
Sell("Sell");
if sellExit == true Then
ExitShort("SExit");
}
//SetStopInactivity(최소가격,기간,PointStop);
SetStopProfittarget(목표수익값,PointStop);
SetStopLoss(SetStop,PointStop);
SetStopTrailing(gamso,minMoney,PointStop,변수);