Q&A 게시판 | HOME > Q&A 게시판 |
작성자 :
거꾸시
작성일 : 2025-09-14 22:57:45
조회수 : 8
수식문의 드립니다.
아래의 지표 수식의 신호에 따라 자동매매를 하고 싶습니다.
시스템 코드로 변경하여 주십시오.
설정한 금액만큼 진입
녹색 삼각형 신호에 매수 진입.
빨간색 삼각형 신호에 청산.
input : a(1);
input : ATRP(10);
input : ha(false);
var : xATR(0),nLoss(0);
var : xClose(0),xHigh(0),xLow(0),xOpen(0),src(0);
var : xATRTrailingStop(0),ps(0),xcolor(0);
xATR = atr(ATRP);
nLoss = a * xATR;
if index == 0 then
{
xClose = (O+H+L+C)/4;
xOpen = open;
xHigh = MaxList( high, xOpen, xClose);
xLow = MinList( low, xOpen,xClose);
}
else
{
xClose = (O+H+L+C)/4;
xOpen = (xOpen [1] + xClose [1])/2 ;
xHigh = MaxList(High, xOpen, xClose) ;
xLow = MinList(Low, xOpen, xClose) ;
}
if ha == False Then
src = close;
Else
src = xClose;
var1 = IFf(IsNan(xATRTrailingStop[1]) ==true,0,xATRTrailingStop[1]);
xATRTrailingStop =iff(src > var1 and src[1] > var1, max(var1, src - nLoss),
iff(src < var1 and src[1] < var1, min(var1, src + nLoss),
iff(src > var1, src - nLoss, src + nLoss)));
ps = iff(src[1] < var1 and src > var1, 1,
iff(src[1] > var1 and src < var1, -1, IFf(IsNaN(ps[1])==true,0,ps[1])));
xcolor = iff(ps == -1 , red, IFf(ps == 1 , green , blue));
var : emv(0),above(False),below(False);
var : b(False),s(False),barbuy(False),barsell(False),tx(0);
emv = ema(src,1);
above = CrossUp(emv, xATRTrailingStop);
below = CrossUp(xATRTrailingStop, emv);
b = src > xATRTrailingStop and above;
s = src < xATRTrailingStop and below;
barbuy = src > xATRTrailingStop;
barsell = src < xATRTrailingStop ;
if b == true Then
{
tx = Text_New(sDate,sTime,L,"▲");
Text_SetStyle(tx,2,0);
Text_SetColor(tx,Green);
}
if s == true Then
{
tx = Text_New(sDate,sTime,H,"▼");
Text_SetStyle(tx,2,1);
Text_SetColor(tx,Red);
}
시스템 코드로 변경하여 주십시오.
설정한 금액만큼 진입
녹색 삼각형 신호에 매수 진입.
빨간색 삼각형 신호에 청산.
input : a(1);
input : ATRP(10);
input : ha(false);
var : xATR(0),nLoss(0);
var : xClose(0),xHigh(0),xLow(0),xOpen(0),src(0);
var : xATRTrailingStop(0),ps(0),xcolor(0);
xATR = atr(ATRP);
nLoss = a * xATR;
if index == 0 then
{
xClose = (O+H+L+C)/4;
xOpen = open;
xHigh = MaxList( high, xOpen, xClose);
xLow = MinList( low, xOpen,xClose);
}
else
{
xClose = (O+H+L+C)/4;
xOpen = (xOpen [1] + xClose [1])/2 ;
xHigh = MaxList(High, xOpen, xClose) ;
xLow = MinList(Low, xOpen, xClose) ;
}
if ha == False Then
src = close;
Else
src = xClose;
var1 = IFf(IsNan(xATRTrailingStop[1]) ==true,0,xATRTrailingStop[1]);
xATRTrailingStop =iff(src > var1 and src[1] > var1, max(var1, src - nLoss),
iff(src < var1 and src[1] < var1, min(var1, src + nLoss),
iff(src > var1, src - nLoss, src + nLoss)));
ps = iff(src[1] < var1 and src > var1, 1,
iff(src[1] > var1 and src < var1, -1, IFf(IsNaN(ps[1])==true,0,ps[1])));
xcolor = iff(ps == -1 , red, IFf(ps == 1 , green , blue));
var : emv(0),above(False),below(False);
var : b(False),s(False),barbuy(False),barsell(False),tx(0);
emv = ema(src,1);
above = CrossUp(emv, xATRTrailingStop);
below = CrossUp(xATRTrailingStop, emv);
b = src > xATRTrailingStop and above;
s = src < xATRTrailingStop and below;
barbuy = src > xATRTrailingStop;
barsell = src < xATRTrailingStop ;
if b == true Then
{
tx = Text_New(sDate,sTime,L,"▲");
Text_SetStyle(tx,2,0);
Text_SetColor(tx,Green);
}
if s == true Then
{
tx = Text_New(sDate,sTime,H,"▼");
Text_SetStyle(tx,2,1);
Text_SetColor(tx,Red);
}