안녕하세요?
답변주신 아래 글번호 81505에 진입횟수를 추가 하고 싶습니다.
아래와 같이 작성해보았는데 횟수 제어가 안됩니다.
input : 최대진입횟수(3);
input : P(20),dv(2);
var : bbmd(0),bbup(0),bbdn(0),bwidth(0);
Var : Entry(0);
bbmd = ma(c,P);
bbup = bbmd+std(c,P)*dv;
bbdn = bbmd-std(c,P)*dv;
Bwidth = (bbup-bbdn)/bbmd;
if Bdate != Bdate[1] Then
{
entry = 0;
}
If entry < 최대진입횟수 and C > bbmd and CountIf(Bwidth>Bwidth[1],2) == 2 Then
{
Buy();
}
If entry < 최대진입횟수 and C < bbmd and CountIf(Bwidth<Bwidth[1],2) == 2 Then
{
Sell();
}
if MarketPosition == 1 and CountIf(Bwidth<Bwidth[1],BarsSinceEntry) == 2 Then
ExitLong();
if MarketPosition == -1 and CountIf(Bwidth<Bwidth[1],BarsSinceEntry) == 2 Then
ExitShort();
SetStopEndofday(152000);
답변 1
예스스탁
예스스탁 답변
2023-04-04 08:53:43
안녕하세요
예스스탁입니다.
entry는 변수일 뿐입니다.
진입이 발생하면 해당 변수에 1씩 증가를 하게 내용을 추가하셔야 합니다.
input : 최대진입횟수(3);
input : P(20),dv(2);
var : bbmd(0),bbup(0),bbdn(0),bwidth(0);
Var : Entry(0);
bbmd = ma(c,P);
bbup = bbmd+std(c,P)*dv;
bbdn = bbmd-std(c,P)*dv;
Bwidth = (bbup-bbdn)/bbmd;
if Bdate != Bdate[1] Then
{
entry = 0;
}
if (MarketPosition != 0 and MarketPosition != MarketPosition[1]) or
(MarketPosition == MarketPosition[1] and TotalTrades > TotalTrades[1]) Then
entry = entry+1;
If entry < 최대진입횟수 and C > bbmd and CountIf(Bwidth>Bwidth[1],2) == 2 Then
{
Buy();
}
If entry < 최대진입횟수 and C < bbmd and CountIf(Bwidth<Bwidth[1],2) == 2 Then
{
Sell();
}
if MarketPosition == 1 and CountIf(Bwidth<Bwidth[1],BarsSinceEntry) == 2 Then
ExitLong();
if MarketPosition == -1 and CountIf(Bwidth<Bwidth[1],BarsSinceEntry) == 2 Then
ExitShort();
SetStopEndofday(152000);
즐거운 하루되세요
> 흰둥이아빠 님이 쓴 글입니다.
> 제목 : 함수요청
> 안녕하세요?
답변주신 아래 글번호 81505에 진입횟수를 추가 하고 싶습니다.
아래와 같이 작성해보았는데 횟수 제어가 안됩니다.
input : 최대진입횟수(3);
input : P(20),dv(2);
var : bbmd(0),bbup(0),bbdn(0),bwidth(0);
Var : Entry(0);
bbmd = ma(c,P);
bbup = bbmd+std(c,P)*dv;
bbdn = bbmd-std(c,P)*dv;
Bwidth = (bbup-bbdn)/bbmd;
if Bdate != Bdate[1] Then
{
entry = 0;
}
If entry < 최대진입횟수 and C > bbmd and CountIf(Bwidth>Bwidth[1],2) == 2 Then
{
Buy();
}
If entry < 최대진입횟수 and C < bbmd and CountIf(Bwidth<Bwidth[1],2) == 2 Then
{
Sell();
}
if MarketPosition == 1 and CountIf(Bwidth<Bwidth[1],BarsSinceEntry) == 2 Then
ExitLong();
if MarketPosition == -1 and CountIf(Bwidth<Bwidth[1],BarsSinceEntry) == 2 Then
ExitShort();
SetStopEndofday(152000);