커뮤니티
수동으로 marketposition 조건문을 만족시킬려면?
2012-02-28 19:17:18
474
글번호 48338
전날 동시호가 자동주문이 안된다고 하시니, 일단 수동으로 전날 장종료시 현물 주문을 했다고 했을때, buy 라는 것을 사용하지 않았는데, marketposition == 1 이런 조건문이 가능하나요?
제가 일부러 marketposition = 1; 이라는 할당문을 앞에 넣었더니, 문법 에러가 나더군요...
즉 다시 말씀드리면, 이미 매도주문을 위한 현물이 있는 상황에서, 매도 marketposition 조건문을 타려면 다음과 같이 하는 것이 맞나요?
------------------------------------------------------------------------
rate_cutloss = -3;
A_rate = (A_close-A_DayClose)/A_DayClose*100;
변수정의시 본종목 등락률을 A_rate으로 상기와 같이 정의했습니다.
if marketposition ==1 then
{
if CrossDown(A_rate, rate_cutloss) then
{
exitlong("손절");
}
else if A_rate > 14 then
{
exitlong("상한");
}
else if CrossDown(EMA(A_close, 10), EMA(A_close, se20)) then
{
exitlong("이평매도");
}
}
답변 1
예스스탁 예스스탁 답변
2012-02-28 19:54:38
안녕하세요
예스스탁입니다.
marketposition은 차트상 신호에 따라 할당 되므로
강제로 할당할 수 없습니다.
또한 시스템에서는 직전에 진입신호가 없으면
청산신호는 발동이 되지 않으며
진입신호가 없는 시스템은 차트에 적용이 가능하지 않습니다.
하나의 방법이라면 차트의 과거봉에 매수신호를 찍고 신호를 발생하게 하는 내용입니다.
아래식은 차트 첫봉에 매수신호를 찍고 청산을 당일에만 발생하게 하는 식입니다.
진입가격이나 진입이후의 최고가등이 필요없는 청산조건이시므로
아래식을 이용하시면 될것 같습니다.
input : 진입수량(100),Cutloss(-3),P1(10),P2(20);
var : 상한가(0), UpLimit(0);
var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0);
#상한가 계산
if date >= 19981207 then {
if date < 20050328 && CodeCategory() == 2 then
UpLimit = (BP[0] * 1.12);
Else
UpLimit = (BP[0] * 1.15);
if CodeCategory() == 2 then {
if date >= 20030721 then {
up1 = int(UpLimit/100+0.00001)*100;
up2 = int(UpLimit/100+0.00001)*100;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
}
else {
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/10+0.00001)*10;
}
}
Else {
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
}
if CodeCategory() == 1 || CodeCategory() == 2 then {
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else
상한가 = iff(up6>=5000, up5, up6);
}
else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF
상한가 = up6;
}
}
#가신호(차트상 젤 첫봉에 매수신호가 찍힘)
if index == 0 Then
buy("B",OnClose,def,진입수량);
if MarketPosition == 1 and CurrentDate == sdate then{#항상 당일에만 발동
exitlong("손절",AtStop,DayClose(1)*(1+Cutloss/100));
exitlong("상한",AtStop,상한가);
if CrossDown(EMA(close, P1), EMA(close, P2)) Then
ExitLong("이평매도");
}
CurrentDate는 컴퓨터의 날짜를 가져와서 데이터의 시간과 비교하므로
컴퓨터 날짜가 정상적으로 설정이 되어 있는지 확인하셔야 합니다.
즐거운 하루되세요
> 아우라 님이 쓴 글입니다.
> 제목 : 수동으로 marketposition 조건문을 만족시킬려면?
> 전날 동시호가 자동주문이 안된다고 하시니, 일단 수동으로 전날 장종료시 현물 주문을 했다고 했을때, buy 라는 것을 사용하지 않았는데, marketposition == 1 이런 조건문이 가능하나요?
제가 일부러 marketposition = 1; 이라는 할당문을 앞에 넣었더니, 문법 에러가 나더군요...
즉 다시 말씀드리면, 이미 매도주문을 위한 현물이 있는 상황에서, 매도 marketposition 조건문을 타려면 다음과 같이 하는 것이 맞나요?
------------------------------------------------------------------------
rate_cutloss = -3;
A_rate = (A_close-A_DayClose)/A_DayClose*100;
변수정의시 본종목 등락률을 A_rate으로 상기와 같이 정의했습니다.
if marketposition ==1 then
{
if CrossDown(A_rate, rate_cutloss) then
{
exitlong("손절");
}
else if A_rate > 14 then
{
exitlong("상한");
}
else if CrossDown(EMA(A_close, 10), EMA(A_close, se20)) then
{
exitlong("이평매도");
}
}