커뮤니티
수식좀 검토해주세요..
2012-01-19 17:36:36
359
글번호 46822
안녕하세요..
선물당일거래용으로 만든수식인데 결과값이 다르게 나와서 문의드립니다.
var : cond(False,data2),cond1(False,data2);
if data2(dayindex) == 0 Then{
cond = data2(C>O);
cond1 = data2(C<O); }
If dayindex == 5 Then{
var1 = DayOpen;
var2 = Highest(H,5);
var3 = Lowest(L,5);
var4 = C; }
if cond == true and MarketPosition == 0 then{
if crossup(c,var2) Then
buy("b1");
if MarketPosition == 1 and CrossDown(c,var1) Then
sell("s1"); }
if cond1 == true and MarketPosition == 0 then{
if crossdown(c,var4) Then
sell("s11");
if MarketPosition == -1 and Crossup(c,var4) Then
buy("b11"); }
SetStopProfittarget(2,PointStop);
여기서 종가가 매수한 값보다 작으면 매수청산, 매도한 값보다 크면 매도청산이
되도록 작성한 수식인데 결과값은 청산이 되지 않습니다. 수정좀 부탁합니다.
또, 매수나 매도이후 수익발생하면 더이상 진입금지 되도록 수식좀 추가해주세요
옵션에서 사용할 수 있도록 수식도 추가 부탁합니다..
수고하세요..
답변 4
예스스탁 예스스탁 답변
2012-01-19 16:19:40
안녕하세요
예스스탁입니다.
식을 수정했습니다.
var : cond(False,data2),cond1(False,data2);
var : va1(0,data1),va2(0,data1),va3(0,data1),va4(0,data1);
if data2(dayindex) == 0 Then{
cond = data2(C>O);
cond1 = data2(C<O);
}
If data1(dayindex+1 == 5) Then{
va1 = data1(DayOpen);
va2 = data1(Highest(H,5));
va3 = data1(Lowest(L,5));
va4 = data1(C);
}
if cond == true and MarketPosition == 0 and data1(dayindex+1) > 5 then{
if crossup(c,va2) Then
buy("b1");
}
if MarketPosition == 1 and CrossDown(c,va1) Then
sell("s1");
if cond1 == true and MarketPosition == 0 and data1(dayindex+1) > 5 then{
if crossdown(c,va4) Then
sell("s11");
}
if MarketPosition == -1 and Crossup(c,va4) Then
buy("b11");
SetStopProfittarget(0.5,PointStop);
MarketPosition == 0 과 MarketPosition == 1이 하나의 봉에서 모두 만족하게
작성이 되어 있어 s1 신호가 발생할 수 없었습니다.
마찬가지로 MarketPosition == 0 과 MarketPosition == -1이 하나의 봉에서 모두 만족하게 작성이 되어 있어 b11 신호가 발생할 수 없었습니다.
참조 종목 사용하실 경우 모든 변수나 값들은 테이터 번호를 지정해서
작성해 주셔야 합니다.
s1과 b11은 청산후 모두 반대포지션으로 진입되게 작성이 되어 있습니다.
만약 청산만 하실 의도시면 아래와 같이 변경하시면 됩니다.
sell("s1")l; --> exitlong("s1");
buy("b11")l; --> exitshort("b11");
즐거운 하루되세요
> bigdeal 님이 쓴 글입니다.
> 제목 : 수식좀 검토해주세요..
> 안녕하세요..
선물당일거래용으로 만든수식인데 결과값이 다르게 나와서 문의드립니다.
var : cond(False,data2),cond1(False,data2);
if data2(dayindex) == 0 Then{
cond = data2(C>O);
cond1 = data2(C<O); }
If dayindex == 5 Then{
var1 = DayOpen;
var2 = Highest(H,5);
var3 = Lowest(L,5);
var4 = C; }
if cond == true and MarketPosition == 0 then{
if crossup(c,var2) Then
buy("b1");
if MarketPosition == 1 and CrossDown(c,var1) Then
sell("s1"); }
if cond1 == true and MarketPosition == 0 then{
if crossdown(c,var4) Then
sell("s11");
if MarketPosition == -1 and Crossup(c,var4) Then
buy("b11"); }
SetStopProfittarget(0.5,PointStop);
여기서 종가가 매수한 값보다 작으면 매수청산, 매도한 값보다 크면 매도청산이
되도록 작성한 수식인데 결과값은 청산이 되지 않습니다. 수정좀 부탁합니다.
또, 매수나 매도이후 수익발생하면 더이상 진입금지 되도록 수식좀 추가해주세요
옵션에서 사용할 수 있도록 수식도 추가 부탁합니다..
수고하세요..
bigdeal
2012-01-19 16:43:57
감사합니다.
매수, 매도 진입후 수익발생되면 더이상 진입금지하는 수식과
위수식을 옵션에서 사용할 수 있는 수식으로 부탁좀드립니다. 내가 만든수식으로 적용하면 신호가 옵션에서 발생되는 신호와 선물봉에서 나오는 신호가 다릅니다.
감사합니다
예스스탁 예스스탁 답변
2012-01-19 17:12:14
안녕하세요
예스스탁입니다.
죄송합니다. 누락된 부분이 있었습니다.
수익이 발생하면 더이상 진입하지 않게 수정했습니다.
Input : shortPeriod(5), longPeriod(20), period(36),ADXP(14);
var : cnt(0),count(0),d2adx(0,data2),cond(false,data2),d3cross(0,data3),d4cross(0,data4);
var : val1(0,data1),val2(0,data1),val3(0,data1),cond1(false,data1),cond2(false,data1);
d2adx = data2(ADX(ADXP));
val1 = ema(C, shortPeriod);
val2 = ema(C, longPeriod);
val3= ema(C, Period);
if data2(date != date[1]) then
cond = false;
if d2adx >= 40 Then
cond = true;
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count+1;
}
cond1 = count == 0 or
(count >= 1 and MarketPosition == -1) or
(count >= 1 and MarketPosition == 0 and
(IsExitName("ssx",1) == true or IsExitName("sPt1",1) == true or IsExitName("bx",1) == true or IsExitName("sx",1) == true));
cond2 = count == 0 or
(count >= 1 and MarketPosition == 1) or
(count >= 1 and MarketPosition == 0 and
(IsExitName("bbx",1) == true or IsExitName("bPt1",1) == true or IsExitName("bx",1) == true or IsExitName("sx",1) == true));
if data3(crossup(ma(c,5),ma(c,30))) Then
d3cross = 1;
if data3(CrossDown(ma(c,5),ma(c,30))) Then
d3cross = -1;
if data4(crossup(ma(c,5),ma(c,30))) Then
d4cross = 1;
if data4(CrossDown(ma(c,5),ma(c,30))) Then
d4cross = -1;
if cond1 == true and val1 > val2 and val3 > val3[1] and !(d3cross == -1 and d4cross == -1) Then{
if (count == 0) or
(count >= 1 and MarketPosition == -1 and C > EntryPrice) or
(count >= 1 and MarketPosition == 0 and PositionProfit(1) < 0) Then
buy("b");
if count >= 1 and MarketPosition == -1 and C < EntryPrice Then
ExitShort();
}
if cond2 == true and val1 < val2 and val3 < val3[1] and !(d3cross == 1 and d4cross == 1) Then{
if (count == 0) or
(count >= 1 and MarketPosition == 1 and C < EntryPrice) or
(count >= 1 and MarketPosition == 0 and PositionProfit(1) < 0) Then
sell("s");
if count >= 1 and MarketPosition == -1 and C > EntryPrice Then
Exitlong();
}
if MarketPosition == 1 and val3 < val3[1] and cond == false Then
ExitLong("bx");
if MarketPosition == 1 and val2 < val2[1] and cond == true Then
ExitLong("bbx");
if MarketPosition == -1 and val3 > val3[1] and cond == false Then
ExitShort("sx");
if MarketPosition == -1 and val2 > val2[1] and cond == true Then
ExitShort("ssx");
if MarketPosition !=0 Then{
ExitLong("bPT1",atLimit,EntryPrice+1);#진입가+1포인트 매수청산
ExitShort("SPT1",AtLimit,EntryPrice-1);#진입가-1포인트 매도청산
}
현재 주종목이 선물인 내용에서 해당 내용 포함하여
옵션으로 변경하는 하시려면 옵션이 주종목이 되고
선물을 참조종목으로 추가하셔야 합니다.
data2~data4를 기존에 사용하시므로 data5로 선물을 참조로 추가하신후
주종목을 옵션종목으로 하시고 식을 걸어주셔야 합니다.
또한 atlimit이나 atstop은 원래 주종목의 데이터만을
감시하는 것이므로 선물이 참조로 가게되면
모두 봉완성시로 변경해서 작성해야 합니다.
변경한 식입니다.
Input : shortPeriod(5), longPeriod(20), period(36),ADXP(14);
var : cnt(0),count(0),d2adx(0,data2),cond(false,data2),d3cross(0,data3),d4cross(0,data4);
var : val1(0,data5),val2(0,data5),val3(0,data5),cond1(false,data1),cond2(false,data1),d5c(0,data1);
d2adx = data2(ADX(ADXP));
val1 = data5(ema(C, shortPeriod));
val2 = data5(ema(C, longPeriod));
val3 = data5(ema(C, Period));
d5C = data5(c);
if data2(date != date[1]) then
cond = false;
if d2adx >= 40 Then
cond = true;
count = 0;
for cnt = 0 to 10{
if sdate == EntryDate(cnt) Then
count = count+1;
}
cond1 = count == 0 or
(count >= 1 and MarketPosition == -1) or
(count >= 1 and MarketPosition == 0 and
(IsExitName("ssx",1) == true or IsExitName("sPt1",1) == true or IsExitName("bx",1) == true or IsExitName("sx",1) == true));
cond2 = count == 0 or
(count >= 1 and MarketPosition == 1) or
(count >= 1 and MarketPosition == 0 and
(IsExitName("bbx",1) == true or IsExitName("bPt1",1) == true or IsExitName("bx",1) == true or IsExitName("sx",1) == true));
if data3(crossup(ma(c,5),ma(c,30))) Then
d3cross = 1;
if data3(CrossDown(ma(c,5),ma(c,30))) Then
d3cross = -1;
if data4(crossup(ma(c,5),ma(c,30))) Then
d4cross = 1;
if data4(CrossDown(ma(c,5),ma(c,30))) Then
d4cross = -1;
if cond1 == true and val1 > val2 and val3 > val3[1] and !(d3cross == -1 and d4cross == -1) Then{
if (count == 0) or
(count >= 1 and MarketPosition == -1 and data5(C) > d5c[BarsSinceEntry]) or
(count >= 1 and MarketPosition == 0 and MarketPosition(1) == 1 and d5c[BarsSinceExit(1)]- d5c[BarsSinceEntry(1)] < 0) or
(count >= 1 and MarketPosition == 0 and MarketPosition(1) == -1 and d5c[BarsSinceEntry(1)]-d5c[BarsSinceExit(1)] < 0) Then
buy("b");
if count >= 1 and MarketPosition == -1 and data5(C) < d5c[BarsSinceEntry] Then
ExitShort();
}
if cond2 == true and val1 < val2 and val3 < val3[1] and !(d3cross == 1 and d4cross == 1) Then{
if (count == 0) or
(count >= 1 and MarketPosition == 1 and data5(C) < d5c[BarsSinceEntry]) or
(count >= 1 and MarketPosition == 0 and MarketPosition(1) == 1 and d5c[BarsSinceExit(1)]- d5c[BarsSinceEntry(1)] < 0) or
(count >= 1 and MarketPosition == 0 and MarketPosition(1) == -1 and d5c[BarsSinceEntry(1)]-d5c[BarsSinceExit(1)] < 0) Then
sell("s");
if count >= 1 and MarketPosition == -1 and data5(C) > d5c[BarsSinceEntry] Then
Exitlong();
}
if MarketPosition == 1 and val3 < val3[1] and cond == false Then
ExitLong("bx");
if MarketPosition == 1 and val2 < val2[1] and cond == true Then
ExitLong("bbx");
if MarketPosition == -1 and val3 > val3[1] and cond == false Then
ExitShort("sx");
if MarketPosition == -1 and val2 > val2[1] and cond == true Then
ExitShort("ssx");
if MarketPosition !=0 Then{
if CrossUp(data5(H),d5c[BarsSinceEntry]+1) Then
ExitLong("bPT1");
if CrossDown(data5(L),d5c[BarsSinceEntry]+1) Then
ExitLong("sPT1");
}
의도와 다르시면 내일 전화주시기 바랍니다.
02-3453-1060
즐거운 하루되세요
> bigdeal 님이 쓴 글입니다.
> 제목 : Re : Re : 감사합니다. 그런데요?
>
감사합니다.
매수, 매도 진입후 수익발생되면 더이상 진입금지하는 수식과
위수식을 옵션에서 사용할 수 있는 수식으로 부탁좀드립니다. 내가 만든수식으로 적용하면 신호가 옵션에서 발생되는 신호와 선물봉에서 나오는 신호가 다릅니다.
감사합니다
bigdeal
2012-01-19 17:23:28
너무바쁘셔서 착오가 있으신것 같아요..^^
이동평균선을 이용한 매수매도식이 아닌데 갑자기 이상한 수식으로 변형되었어요..
처음 고쳐준 수식에서 수익 발생하면 진입금지하도록 하고 옵션에서 사용할수있도록
다시좀 부탁드립니다..
수고하세요..
다음글