답변완료
수정 부탁드립니다.
일전에 만들어 주신 시스템식을 아래와 같이 3가지로 만들고 싶은데 가능할까요?
1. 매수신호에 매수'진입'하고, 매도신호에는 매수'청산' 만 되도록 (청산과 동시 매도진입X),
2. 매도신호에 매도'진입'하고, 매수신호에 매도'청산' 만 되도록 (청산과 동시 매수진입X).
3. ema 100 위 매수신호에 매수'진입'하고, 매도신호에는 매수'청산' 만 되도록 (청산과 동시 매도진입X),
ema 100 아래 매도신호에 매도'진입'하고, 매수신호에 매도'청산' 만 되도록 (청산과 동시 매수진입X).
항상 감사드립니다~!!
input : keyvalue(5);
input : atrperiod(10);
var : src(0),xatr(0),nloss(0),xATRTrailingStop(0),pos(0),xcolor(0);
src = close;
xATR = atr(atrperiod);
nLoss = keyvalue * xATR;
xATRTrailingStop = 0.0;
xATRTrailingStop = iff(src > iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]) and src[1] > iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]), max(iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]), src - nLoss),
iff(src < iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]) and src[1] < iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]), min(iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]), src + nLoss),
iff(src > iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]), src - nLoss, src + nLoss)));
pos = 0;
pos = iff(src[1] < iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]) and src > iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]), 1,
iff(src[1] > iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]) and src < iff(IsNan(xATRTrailingStop[1]) == true, 0,xATRTrailingStop[1]), -1, iff(IsNan(pos[1])==true, 0,pos[1])));
xcolor = iff(pos == -1 , red , iff(pos == 1 , green ,blue));
Condition1 = CrossUp(src,xATRTrailingStop);
Condition2 = CrossDown(src,xATRTrailingStop);
if Condition1 == true Then
Buy("Buy");
if Condition2 == true Then
Sell("Sell");
2023-12-18
1128
글번호 174922
시스템
답변완료
전환비율 data2
Input:전환비율(0.1);
Var:j(0),jj(0),HH(0),LL(0),hiBar(0),loBar(0),최종꼭지점(""),처리구분(""),TL1(0);
Array:고[10,4](0),저[10,4](0);
HH=H;
LL=L;
If Index==0 Then
{
고[1,1]=HH;
고[1,2]=0;
고[1,3]=sDate;
고[1,4]=sTime;
저[1,1]=LL;
저[1,2]=0;
저[1,3]=sDate;
저[1,4]=sTime;
}
If Index>0 Then
{
hiBar=hiBar+1;
loBar=loBar+1;
}
If HH[hiBar]<HH Then hiBar=0;
If LL[loBar]>LL Then loBar=0;
Condition1=저[1,1]*(1+(전환비율/100))<HH and hiBar==0;
Condition2=고[1,1]*(1-(전환비율/100))>LL and loBar==0;
처리구분="";
If Condition1 and Condition2 Then//고점과저점조건동시만족
{
If 최종꼭지점=="저점" Then
{
If 저[1,1]>LL Then 처리구분="저점처리";
Else 처리구분="고점처리";
}
Else If 최종꼭지점=="고점" Then
{
If 고[1,1]<HH Then 처리구분="고점처리";
Else 처리구분="저점처리";
}
}
Else If Condition1 Then 처리구분="고점처리";
Else If Condition2 Then 처리구분="저점처리";
If 처리구분=="고점처리" Then
{
If 최종꼭지점=="저점" Then
{
For j=10 DownTo 2
{
For jj=1 To 4
{
고[j,jj]=고[j-1,jj];
}
}
고[1,1]=HH[hiBar];
고[1,2]=Index-hiBar;
고[1,3]=sDate[hiBar];
고[1,4]=sTime[hiBar];
hiBar=-1;
loBar=-1;
TL1=TL_New_Self(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
TL_SetSize(TL1,1);
TL_SetColor(TL1,RED);
}
Else If 고[1,1]<HH[hiBar] Then//1번고점보다높은고가출현
{
고[1,1]=HH[hiBar];
고[1,2]=Index-hiBar;
고[1,3]=sDate[hiBar];
고[1,4]=sTime[hiBar];
hiBar=-1;
loBar=-1;
TL_SetEnd(TL1,고[1,3],고[1,4],고[1,1]);
}
최종꼭지점="고점";
Plot1(고[1,1]);
NoPlot(2);
}
If 처리구분=="저점처리" Then
{
If 최종꼭지점=="고점" Then
{
For j=10 DownTo 2
{
For jj=1 To 4
{
저[j,jj]=저[j-1,jj];
}
}
저[1,1]=LL[loBar];
저[1,2]=Index-loBar;
저[1,3]=sDate[loBar];
저[1,4]=sTime[loBar];
hiBar=-1;
loBar=-1;
TL1=TL_New_Self(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
TL_SetSize(TL1,1);
TL_SetColor(TL1,BLUE);
}
Else If 저[1,1]>LL[loBar] Then
{
저[1,1]=LL[loBar];
저[1,2]=Index-loBar;
저[1,3]=sDate[loBar];
저[1,4]=sTime[loBar];
hiBar=-1;
loBar=-1;
TL_SetEnd(TL1,저[1,3],저[1,4],저[1,1]);
}
최종꼭지점="저점";
Plot2(저[1,1]);
NoPlot(1);
}
data2 지표로 쓸수있게 수정.
data2가 상승전환하면 상승 box, 하락전환하면 상승 box 삭제하고 하락 box. 감사합니다.
2023-12-17
1731
글번호 174917
지표