커뮤니티

230812 건

프로필 이미지
목마와숙녀
2026-03-05 16:09:29
47
글번호 230938
답변완료

230812 건 답변 고맙습니다.

강제청산함수를 사용해서 답해주셨으면 합니다.

요즘 1분봉도 길어서 봉완성 후 청산하는 것이 부담스럽습니다.

시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2026-03-06 09:21:18

안녕하세요 예스스탁입니다. 강제청산함수으로는 피라미딩시 진입별로 유지가 가능하지 않습니다. 강제청산은 값이 셋팅되면 모든 진입에 적용됩니다. 매수가 봉완성시에 진입하므로 매수와 함께 손익절도 같이 셋팅을 해서 다음봉에서도 청산될 수 있게 내용을 추가해 드립니다. 다만 트레일링스탑은 봉미완성시에 미완성봉의 고가를 알 수 없어 매수 후 첫봉은 매수가 기준 지정한 포인트 내려가면 청산하게 됩니다. // Data2 기반 피라미딩 전략 (개선된 청산명 식별) Input : MaxPyramids(4), 양봉1(7), 양봉2(3); input : als(500),atr(1000); input : bls(1000),btr(1500); input : cls(1500),ctr(2000); input : dls(2000),dtr(2500); input : eod(151900); Var : entryCount(0), bullCount(0), b1Placed(false); Var : lastEntryName(""); // 마지막 진입명 저장 var : p1(0),p2(0),p3(0),p4(0); var : h1(0),h2(0),h3(0),h4(0); // 새 영업일 초기화 If data2(Bdate) != data2(Bdate[1]) Then { entryCount = 0; bullCount = 0; b1Placed = False; lastEntryName = ""; } // 1) 초회 진입: data1와 data2 영업일 같고 data2 첫 양봉일 때 If MarketPosition == 0 And data1(Bdate) == data2(Bdate) And b1Placed == False And data2(C) > data2(O) Then { Buy("b1", onclose, Def); entryCount = 1; bullCount = 0; b1Placed = True; lastEntryName = "b1"; p1 = c; h1 = p1; ExitLong("bl11",AtStop,p1-als,"b1"); ExitLong("bt11",AtStop,h1-atr,"b1"); } // 2) 피라미딩 로직 (최대 MaxPyramids) If MarketPosition >= 1 Then { // data2 양봉/음봉 카운트 업데이트 If data2(C) > data2(O) Then bullCount = bullCount + 1; // 음봉 발생 시 다음 진입 조건 확인 If data2(C) < data2(O) Then { // 두번째 진입: b1 진입 이후 첫 음봉 If entryCount == 1 And entryCount < MaxPyramids Then { Buy("b2", onclose, Def); entryCount = 2; bullCount = 0; lastEntryName = "b2"; p2 = c; h2 = p2; ExitLong("bl21",AtStop,p2-bls,"b2"); ExitLong("bt21",AtStop,h2-btr,"b2"); } // 세번째 진입: 두번째 진입 후 양봉 양에 따른 진입 Else If entryCount == 2 And entryCount < MaxPyramids And bullCount >= 양봉1 Then { Buy("b3", onclose, Def); entryCount = 3; bullCount = 0; lastEntryName = "b3"; p3 = c; h3 = p3; ExitLong("bl31",AtStop,P3-cls,"b3"); ExitLong("bt31",AtStop,h3-ctr,"b3"); } // 네번째 진입: 세번째 진입 후 양봉 양에 따른 진입 Else If entryCount == 3 And entryCount < MaxPyramids And bullCount >= 양봉2 Then { Buy("b4", onclose, Def); entryCount = 4; bullCount = 0; lastEntryName = "b4"; p4 = c; h4 = p4; ExitLong("bl41",AtStop,P4-dls,"b4"); ExitLong("bt41",AtStop,h4-dtr,"b4"); } } } // 포지션이 없으면 lastEntryName 초기화 If MarketPosition == 0 Then lastEntryName = ""; // 청산(스탑) 설정: 마지막 진입명을 기준으로 적용 If MarketPosition == 1 Then { If MaxEntries > 0 Then { if h1 == 0 or (h1 > 0 and h > h1) Then h1 = h; ExitLong("bl1",AtStop,p1-als,"b1"); ExitLong("bt1",AtStop,h1-atr,"b1"); } If MaxEntries > 1 Then { if h2 == 0 or (h2 > 0 and h > h2) Then h2 = h; ExitLong("bl2",AtStop,p2-bls,"b2"); ExitLong("bt2",AtStop,h2-btr,"b2"); } If MaxEntries > 2 Then { if h3 == 0 or (h3 > 0 and h > h3) Then h3 = h; ExitLong("bl3",AtStop,P3-cls,"b3"); ExitLong("bt3",AtStop,h3-ctr,"b3"); } If MaxEntries > 3 Then { if h4 == 0 or (h4 > 0 and h > h4) Then h4 = h; ExitLong("bl4",AtStop,P4-dls,"b4"); ExitLong("bt4",AtStop,h4-dtr,"b4"); } } Else { h1 = 0; h2 = 0; h3 = 0; h4 = 0; } // 당일 종료(오후 eod에 강제 청산) SetStopEndofday(eod); 즐거운 하루되세요