커뮤니티
지표 문의
2013-06-25 04:59:33
165
글번호 64666
안녕하세요, 아래 전략을 지표로 만들고 싶습니다.
매수든 매도든 한번 진입했다가 청산되는것을 '1거래'라고 하겟습니다.
제가 만들고 싶은 지표는 그래프로 나타나는 것은 아니고
단순히 Count 결과를 messageLog 등을 통해 추출하고 싶은 것입니다.
지표 내용 : 지난 100거래 혹은 1000거래 동안 1거래의 max값의 count
변수정의 : cnt_0.3 / cnt_0.9 / cnt_2.0
예를 들어
1번째 거래가 매수로 들어가서 0.5 까지 올라갔다면
cnt_0.3 = cnt_0.3 + 1 ; 입니다
2번째 거래가 매수로 들어가서 1.2 까지 올라갔다면
cnt_0.3 = cnt_0.3 + 1;
cnt_0.9 = cnt_0.9 + 1;
입니다.
즉, 1거래동안 최대값에 이르는동안 0.3 / 0.9 / 2.0 등 구간을 거치는 것은
모두 1씩 카운트 하는 것입니다..
마지막 예)
오늘 시가 50에서 시작하여
50 -> 50.5 -> 50 -> 50.4 -> 50 -> 51 -> 53 -> 50 -> 51(장종료) 으로 변동했다면
거래는 총 4회가 이루어졌고
cnt_0.3 = 4
cnt_0.9 = 2
cnt_2.0 = 1
전략과 마찬가지로 새로운 날이 열리면 기준시가는 변경됩니다.
이런 결과가 MessageLog 를 통해 도출되면 좋겠습니다
정말 감사합니다... (_ _);;
==================
var : Bcond1(false),Bcond2(false),Bcond3(false),BEntryVol(0);
var : Scond1(false),Scond2(false),Scond3(false),SEntryVol(0);
var : DOpen(0);
if stime == 161500 or (stime > 161500 and stime[1] < 161500) Then{
DOpen = O;
Bcond1 = false;
Bcond2 = false;
Bcond3 = false;
Scond1 = false;
Scond2 = false;
Scond3 = false;
}
if MarketPosition == 1 Then{
if highest(H,BarsSinceEntry) >= EntryPrice+0.3 Then
Bcond1 = true;
if highest(H,BarsSinceEntry) >= EntryPrice+0.9 Then
Bcond2 = true;
if highest(H,BarsSinceEntry) >= EntryPrice+2.0 Then
Bcond3 = true;
}
if MarketPosition == -1 Then{
if Lowest(L,BarsSinceEntry) <= EntryPrice-0.3 Then
Scond1 = true;
if Lowest(L,BarsSinceEntry) <= EntryPrice-0.9 Then
Scond2 = true;
if Lowest(L,BarsSinceEntry) <= EntryPrice-2.0 Then
Scond3 = true;
}
if Bcond1 == false and Bcond2 == false and Bcond3 == false Then
BEntryVol = 10;
if Bcond1 == true and Bcond2 == false and Bcond3 == false Then
BEntryVol = 8;
if Bcond1 == true and Bcond2 == true and Bcond3 == false Then
BEntryVol = 3;
if Bcond1 == true and Bcond2 == true and Bcond3 == true Then
BEntryVol = 0;
if Scond1 == false and Scond2 == false and Scond3 == false Then
SEntryVol = 10;
if Scond1 == true and Scond2 == false and Scond3 == false Then
SEntryVol = 8;
if Scond1 == true and Scond2 == true and Scond3 == false Then
SEntryVol = 3;
if Scond1 == true and Scond2 == true and Scond3 == true Then
SEntryVol = 0;
if MarketPosition <= 0 and crossup(c,DOpen) Then
buy("b",OnClose,def,BEntryVol);
if MarketPosition == 1 Then{
if Bcond1 == false Then
ExitLong("bx1",atlimit,EntryPrice+0.3,"",2,1);
if Bcond2 == false Then
ExitLong("bx2",atlimit,EntryPrice+0.9,"",5,1);
if Bcond3 == false Then
ExitLong("bx3",atlimit,EntryPrice+2.0,"",3,1);
}
if MarketPosition != 1 Then{
if Bcond1 == false Then
ExitLong("bx11",atlimit,C+0.3,"",2,1);
if Bcond2 == false Then
ExitLong("bx12",atlimit,C+0.9,"",5,1);
if Bcond3 == false Then
ExitLong("bx13",atlimit,C+2.0,"",3,1);
}
if MarketPosition >= 0 and CrossDown(C,DOpen) Then
sell("s",OnClose,def,SentryVol);
if MarketPosition == -1 Then{
if Scond1 == false Then
ExitShort("sx1",atlimit,EntryPrice-0.3,"",2,1);
if Scond2 == false Then
ExitShort("sx2",atlimit,EntryPrice-0.9,"",5,1);
if Scond3 == false Then
ExitShort("sx3",atlimit,EntryPrice-2.0,"",3,1);
}
if MarketPosition != -1 Then{
if Scond1 == false Then
ExitShort("sx11",atlimit,c-0.3,"",2,1);
if Scond2 == false Then
ExitShort("sx12",atlimit,c-0.9,"",5,1);
if Scond3 == false Then
ExitShort("sx13",atlimit,c-2.0,"",3,1);
}
#당일청산
if stime == 160000 or (stime > 160000 and stime[1] < 160000) Then{
ExitLong();
ExitShort();
}
답변 1
예스스탁 예스스탁 답변
2013-06-25 11:50:09
안녕하세요
예스스탁입니다.
최근 N개의 거래동안의 값을 리턴합니다.
input : N(100);
var : cnt(0),cnt_03(0),cnt_09(0),cnt_20(0);
var : Bcond1(false),Bcond2(false),Bcond3(false),BEntryVol(0);
var : Scond1(false),Scond2(false),Scond3(false),SEntryVol(0);
var : DOpen(0);
cnt_03 = 0;
cnt_09 = 0;
cnt_20 = 0;
for cnt = 1 to N{
if MaxPositionProfit(cnt) >= 0.3 Then
cnt_03 = cnt_03+1;
if MaxPositionProfit(cnt) >= 0.9 Then
cnt_09 = cnt_09+1;
if MaxPositionProfit(cnt) >= 2.0 Then
cnt_20 = cnt_20+1;
}
if stime == 161500 or (stime > 161500 and stime[1] < 161500) Then{
DOpen = O;
Bcond1 = false;
Bcond2 = false;
Bcond3 = false;
Scond1 = false;
Scond2 = false;
Scond3 = false;
}
if MarketPosition == 1 Then{
if highest(H,BarsSinceEntry) >= EntryPrice+0.3 Then
Bcond1 = true;
if highest(H,BarsSinceEntry) >= EntryPrice+0.9 Then
Bcond2 = true;
if highest(H,BarsSinceEntry) >= EntryPrice+2.0 Then
Bcond3 = true;
}
if MarketPosition == -1 Then{
if Lowest(L,BarsSinceEntry) <= EntryPrice-0.3 Then
Scond1 = true;
if Lowest(L,BarsSinceEntry) <= EntryPrice-0.9 Then
Scond2 = true;
if Lowest(L,BarsSinceEntry) <= EntryPrice-2.0 Then
Scond3 = true;
}
if Bcond1 == false and Bcond2 == false and Bcond3 == false Then
BEntryVol = 10;
if Bcond1 == true and Bcond2 == false and Bcond3 == false Then
BEntryVol = 8;
if Bcond1 == true and Bcond2 == true and Bcond3 == false Then
BEntryVol = 3;
if Bcond1 == true and Bcond2 == true and Bcond3 == true Then
BEntryVol = 0;
if Scond1 == false and Scond2 == false and Scond3 == false Then
SEntryVol = 10;
if Scond1 == true and Scond2 == false and Scond3 == false Then
SEntryVol = 8;
if Scond1 == true and Scond2 == true and Scond3 == false Then
SEntryVol = 3;
if Scond1 == true and Scond2 == true and Scond3 == true Then
SEntryVol = 0;
if MarketPosition <= 0 and crossup(c,DOpen) Then
buy("b",OnClose,def,BEntryVol);
if MarketPosition == 1 Then{
if Bcond1 == false Then
ExitLong("bx1",atlimit,EntryPrice+0.3,"",2,1);
if Bcond2 == false Then
ExitLong("bx2",atlimit,EntryPrice+0.9,"",5,1);
if Bcond3 == false Then
ExitLong("bx3",atlimit,EntryPrice+2.0,"",3,1);
}
if MarketPosition != 1 Then{
if Bcond1 == false Then
ExitLong("bx11",atlimit,C+0.3,"",2,1);
if Bcond2 == false Then
ExitLong("bx12",atlimit,C+0.9,"",5,1);
if Bcond3 == false Then
ExitLong("bx13",atlimit,C+2.0,"",3,1);
}
if MarketPosition >= 0 and CrossDown(C,DOpen) Then
sell("s",OnClose,def,SentryVol);
if MarketPosition == -1 Then{
if Scond1 == false Then
ExitShort("sx1",atlimit,EntryPrice-0.3,"",2,1);
if Scond2 == false Then
ExitShort("sx2",atlimit,EntryPrice-0.9,"",5,1);
if Scond3 == false Then
ExitShort("sx3",atlimit,EntryPrice-2.0,"",3,1);
}
if MarketPosition != -1 Then{
if Scond1 == false Then
ExitShort("sx11",atlimit,c-0.3,"",2,1);
if Scond2 == false Then
ExitShort("sx12",atlimit,c-0.9,"",5,1);
if Scond3 == false Then
ExitShort("sx13",atlimit,c-2.0,"",3,1);
}
#당일청산
if stime == 160000 or (stime > 160000 and stime[1] < 160000) Then{
ExitLong();
ExitShort();
}
MessageLog("0.3 %.f 0.9 %.f 2.0 %.f",cnt_03,cnt_09,cnt_20);
즐거운 하루되세요
> 데몬 님이 쓴 글입니다.
> 제목 : 지표 문의
>
안녕하세요, 아래 전략을 지표로 만들고 싶습니다.
매수든 매도든 한번 진입했다가 청산되는것을 '1거래'라고 하겟습니다.
제가 만들고 싶은 지표는 그래프로 나타나는 것은 아니고
단순히 Count 결과를 messageLog 등을 통해 추출하고 싶은 것입니다.
지표 내용 : 지난 100거래 혹은 1000거래 동안 1거래의 max값의 count
변수정의 : cnt_0.3 / cnt_0.9 / cnt_2.0
예를 들어
1번째 거래가 매수로 들어가서 0.5 까지 올라갔다면
cnt_0.3 = cnt_0.3 + 1 ; 입니다
2번째 거래가 매수로 들어가서 1.2 까지 올라갔다면
cnt_0.3 = cnt_0.3 + 1;
cnt_0.9 = cnt_0.9 + 1;
입니다.
즉, 1거래동안 최대값에 이르는동안 0.3 / 0.9 / 2.0 등 구간을 거치는 것은
모두 1씩 카운트 하는 것입니다..
마지막 예)
오늘 시가 50에서 시작하여
50 -> 50.5 -> 50 -> 50.4 -> 50 -> 51 -> 53 -> 50 -> 51(장종료) 으로 변동했다면
거래는 총 4회가 이루어졌고
cnt_0.3 = 4
cnt_0.9 = 2
cnt_2.0 = 1
전략과 마찬가지로 새로운 날이 열리면 기준시가는 변경됩니다.
이런 결과가 MessageLog 를 통해 도출되면 좋겠습니다
정말 감사합니다... (_ _);;
==================
var : Bcond1(false),Bcond2(false),Bcond3(false),BEntryVol(0);
var : Scond1(false),Scond2(false),Scond3(false),SEntryVol(0);
var : DOpen(0);
if stime == 161500 or (stime > 161500 and stime[1] < 161500) Then{
DOpen = O;
Bcond1 = false;
Bcond2 = false;
Bcond3 = false;
Scond1 = false;
Scond2 = false;
Scond3 = false;
}
if MarketPosition == 1 Then{
if highest(H,BarsSinceEntry) >= EntryPrice+0.3 Then
Bcond1 = true;
if highest(H,BarsSinceEntry) >= EntryPrice+0.9 Then
Bcond2 = true;
if highest(H,BarsSinceEntry) >= EntryPrice+2.0 Then
Bcond3 = true;
}
if MarketPosition == -1 Then{
if Lowest(L,BarsSinceEntry) <= EntryPrice-0.3 Then
Scond1 = true;
if Lowest(L,BarsSinceEntry) <= EntryPrice-0.9 Then
Scond2 = true;
if Lowest(L,BarsSinceEntry) <= EntryPrice-2.0 Then
Scond3 = true;
}
if Bcond1 == false and Bcond2 == false and Bcond3 == false Then
BEntryVol = 10;
if Bcond1 == true and Bcond2 == false and Bcond3 == false Then
BEntryVol = 8;
if Bcond1 == true and Bcond2 == true and Bcond3 == false Then
BEntryVol = 3;
if Bcond1 == true and Bcond2 == true and Bcond3 == true Then
BEntryVol = 0;
if Scond1 == false and Scond2 == false and Scond3 == false Then
SEntryVol = 10;
if Scond1 == true and Scond2 == false and Scond3 == false Then
SEntryVol = 8;
if Scond1 == true and Scond2 == true and Scond3 == false Then
SEntryVol = 3;
if Scond1 == true and Scond2 == true and Scond3 == true Then
SEntryVol = 0;
if MarketPosition <= 0 and crossup(c,DOpen) Then
buy("b",OnClose,def,BEntryVol);
if MarketPosition == 1 Then{
if Bcond1 == false Then
ExitLong("bx1",atlimit,EntryPrice+0.3,"",2,1);
if Bcond2 == false Then
ExitLong("bx2",atlimit,EntryPrice+0.9,"",5,1);
if Bcond3 == false Then
ExitLong("bx3",atlimit,EntryPrice+2.0,"",3,1);
}
if MarketPosition != 1 Then{
if Bcond1 == false Then
ExitLong("bx11",atlimit,C+0.3,"",2,1);
if Bcond2 == false Then
ExitLong("bx12",atlimit,C+0.9,"",5,1);
if Bcond3 == false Then
ExitLong("bx13",atlimit,C+2.0,"",3,1);
}
if MarketPosition >= 0 and CrossDown(C,DOpen) Then
sell("s",OnClose,def,SentryVol);
if MarketPosition == -1 Then{
if Scond1 == false Then
ExitShort("sx1",atlimit,EntryPrice-0.3,"",2,1);
if Scond2 == false Then
ExitShort("sx2",atlimit,EntryPrice-0.9,"",5,1);
if Scond3 == false Then
ExitShort("sx3",atlimit,EntryPrice-2.0,"",3,1);
}
if MarketPosition != -1 Then{
if Scond1 == false Then
ExitShort("sx11",atlimit,c-0.3,"",2,1);
if Scond2 == false Then
ExitShort("sx12",atlimit,c-0.9,"",5,1);
if Scond3 == false Then
ExitShort("sx13",atlimit,c-2.0,"",3,1);
}
#당일청산
if stime == 160000 or (stime > 160000 and stime[1] < 160000) Then{
ExitLong();
ExitShort();
}