커뮤니티

참조함수 사용문제..

프로필 이미지
일목초인
2010-09-15 15:41:16
774
글번호 32383
답변완료
아래식은 다음의 조건의 만족하기 위해 샘플로 만들어 본 식입니다. - 조건 - 1. 연결선물지수를 Data2에 참조로 설정하여 매매식 구현 2. BUY1으로 진입한 식은 BUY1 청산식으로만 청산되어야 한다. 3. BUY2으로 진입한 식은 BUY2 청산식으로만 청산되어야 한다. 4. 각각의 매수식은 2개씩 진입하고 청산은 청산식 내용에 따라 1개씩 청산된다. 5. 청산식으로 청산이 안된 진입포지션은 SetStopEndofday에 의해 모두 청산된다. 문제점은 Buy2로 진입한 식도 Buy1청산식으로 청산되어 버립니다. 검토후 수정 부탁드립니다. 항상 감사합니다...^^ SetStopEndofday(140000); // BUY1 if DayIndex()>=0 && DayIndex()<=24 && Data2(C)>Data2(OpenD(0))+0.5 Then { buy("A",OnClose,def,2); Value7 = Data2(C); Var1 = Index; } // BUY2 if DayIndex()>=0 && DayIndex()<=24 && Data2(C)>Data2(OpenD(0))+1 Then { buy("B",OnClose,def,2); Value8 = Data2(C); Var2 = Index; } // BUY1 청산 If IsEntryName("A") then { if Data2(C)>=Value7+0.5 Then ExitLong("Ax1",OnClose,def,"",1,1); if Data2(C)>=Value7+1 Then ExitLong("Ax2",OnClose,def,"",1,1); if Data2(C)<=Value7-0.5 Then ExitLong("Ax3",OnClose,def,"",1,1); if Data2(C)<=Value7-1 Then ExitLong("Ax4",OnClose,def,"",1,1); } // BUY2 청산 If IsEntryName("B") then { if Data2(C)>=Value8+0.5 Then ExitLong("Bx1",OnClose,def,"",1,1); if Data2(C)>=Value8+1 Then ExitLong("Bx2",OnClose,def,"",1,1); if Data2(C)<=Value8-0.5 Then ExitLong("Bx3",OnClose,def,"",1,1); if Data2(C)<=Value8-1 Then ExitLong("Bx4",OnClose,def,"",1,1); }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2010-09-16 17:34:22

