커뮤니티

문의드립니다.

프로필 이미지
양치기
2014-11-02 20:58:58
182
글번호 79992
답변완료

첨부 이미지

항상 도움 주셔서 감사합니다. 스탑로스에 대해 문의 드립니다. 문1) 일단 정상적으로 매수 매도 청산 로직에 맨 하단에 스탑로스를 코딩하였습니다. 스탑로스 코딩 위치는 상단 또는 중간에 코딩 해도 되나요? 아니면 보통 맨 하단에 코딩하는게 맞나요? 문2) 매수, 매도 청산이 "목표수익청산" 청산 이후 재진입은 스탑로스 폭을 다르게 하고 싶습니다. if 문을 사용해서 다르게 스탑로스가 가능한가요? 문3) 스탑로스 대신에 가격조건으로 스탑로스를 하려고 했지만 어떻게 해야할지 모르겠습니다. 이 부분에 대한 오류 수정 부탁드립니다. 예문 참조 부탁드립니다. 좋은 아이디어 부탁드립니다. 문4) 해외 통화선물인데 시간설정에 대해 청산이 되지 않습니다. 성능보고서 상에는 당일 청산이 되어 있는데 실제로는 청산이 안되었습니다. 또 11월1일(토요일) 새벽에는 성능보고서 뿐만 아니라 실제 청산 자체가 안되었습니다. 거래종목은 유로FX입니다. 왜 그런것일까요? 예문) 거래종목:유로FX매매 시간: 7시부터~익일 6시까지 거래계약수 : 1계약 input : 손절(20), 수익(20) ,재진입손절(10), 재진입수익(10); var : 이평5(0), 이평10(0), 이평20(0) ; 이평5 = ma(c,5); 이평10 = ma(c,10); 이평20 = ma(c,20); #거래시간 if sTime >= 070000 or stime < 060000 Then { # 매매 if MarketPosition == 0 then # 매수 if crossup(이평5,이평10) then buy("buy"); if MarketPosition == 0 and isexitname("StopProfitTarget") == true then # 매수재진입 if crossup(이평5,이평20) then buy("buy2"); if MarketPosition == 1 then # 매수청산 if crossdown(이평5,이평10) then exitlong("ext"); if MarketPosition == 1 and IsEntryName("buy2") == true then #재진입청산 ExitShort("buy_Loss",AtStop,EntryPrice-PriceScale*10); # 이부분이 로직오류 ExitShort("buy_profit",AtStop,EntryPrice+PriceScale*10); if crossdown(이평5,이평20) then exitlong("ext2"); ------------------------------------------------------------------------------- if MarketPosition == 0 then # 매도 if crossdown(이평5,이평10) then sell("sell"); if MarketPosition == 0 and isexitname("StopProfitTarget") == true then # 매도재진입 if crossdown(이평5,이평20) then sell("sell2"); if MarketPosition == -1 then # 매도청산 if crossup(이평5,이평10) then exitshort("out"); if MarketPosition == -1 and IsEntryName("sell2") == true then #재진입청산 ExitShort("sell_Loss",AtStop,EntryPrice+PriceScale*10); # 이부분 로직오류 ExitShort("sell_profit",AtStop,EntryPrice-PriceScale*10); if crossdown(이평5,이평20) then exitlong("out2"); # 거래시간 종료 } # 포지션 청산 if stime == 060000 or (stime > 060000 and stime[1] < 060000) Then{ ExitLong("매수청산"); ExitShort("매도청산"); } # 스탑로스 SetStopProfittarget(수익,PointStop); SetStopLoss(손절,PointStop); # 프로그램 중간에 재진입 청산로직이 생각이 안나서 맨하단에 스탑로스를 다르게 코딩해 보았습니다. if isentryname("buy2") == true or isentryname("sell2") == true then{ SetStopProfittarget(10,PointStop); SetStopLoss(10,PointStop); { else { SetStopProfittarget(20,PointStop); SetStopLoss(20,PointStop); } 문5) 스탑로스를 위와 같이 코딩하는게 맞는지요? if문 사용시 스탑로스가 미치는 범위는 어디까지 인가요? 문6) 재진입 청산로직에 대해 아래와 같이 가격조건으로 청산하거나 스탑로스 if문을 써서 재진입은 다르게 스탑로스 하고 싶습니다. 아랜) ExitShort("SLoss",AtStop,EntryPrice-PriceScale*10); ExitShort("Sprof",AtStop,EntryPrice+PriceScale*10); 문7) 위 예문에 대해 로직이나 플로우에 틀린부분이 있으면 수정 부탁드립니다. 한번에 많은 질문을 드려 죄송합니다. 도움 부탁드립니다.
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2014-11-03 15:14:43

