커뮤니티

익절 수식 오류

프로필 이미지
민현종
2023-04-26 11:17:19
833
글번호 168502
답변완료
다음과 같이 제대로 된 익절수식을 EL1, 2, 3, 4에 넣었습니다. EL1, EL2는 항상 익절인데, EL3, EL4는 손절이 나오기도 합니다. 무슨 문제가 있는걸까요? If COND == 1 Then { Buy("B0", OnClose, Def, 1); EnPrice = C; } If COND == 1 AND MarketPosition > 0 Then { If B_Count > 30 Then { If COND_A == True AND COND_B == True AND COND_C == True Then { Buy("B3", OnClose, Def, 1); EnPrice1 = C; } If COND_A == True AND COND_B == True AND COND_D == True Then { Buy("B4", OnClose, Def, 1); EnPrice2 = C; } } If C > EnPrice*(1+0.03) Then { ExitLong("EL1", OnClose, Def, "B0", 1, 1); } If C > EnPrice*(1+0.06) Then { ExitLong("EL2", OnClose, Def, "B0", 1, 1); } If C > EnPrice1*(1+0.020) Then { ExitLong("EL3", OnClose, Def, "B3", 1, 1); } If C > EnPrice2*(1+0.020) Then { ExitLong("EL4", OnClose, Def, "B4", 1, 1); } }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-04-26 14:35:21

안녕하세요 예스스탁입니다. 변수값이 매수이후 변경이 있는 것 같습니다. 신호는 다른진입신호등으로 지정하면 해당 이름으로 한번만 동작하지만 변수는 지정한 조건만 만족하면 값이 계속 저장이 됩니다. 올려주신 수식이 일부분이라 각 Cond가 false가 되는 내용을 알수 없지만 올려주신 내용으로만 보면 EnPrice1,EnPrice2뿐만아니라 EnPrice값도 이후에 변경이 될수 있습니다. 또한 청산이 완료되면 변수를 초기화하는 내용도 추가하셔야 합니다. If EnPrice == 0 and COND == 1 Then { Buy("B0", OnClose, Def, 1); EnPrice = C; } If COND == 1 AND MarketPosition > 0 Then { If B_Count > 30 Then { If EnPrice1 == 0 and COND_A == True AND COND_B == True AND COND_C == True Then { Buy("B3", OnClose, Def, 1); EnPrice1 = C; } If EnPrice2 == 0 and COND_A == True AND COND_B == True AND COND_D == True Then { Buy("B4", OnClose, Def, 1); EnPrice2 = C; } } If EnPrice > 0 and C > EnPrice*(1+0.03) Then { ExitLong("EL1", OnClose, Def, "B0", 1, 1); EnPrice = 0; } If EnPrice > 0 and C > EnPrice*(1+0.06) Then { ExitLong("EL2", OnClose, Def, "B0", 1, 1); EnPrice = 0; } If EnPrice1 > 0 and C > EnPrice1*(1+0.020) Then { ExitLong("EL3", OnClose, Def, "B3", 1, 1); EnPrice1 = 0; } If EnPrice2 > 0 and C > EnPrice2*(1+0.020) Then { ExitLong("EL4", OnClose, Def, "B4", 1, 1); EnPrice1 = 0; } } if MarketPosition != 1 Then { EnPrice = 0; EnPrice1 = 0; EnPrice2 = 0; } 즐거운 하루되세요 > 민현종 님이 쓴 글입니다. > 제목 : 익절 수식 오류 > 다음과 같이 제대로 된 익절수식을 EL1, 2, 3, 4에 넣었습니다. EL1, EL2는 항상 익절인데, EL3, EL4는 손절이 나오기도 합니다. 무슨 문제가 있는걸까요? If COND == 1 Then { Buy("B0", OnClose, Def, 1); EnPrice = C; } If COND == 1 AND MarketPosition > 0 Then { If B_Count > 30 Then { If COND_A == True AND COND_B == True AND COND_C == True Then { Buy("B3", OnClose, Def, 1); EnPrice1 = C; } If COND_A == True AND COND_B == True AND COND_D == True Then { Buy("B4", OnClose, Def, 1); EnPrice2 = C; } } If C > EnPrice*(1+0.03) Then { ExitLong("EL1", OnClose, Def, "B0", 1, 1); } If C > EnPrice*(1+0.06) Then { ExitLong("EL2", OnClose, Def, "B0", 1, 1); } If C > EnPrice1*(1+0.020) Then { ExitLong("EL3", OnClose, Def, "B3", 1, 1); } If C > EnPrice2*(1+0.020) Then { ExitLong("EL4", OnClose, Def, "B4", 1, 1); } }