커뮤니티

질문드립니다.

프로필 이미지
forexar
2014-10-12 18:15:22
127
글번호 79272
답변완료
1) 첫번째 질문? Inputs: Period1(5), Period2(20),position(1); var : Sma1(0,data2),Sma2(0,data2); Sma1 = data2(ma(C,Period1)); Sma2 = data2(ma(C,Period2)); If crossup(sma1,sma2) then { buy("b",def,position); } If crossdown(sma1,sma2) then { sell("s",def,position); } setstoptrailing(0.1,0.2,pointstop); setstoploss(0.5,pointstop); data1 200틱봉 data2는 1시간봉 위와같이 소스를 만들었습니다. 근데 data2에서 신호를 받아와서 200틱에서 체결시켜서 그런지 crossup(sma1,sma2),crossdown(sma1,sma2) 이 두 상태가 만족이되면 익절이나 손절이후 계속해서 거래가 지속됩니다. 즉, 만약 1시간봉에서 매수신호가 떴다면 다음 매도 신호 전까지 익절 손절 상관없이 계속 매수거래가 이루어집니다. 포지션 청산 후 바로 진입이 이루어지구요. 한번 익절이나 손절이후 다음 신호까지 거래가 안되게 하려면 어떻게 해야할까요? 껐다키면 한번만 거래된 걸로 나오지만 실제로 실시간에선 저렇게 거래가 됩니다. 2) 두번째 질문 위의 문제를 좀더 좋은 방향으로 발전시키고 싶은데요 계속 거래가 지속되게 놔뒀을때 한 시간봉 신호로 첫매수 거래가 익절이라고 가정하고 다음거래가 200틱봉에서 최저점을 경신할때 매수거래가 체결 되게끔하고 매도시에는 반대로 하다 한 번 손절이 후 거래가 멈추고 다시 한시간 봉 신호를 기다리려면 어떻게 바꿔야 될까요?
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2014-10-13 14:58:17

안녕하세요 예스스탁입니다. 1. 문의하신 내용은 매수와 매도가 서로 번갈아 가면서 발생하도록 해야 합니다. Inputs: Period1(5), Period2(20),position(1); var : Sma1(0,data2),Sma2(0,data2); Sma1 = data2(ma(C,Period1)); Sma2 = data2(ma(C,Period2)); if !(MarketPosition == 0 and MarketPosition(1) == 1 ) then { If crossup(sma1,sma2) then { buy("b",def,position); } } if !(MarketPosition == 0 and MarketPosition(1) == -1 ) then { if crossdown(sma1,sma2) then { sell("s",def,position); } } setstoptrailing(0.1,0.2,pointstop); setstoploss(0.5,pointstop); 2. Inputs: Period1(5), Period2(20),position(1); var : Sma1(0,data2),Sma2(0,data2); var : Bcond(false,data1),Scond(false,data1),T(0,data1); var : Bcount(0,data1),Scount(0,data1),HH(0,data1),LL(0,data1); Sma1 = data2(ma(C,Period1)); Sma2 = data2(ma(C,Period2)); #data2 매수조건 매도조건을 data1기준으로 저장 Bcond = crossup(sma1,sma2); Scond = crossup(sma1,sma2); if Bcond == true and Bcond[1] == false Then{ LL = L; T = 1; Bcount = 0; } if Scond == true and Scond[1] == false Then{ HH = L; T = -1; Scount = 0; } #최초 매수조건발생 후 data1 최저가 if T == 1 and L < LL Then LL = L; #최초 매도조건 발생 후 data1 최고가 if T == -1 and H > HH Then HH = H; if MarketPosition == 1 and MarketPosition != MarketPosition[1] Then Bcount = Bcount+1; if MarketPosition == -1 and MarketPosition != MarketPosition[1] Then Scount = Scount+1; If Bcond == true then { if Bcount == 0 Then buy("b1",OnClose,def,position); if Bcount >= 1 and L == LL Then buy("b2",OnClose,def,position); } if Scond == true then { if Scount == 0 then sell("s1",OnClose, def,position); if Scount >= 0 and H == HH then sell("s2",OnClose, def,position); } setstoptrailing(0.1,0.2,pointstop); setstoploss(0.5,pointstop); 즐거운 하루되세요 > forexar 님이 쓴 글입니다. > 제목 : 질문드립니다. > 1) 첫번째 질문? Inputs: Period1(5), Period2(20),position(1); var : Sma1(0,data2),Sma2(0,data2); Sma1 = data2(ma(C,Period1)); Sma2 = data2(ma(C,Period2)); If crossup(sma1,sma2) then { buy("b",def,position); } If crossdown(sma1,sma2) then { sell("s",def,position); } setstoptrailing(0.1,0.2,pointstop); setstoploss(0.5,pointstop); data1 200틱봉 data2는 1시간봉 위와같이 소스를 만들었습니다. 근데 data2에서 신호를 받아와서 200틱에서 체결시켜서 그런지 crossup(sma1,sma2),crossdown(sma1,sma2) 이 두 상태가 만족이되면 익절이나 손절이후 계속해서 거래가 지속됩니다. 즉, 만약 1시간봉에서 매수신호가 떴다면 다음 매도 신호 전까지 익절 손절 상관없이 계속 매수거래가 이루어집니다. 포지션 청산 후 바로 진입이 이루어지구요. 한번 익절이나 손절이후 다음 신호까지 거래가 안되게 하려면 어떻게 해야할까요? 껐다키면 한번만 거래된 걸로 나오지만 실제로 실시간에선 저렇게 거래가 됩니다. 2) 두번째 질문 위의 문제를 좀더 좋은 방향으로 발전시키고 싶은데요 계속 거래가 지속되게 놔뒀을때 한 시간봉 신호로 첫매수 거래가 익절이라고 가정하고 다음거래가 200틱봉에서 최저점을 경신할때 매수거래가 체결 되게끔하고 매도시에는 반대로 하다 한 번 손절이 후 거래가 멈추고 다시 한시간 봉 신호를 기다리려면 어떻게 바꿔야 될까요?