안녕하세요 예스스탁입니다. 1. 위치는 관계없습니다. 원하시는 위치에 지정해 주시면 됩니다. 2. 아래 수식 참고하시기 바랍니다. #거래종목:유로FX매매 #시간: 7시부터~익일 6시까지 #거래계약수 : 1계약 input : 손절(20), 수익(20) ,재진입손절(10), 재진입수익(10); var : 이평5(0), 이평10(0), 이평20(0) ; 이평5 = ma(c,5); 이평10 = ma(c,10); 이평20 = ma(c,20); #거래시간 if sTime >= 070000 or stime < 055000 Then { # 매매 if MarketPosition == 0 then # 매수 if crossup(이평5,이평10) then buy("buy"); if MarketPosition == 0 and isexitname("StopProfitTarget",1) == true then # 매수재진입 if crossup(이평5,이평20) then buy("buy2"); if MarketPosition == 1 then # 매수청산 if crossdown(이평5,이평10) then exitlong("ext"); if crossdown(이평5,이평20) then exitlong("ext2"); #------------------------------------------------------------------------------- if MarketPosition == 0 then # 매도 if crossdown(이평5,이평10) then sell("sell"); if MarketPosition == 0 and isexitname("StopProfitTarget",1) == true then # 매도재진입 if crossdown(이평5,이평20) then sell("sell2"); if MarketPosition == -1 then # 매도청산 if crossup(이평5,이평10) then exitshort("out"); if crossdown(이평5,이평20) then exitlong("out2"); # 거래시간 종료 } # 포지션 청산 if stime == 055000 or (stime > 055000 and stime[1] < 055000) Then{ ExitLong("매수청산"); ExitShort("매도청산"); } if isentryname("buy2") == true or isentryname("sell2") == true then{ SetStopProfittarget(10,PointStop); SetStopLoss(10,PointStop); { else { SetStopProfittarget(20,PointStop); SetStopLoss(20,PointStop); } 3. 강제청산 함수를 제외하고 가격조건을 주어 구현한 식입니다. 참고하시기 바랍니다. input : 손절(20), 수익(20) ,재진입손절(10), 재진입수익(10); var : 이평5(0), 이평10(0), 이평20(0) ; 이평5 = ma(c,5); 이평10 = ma(c,10); 이평20 = ma(c,20); #거래시간 if sTime >= 070000 or stime < 055000 Then { # 매매 if MarketPosition == 0 then # 매수 if crossup(이평5,이평10) then buy("buy"); if MarketPosition == 0 and isexitname("StopProfitTarget",1) == true then # 매수재진입 if crossup(이평5,이평20) then buy("buy2"); if MarketPosition == 1 then # 매수청산 if crossdown(이평5,이평10) then exitlong("ext"); if MarketPosition == 1 and IsEntryName("buy") == true then{ ExitLong("BProfit1",atlimit,EntryPrice+PriceScale*20); ExitLong("BLoss1",atlimit,EntryPrice-PriceScale*20); } if MarketPosition == 1 and IsEntryName("buy2") == true then{ ExitLong("BProfit2",atlimit,EntryPrice+PriceScale*10); ExitLong("BLoss2",atlimit,EntryPrice-PriceScale*10); } if crossdown(이평5,이평20) then exitlong("ext2"); #------------------------------------------------------------------------------- if MarketPosition == 0 then # 매도 if crossdown(이평5,이평10) then sell("sell"); if MarketPosition == 0 and isexitname("StopProfitTarget",1) == true then # 매도재진입 if crossdown(이평5,이평20) then sell("sell2"); if MarketPosition == -1 and IsEntryName("sell") == true then{ ExitShort("SProfit1",atlimit,EntryPrice-PriceScale*20); ExitShort("SLoss1",atlimit,EntryPrice+PriceScale*20); } if MarketPosition == -1 and IsEntryName("sell2") == true then{ ExitShort("SProfit2",atlimit,EntryPrice-PriceScale*10); ExitShort("sLoss2",atlimit,EntryPrice+PriceScale*10); } if MarketPosition == -1 then # 매도청산 if crossup(이평5,이평10) then exitshort("out"); if crossdown(이평5,이평20) then exitlong("out2"); # 거래시간 종료 } # 포지션 청산 if stime == 055000 or (stime > 055000 and stime[1] < 055000) Then{ ExitLong("매수청산"); ExitShort("매도청산"); } 4. 해외선물에서 시간으로 청산을 하실 때 아래 지표식 적용해서 시간 확인하시기 바랍니다. plot1(stime); 차트가 한국시간일때 유로fx의 경우 6시 봉이 없습니다. 그러므로 6시 다음봉인 7시 봉에 청산신호가 발생하게 됩니다. 차트에 마우스로 클릭할때의 시간과 랭귀지에서 사용하는 시간이 다릅니다. 수식에서는 stime을 이용하게 되므로 위 지표로 시간확인하셔야 합니다. 사용하시는 차트 주기에서 위 지표로 시간 확인하시고 시간지정해 주셔야 합니다. 또한 if문은 봉완성시에 주문이 집행됩니다. 봉완성은 다음봉 시가가 수신될때 이므로 차트가 1분봉이면 055900으로 지정하시면 해당 봉완성인 다음봉 7시봉시가에 주문이 되고 055800으로 지정하시면 05시59분봉 시가에 청산이 됩니다. 위식에는 넉넉히 5시55분봉에 청산이 되게 수정했습니다. 5. if문으로 조건을 지정해 주므로 기존에 올리신 식에서 # 스탑로스 SetStopProfittarget(수익,PointStop); SetStopLoss(손절,PointStop); 부분은 삭제하시면 됩니다. 6. 2번,3번 답변 참고하시기 바랍니다. 7. 직전 청산의 명칭을 조건으로 지정할때 isexitname을 사용하는데 두번째 매개변수는 가장 작은 값이 1입니다. isexitname("StopProfitTarget",1) == true --> X isexitname("StopProfitTarget",1) == true --> O 즐거운 하루되세요 > 양치기 님이 쓴 글입니다. > 제목 : 문의드립니다. > 항상 도움 주셔서 감사합니다. 스탑로스에 대해 문의 드립니다. 문1) 일단 정상적으로 매수 매도 청산 로직에 맨 하단에 스탑로스를 코딩하였습니다. 스탑로스 코딩 위치는 상단 또는 중간에 코딩 해도 되나요? 아니면 보통 맨 하단에 코딩하는게 맞나요? 문2) 매수, 매도 청산이 "목표수익청산" 청산 이후 재진입은 스탑로스 폭을 다르게 하고 싶습니다. if 문을 사용해서 다르게 스탑로스가 가능한가요? 문3) 스탑로스 대신에 가격조건으로 스탑로스를 하려고 했지만 어떻게 해야할지 모르겠습니다. 이 부분에 대한 오류 수정 부탁드립니다. 예문 참조 부탁드립니다. 좋은 아이디어 부탁드립니다. 문4) 해외 통화선물인데 시간설정에 대해 청산이 되지 않습니다. 성능보고서 상에는 당일 청산이 되어 있는데 실제로는 청산이 안되었습니다. 또 11월1일(토요일) 새벽에는 성능보고서 뿐만 아니라 실제 청산 자체가 안되었습니다. 거래종목은 유로FX입니다. 왜 그런것일까요? 예문) 거래종목:유로FX매매 시간: 7시부터~익일 6시까지 거래계약수 : 1계약 input : 손절(20), 수익(20) ,재진입손절(10), 재진입수익(10); var : 이평5(0), 이평10(0), 이평20(0) ; 이평5 = ma(c,5); 이평10 = ma(c,10); 이평20 = ma(c,20); #거래시간 if sTime >= 070000 or stime < 060000 Then { # 매매 if MarketPosition == 0 then # 매수 if crossup(이평5,이평10) then buy("buy"); if MarketPosition == 0 and isexitname("StopProfitTarget") == true then # 매수재진입 if crossup(이평5,이평20) then buy("buy2"); if MarketPosition == 1 then # 매수청산 if crossdown(이평5,이평10) then exitlong("ext"); if MarketPosition == 1 and IsEntryName("buy2") == true then #재진입청산 ExitShort("buy_Loss",AtStop,EntryPrice-PriceScale*10); # 이부분이 로직오류 ExitShort("buy_profit",AtStop,EntryPrice+PriceScale*10); if crossdown(이평5,이평20) then exitlong("ext2"); ------------------------------------------------------------------------------- if MarketPosition == 0 then # 매도 if crossdown(이평5,이평10) then sell("sell"); if MarketPosition == 0 and isexitname("StopProfitTarget") == true then # 매도재진입 if crossdown(이평5,이평20) then sell("sell2"); if MarketPosition == -1 then # 매도청산 if crossup(이평5,이평10) then exitshort("out"); if MarketPosition == -1 and IsEntryName("sell2") == true then #재진입청산 ExitShort("sell_Loss",AtStop,EntryPrice+PriceScale*10); # 이부분 로직오류 ExitShort("sell_profit",AtStop,EntryPrice-PriceScale*10); if crossdown(이평5,이평20) then exitlong("out2"); # 거래시간 종료 } # 포지션 청산 if stime == 060000 or (stime > 060000 and stime[1] < 060000) Then{ ExitLong("매수청산"); ExitShort("매도청산"); } # 스탑로스 SetStopProfittarget(수익,PointStop); SetStopLoss(손절,PointStop); # 프로그램 중간에 재진입 청산로직이 생각이 안나서 맨하단에 스탑로스를 다르게 코딩해 보았습니다. if isentryname("buy2") == true or isentryname("sell2") == true then{ SetStopProfittarget(10,PointStop); SetStopLoss(10,PointStop); { else { SetStopProfittarget(20,PointStop); SetStopLoss(20,PointStop); } 문5) 스탑로스를 위와 같이 코딩하는게 맞는지요? if문 사용시 스탑로스가 미치는 범위는 어디까지 인가요? 문6) 재진입 청산로직에 대해 아래와 같이 가격조건으로 청산하거나 스탑로스 if문을 써서 재진입은 다르게 스탑로스 하고 싶습니다. 아랜) ExitShort("SLoss",AtStop,EntryPrice-PriceScale*10); ExitShort("Sprof",AtStop,EntryPrice+PriceScale*10); 문7) 위 예문에 대해 로직이나 플로우에 틀린부분이 있으면 수정 부탁드립니다. 한번에 많은 질문을 드려 죄송합니다. 도움 부탁드립니다.