안녕하세요 예스스탁입니다. 해당 내용은 참조종목과 관련된 사항이 아닙니다. 진입함수는 피라미딩시에 첫진입의 명칭만을 가져오게 됩니다. A진입--> B진입일 경우 해당 포지션의 시작명칭이 A이므로 IsEntryName은 A만을 리턴하게 됩니다. B진입--> A진입일 경우 해당 포지션의 IsEntryName은 B만을 리턴하게 됩니다. 아래는 수정한 식입니다. var : AXcnt(0),BXcnt(0),AXcond1(0),AXcond2(0),AXcond3(0),AXcond4(0),BXcond1(0),BXcond2(0),BXcond3(0),BXcond4(0); if date != date[1] or MarketPosition == 0 Then{ Condition1 = false; Condition2 = false; Axcnt = 0; Bxcnt = 0; Axcond1 = 0;Axcond2 = 0;Axcond3 = 0;Axcond4 = 0; Bxcond1 = 0;Bxcond2 = 0;Bxcond3 = 0;Bxcond4 = 0; } SetStopEndofday(140000); // BUY1 if DayIndex()>=0 && DayIndex()<=24 && Data2(C)>Data2(OpenD(0))+0.5 and Condition1 == false Then { buy("A",OnClose,def,2); Value7 = Data2(C); Condition1 = true; } // BUY2 if DayIndex()>=0 && DayIndex()<=24 && Data2(C)>Data2(OpenD(0))+1 and Condition2 == false Then { buy("B",OnClose,def,2); Value8 = Data2(C); Condition2 = true; } // BUY1 청산 If MarketPosition == 1 and Condition1 == true then{ AXcnt = AXcond1+AXcond2+Axcond3+Axcond4; if Data2(C)>=Value7+0.5 and Axcnt < 2 and AXcond1 ==0 Then{ ExitLong("Ax1",OnClose,def,"",1,1); AXcond1 = 1; } if Data2(C)>=Value7+1 and Axcnt < 2 and AXcond2 == 0 Then{ ExitLong("Ax2",OnClose,def,"",1,1); AXcond2 = 1; } if Data2(C)<=Value7-0.5 and Axcnt < 2 and AXcond3 == 0 Then{ ExitLong("Ax3",OnClose,def,"",1,1); AXcond3 = 1; } if Data2(C)<=Value7-1 and Axcnt < 2 and AXcond4 == 0 Then{ ExitLong("Ax4",OnClose,def,"",1,1); AXcond4 = 1; } } // BUY2 청산 If MarketPosition == 1 and Condition2 == true then { BXcnt = BXcond1+BXcond2+Bxcond3+Bxcond4; if Data2(C)>=Value8+0.5 and bxcnt < 2 and Bxcond1 == 0 Then { ExitLong("Bx1",OnClose,def,"",1,1); BXcond1 = 1; } if Data2(C)>=Value8+1 and bxcnt < 2 and Bxcond2 == 0 Then{ ExitLong("Bx2",OnClose,def,"",1,1); BXcond2 = 1; } if Data2(C)<=Value8-0.5 and bxcnt < 2 and Bxcond3 == 0 Then { ExitLong("Bx3",OnClose,def,"",1,1); BXcond3 = 1; } if Data2(C)<=Value8-1 and bxcnt < 2 and Bxcond4 == 0 Then { ExitLong("Bx4",OnClose,def,"",1,1); BXcond4 = 1; } } 즐거운 하루되세요 > 일목초인 님이 쓴 글입니다. > 제목 : 참조함수 사용문제.. > 아래식은 다음의 조건의 만족하기 위해 샘플로 만들어 본 식입니다. - 조건 - 1. 연결선물지수를 Data2에 참조로 설정하여 매매식 구현 2. BUY1으로 진입한 식은 BUY1 청산식으로만 청산되어야 한다. 3. BUY2으로 진입한 식은 BUY2 청산식으로만 청산되어야 한다. 4. 각각의 매수식은 2개씩 진입하고 청산은 청산식 내용에 따라 1개씩 청산된다. 5. 청산식으로 청산이 안된 진입포지션은 SetStopEndofday에 의해 모두 청산된다. 문제점은 Buy2로 진입한 식도 Buy1청산식으로 청산되어 버립니다. 검토후 수정 부탁드립니다. 항상 감사합니다...^^ SetStopEndofday(140000); // BUY1 if DayIndex()>=0 && DayIndex()<=24 && Data2(C)>Data2(OpenD(0))+0.5 Then { buy("A",OnClose,def,2); Value7 = Data2(C); Var1 = Index; } // BUY2 if DayIndex()>=0 && DayIndex()<=24 && Data2(C)>Data2(OpenD(0))+1 Then { buy("B",OnClose,def,2); Value8 = Data2(C); Var2 = Index; } // BUY1 청산 If IsEntryName("A") then { if Data2(C)>=Value7+0.5 Then ExitLong("Ax1",OnClose,def,"",1,1); if Data2(C)>=Value7+1 Then ExitLong("Ax2",OnClose,def,"",1,1); if Data2(C)<=Value7-0.5 Then ExitLong("Ax3",OnClose,def,"",1,1); if Data2(C)<=Value7-1 Then ExitLong("Ax4",OnClose,def,"",1,1); } // BUY2 청산 If IsEntryName("B") then { if Data2(C)>=Value8+0.5 Then ExitLong("Bx1",OnClose,def,"",1,1); if Data2(C)>=Value8+1 Then ExitLong("Bx2",OnClose,def,"",1,1); if Data2(C)<=Value8-0.5 Then ExitLong("Bx3",OnClose,def,"",1,1); if Data2(C)<=Value8-1 Then ExitLong("Bx4",OnClose,def,"",1,1); }