커뮤니티

문의드립니다.

프로필 이미지
잡다백수
2019-07-04 08:14:18
288
글번호 130019
답변완료

첨부 이미지

도움주시는 덕분에 도전하고 있습니다. 매번 감사합니다. 1 .기타 이 수식이요. 앞의 질문 2번 수식인데요. 본 수식은 해당 레인지 돌파하면 그 방향 진입하는 거고 수정 요청 드린 건 이전 진입이 수익이면 앞선 진입과 반대 방향 진입, 이전 진입이 손실이면 수식대로 진입하는 내용인데 실행해보니 그냥 이전이 수익이더라도 그 방향으로 가고 아니어도 그 방향으로 가는 것 같습니다. Inputs: InitMin(90); Variables: SessStartMin(0), TradeTime(0), SetHigh(0), SetLow(0), LongFlag(False), ShortFlag(False); #conversion of hour-based time to minute-based time SessStartMin = TimeToMinutes(90000); TradeTime = TimeToMinutes(sTime); input : 진입횟수(1),손절률(1),익절률(1); var : count(0),T1(0); input : 진입시간(90000),제한시간(150000),청산시간(153400),특정수익(3); var : Tcond(false),pl(0),ps(0); SetStopLoss(손절률,PercentStop); SetStopProfittarget(익절률,PercentStop); if (sdate != sdate[1] and stime >= 청산시간) or (sdate == sdate[1] and stime >= 청산시간 and stime[1] < 청산시간) then { Tcond = false; if MarketPosition == 1 Then exitlong(); if MarketPosition == -1 Then ExitShort(); } if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then { Tcond = true; T1 = TotalTrades; } if (sdate != sdate[1] and stime >= 제한시간) or (sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then { Tcond = false; } if MarketPosition == 0 Then count = TotalTrades-T1; Else count = TotalTrades-T1+1; if Count < 진입횟수 and Tcond == true then { #Setup - establishment of the initial range If TradeTime <= SessStartMin + InitMin Then { If Date <> Date[1] Then { SetHigh = High; SetLow = Low; LongFlag = True; ShortFlag = True; } Else { If High > SetHigh Then SetHigh = High; If Low < SetLow Then SetLow = Low; } } Else { #Entries once the initial period has ended if MarketPosition == 0 Then { pl = PositionProfit(1); ps = MarketPosition(1); } Else { pl = PositionProfit(0); ps = MarketPosition(0); } If LongFlag AND CrossUp( Close , SetHigh) Then { if pl <= 0 or (PL > 0 and ps != 1) Then Buy(); } If ShortFlag AND CrossDown(Close , SetLow) Then { if pl <= 0 or (pl > 0 and ps != -1) then Sell(); } } } #Long Protective Exit If MarketPosition == 1 Then { LongFlag = False; ExitLong("",atstop,SetLow ); ExitLong("BS",atlimit,EntryPrice+특정수익 ); } #Short Protective Exit If MarketPosition == -1 Then { ShortFlag = False; ExitShort("",atstop,SetHigh ); ExitShort("SB",atlimit,EntryPrice-특정수익 ); } input: TsValue(80); var: Hvalue(0),Lvalue(0); If MarketPosition() == 1 Then { Hvalue = Highest(H,BarsSinceEntry+1); ExitLong("trailstop_EL", Atstop, Hvalue-TsValue*PriceScale); } If MarketPosition() == -1 Then { Lvalue = Lowest(L,BarsSinceEntry+1); ExitShort("trailStop_Es", Atstop, Lvalue + TsValue*PriceScale); } 2. 궁금해서 그러는데요. 작성해주신 2번 전략은 정확히 어떻게 작동하는 건가요? 본 전략이랑 성과가 다르긴 한 것 같은데 차트만 봐서는 뭐가 다른지 잘 모르겠습니다. if pl <= 0 or (PL > 0 and ps != 1) Then Buy(); 여기로 이전 수익이랑 마켓 포지션 나누어 놓은 것 같기는 한데요. 정확히 어떻게 작동하는지 궁금합니다. 3. 앞선 질문의 3번 전략도요. 제가 보기엔 진입횟수도 적고 뭔가 제가 생각한 방향으로 안 나왔습니다. 첨부파일 2와 같은 것처럼 진입하게 하고 싶었거든요. 4. 1번 수식도 본수식(특정시간 인트라데이 돌파전략)의 매수 매도 조건을 만약 이전 수익이 특정 수익이상일 때 반대로 (원래 buy 수식이면 sell로, 그러니까 원래는 정방향 진입인데 특정 수익이 발생한 다음 매매에서는 역방향 진입)하는 거였는데 트레일링 스탑에만 있네요. 글로 어설프게 쓰다보니 설명을 잘 못하는 듯 합니다. 수식 도움 좀 부탁드립니다.
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2019-07-04 10:46:12

안녕하세요 예스스탁입니다. 1 Inputs: InitMin(90); Variables: SessStartMin(0), TradeTime(0), SetHigh(0), SetLow(0), LongFlag(False), ShortFlag(False); #conversion of hour-based time to minute-based time SessStartMin = TimeToMinutes(90000); TradeTime = TimeToMinutes(sTime); input : 진입횟수(1),손절률(1),익절률(1); var : count(0),T1(0); input : 진입시간(90000),제한시간(150000),청산시간(153400),특정수익(3); var : Tcond(false),pl(0),ps(0); SetStopLoss(손절률,PercentStop); SetStopProfittarget(익절률,PercentStop); if (sdate != sdate[1] and stime >= 청산시간) or (sdate == sdate[1] and stime >= 청산시간 and stime[1] < 청산시간) then { Tcond = false; if MarketPosition == 1 Then exitlong(); if MarketPosition == -1 Then ExitShort(); } if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then { Tcond = true; T1 = TotalTrades; } if (sdate != sdate[1] and stime >= 제한시간) or (sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then { Tcond = false; } if MarketPosition == 0 Then count = TotalTrades-T1; Else count = TotalTrades-T1+1; if Count < 진입횟수 and Tcond == true then { #Setup - establishment of the initial range If TradeTime <= SessStartMin + InitMin Then { If Date <> Date[1] Then { SetHigh = High; SetLow = Low; LongFlag = True; ShortFlag = True; } Else { If High > SetHigh Then SetHigh = High; If Low < SetLow Then SetLow = Low; } } Else { #Entries once the initial period has ended if MarketPosition == 0 Then { pl = PositionProfit(1); ps = MarketPosition(1); } Else { pl = PositionProfit(0); ps = MarketPosition(0); } If LongFlag AND CrossUp( Close , SetHigh) Then { if pl <= 0 Then Buy(); Else sell(); } If ShortFlag AND CrossDown(Close , SetLow) Then { if pl <= 0 then Sell(); Else buy(); } } } #Long Protective Exit If MarketPosition == 1 Then Begin LongFlag = False; ExitLong("",atstop,SetLow ); sell("BS",atlimit,EntryPrice+특정수익 ); End; #Short Protective Exit If MarketPosition == -1 Then Begin ShortFlag = False; ExitShort("",atstop,SetHigh ); buy("SB",atlimit,EntryPrice-특정수익 ); End; input: TsValue(80); var: Hvalue(0),Lvalue(0); If MarketPosition() == 1 Then { Hvalue = Highest(H,BarsSinceEntry+1); ExitLong("trailstop_EL", Atstop, Hvalue-TsValue*PriceScale); } If MarketPosition() == -1 Then { Lvalue = Lowest(L,BarsSinceEntry+1); ExitShort("trailStop_Es", Atstop, Lvalue + TsValue*PriceScale); } 2 이전 답변드린 수식에 보시며 아래 내용이 있습니다. if MarketPosition == 0 Then { pl = PositionProfit(1); ps = MarketPosition(1); } Else { pl = PositionProfit(0); ps = MarketPosition(0); } 현재 무포지션이면 pl에 진전거래의 손익을, ps에는 포지션 방향을 저장합니다. 현재 포지션진행중이면(스위칭될 경우 대비) pl에는 현재 진행중인 거래의 손익을 ps에는 현재 포지션의 방향을 저장합니다. 이후에 If LongFlag AND CrossUp( Close , SetHigh) Then { if pl <= 0 or (PL > 0 and ps != 1) Then Buy(); } If ShortFlag AND CrossDown(Close , SetLow) Then { if pl <= 0 or (pl > 0 and ps != -1) then Sell(); } 매수조건 충족시에 pl이 0이하(손실) 이거나 수익이면 직전거래가 반대방향일때만 매수진입 매수조건 충족시에 pl이 0이하(손실) 이거나 수익이면 직전거래가 반대방향일때만 매도진입 하는 내용이었습니다. 직전거래 포지션과 손익에 따라 매수나 매도진입을 할것인가 말것인가를 지정한 내용이었습니다. 3 기존2번식에 해당 내용을 추가했습니다. 1번식에 해당 내용을 추가했습니다. Inputs: InitMin(90); Variables: SessStartMin(0), TradeTime(0), SetHigh(0), SetLow(0), LongFlag(False), ShortFlag(False); #conversion of hour-based time to minute-based time SessStartMin = TimeToMinutes(90000); TradeTime = TimeToMinutes(sTime); input : 진입횟수(1),손절률(1),익절률(1); var : count(0),T1(0); input : 진입시간(90000),제한시간(150000),청산시간(153400),특정수익(3),n(5); var : Tcond(false),pl(0),ps(0),T(0),S(0); SetStopLoss(손절률,PercentStop); SetStopProfittarget(익절률,PercentStop); if (sdate != sdate[1] and stime >= 청산시간) or (sdate == sdate[1] and stime >= 청산시간 and stime[1] < 청산시간) then { Tcond = false; if MarketPosition == 1 Then exitlong(); if MarketPosition == -1 Then ExitShort(); } if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then { Tcond = true; T1 = TotalTrades; } if (sdate != sdate[1] and stime >= 제한시간) or (sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then { Tcond = false; } if MarketPosition == 0 Then count = TotalTrades-T1; Else count = TotalTrades-T1+1; if Count < 진입횟수 and Tcond == true then { #Setup - establishment of the initial range If TradeTime <= SessStartMin + InitMin Then { If Date <> Date[1] Then { SetHigh = High; SetLow = Low; LongFlag = True; ShortFlag = True; } Else { If High > SetHigh Then SetHigh = High; If Low < SetLow Then SetLow = Low; } } Else { #Entries once the initial period has ended if MarketPosition == 0 Then { pl = PositionProfit(1); ps = MarketPosition(1); } Else { pl = PositionProfit(0); ps = MarketPosition(0); } If LongFlag AND CrossUp( Close , SetHigh) Then { T = 1; S = H-PriceScale*n; } If ShortFlag AND CrossDown(Close , SetLow) Then { T = -1; S = L-PriceScale*n; } if T == 1 Then Buy("b",atlimit,S); if T == -1 Then sell("s",atlimit,S); } } #Long Protective Exit If MarketPosition == 1 Then Begin LongFlag = False; ExitLong("",atstop,SetLow ); sell("BS",atlimit,EntryPrice+특정수익 ); End; #Short Protective Exit If MarketPosition == -1 Then Begin ShortFlag = False; ExitShort("",atstop,SetHigh ); buy("SB",atlimit,EntryPrice-특정수익 ); End; input: TsValue(80); var: Hvalue(0),Lvalue(0); If MarketPosition() == 1 Then { Hvalue = Highest(H,BarsSinceEntry+1); ExitLong("trailstop_EL", Atstop, Hvalue-TsValue*PriceScale); } If MarketPosition() == -1 Then { Lvalue = Lowest(L,BarsSinceEntry+1); ExitShort("trailStop_Es", Atstop, Lvalue + TsValue*PriceScale); } 4 1번 수식의 일정수익시 반대방향 진입이 청산으로 되어 있어 수정했습니다. Inputs: InitMin(90); Variables: SessStartMin(0), TradeTime(0), SetHigh(0), SetLow(0), LongFlag(False), ShortFlag(False); #conversion of hour-based time to minute-based time SessStartMin = TimeToMinutes(90000); TradeTime = TimeToMinutes(sTime); input : 진입횟수(1),손절률(1),익절률(1); var : count(0),T1(0); input : 진입시간(90000),제한시간(150000),청산시간(153400),특정수익(3); var : Tcond(false); SetStopLoss(손절률,PercentStop); SetStopProfittarget(익절률,PercentStop); if (sdate != sdate[1] and stime >= 청산시간) or (sdate == sdate[1] and stime >= 청산시간 and stime[1] < 청산시간) then { Tcond = false; if MarketPosition == 1 Then exitlong(); if MarketPosition == -1 Then ExitShort(); } if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then { Tcond = true; T1 = TotalTrades; } if (sdate != sdate[1] and stime >= 제한시간) or (sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then { Tcond = false; } if MarketPosition == 0 Then count = TotalTrades-T1; Else count = TotalTrades-T1+1; if Count < 진입횟수 and Tcond == true then { #Setup - establishment of the initial range If TradeTime <= SessStartMin + InitMin Then { If Date <> Date[1] Then { SetHigh = High; SetLow = Low; LongFlag = True; ShortFlag = True; } Else { If High > SetHigh Then SetHigh = High; If Low < SetLow Then SetLow = Low; } } Else { #Entries once the initial period has ended If LongFlag AND CrossUp( Close , SetHigh) Then { Buy(); } If ShortFlag AND CrossDown(Close , SetLow) Then { Sell(); } } } #Long Protective Exit If MarketPosition == 1 Then Begin LongFlag = False; ExitLong("",atstop,SetLow ); sell("BS",atlimit,EntryPrice+특정수익 ); End; #Short Protective Exit If MarketPosition == -1 Then Begin ShortFlag = False; ExitShort("",atstop,SetHigh ); buy("SB",atlimit,EntryPrice-특정수익 ); End; input: TsValue(80); var: Hvalue(0),Lvalue(0); If MarketPosition() == 1 Then { Hvalue = Highest(H,BarsSinceEntry+1); ExitLong("trailstop_EL", Atstop, Hvalue-TsValue*PriceScale); } If MarketPosition() == -1 Then { Lvalue = Lowest(L,BarsSinceEntry+1); ExitShort("trailStop_Es", Atstop, Lvalue + TsValue*PriceScale); } 즐거운 하루되세요 > 잡다백수 님이 쓴 글입니다. > 제목 : 문의드립니다. > 도움주시는 덕분에 도전하고 있습니다. 매번 감사합니다. 1 .기타 이 수식이요. 앞의 질문 2번 수식인데요. 본 수식은 해당 레인지 돌파하면 그 방향 진입하는 거고 수정 요청 드린 건 이전 진입이 수익이면 앞선 진입과 반대 방향 진입, 이전 진입이 손실이면 수식대로 진입하는 내용인데 실행해보니 그냥 이전이 수익이더라도 그 방향으로 가고 아니어도 그 방향으로 가는 것 같습니다. Inputs: InitMin(90); Variables: SessStartMin(0), TradeTime(0), SetHigh(0), SetLow(0), LongFlag(False), ShortFlag(False); #conversion of hour-based time to minute-based time SessStartMin = TimeToMinutes(90000); TradeTime = TimeToMinutes(sTime); input : 진입횟수(1),손절률(1),익절률(1); var : count(0),T1(0); input : 진입시간(90000),제한시간(150000),청산시간(153400),특정수익(3); var : Tcond(false),pl(0),ps(0); SetStopLoss(손절률,PercentStop); SetStopProfittarget(익절률,PercentStop); if (sdate != sdate[1] and stime >= 청산시간) or (sdate == sdate[1] and stime >= 청산시간 and stime[1] < 청산시간) then { Tcond = false; if MarketPosition == 1 Then exitlong(); if MarketPosition == -1 Then ExitShort(); } if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) then { Tcond = true; T1 = TotalTrades; } if (sdate != sdate[1] and stime >= 제한시간) or (sdate == sdate[1] and stime >= 제한시간 and stime[1] < 제한시간) then { Tcond = false; } if MarketPosition == 0 Then count = TotalTrades-T1; Else count = TotalTrades-T1+1; if Count < 진입횟수 and Tcond == true then { #Setup - establishment of the initial range If TradeTime <= SessStartMin + InitMin Then { If Date <> Date[1] Then { SetHigh = High; SetLow = Low; LongFlag = True; ShortFlag = True; } Else { If High > SetHigh Then SetHigh = High; If Low < SetLow Then SetLow = Low; } } Else { #Entries once the initial period has ended if MarketPosition == 0 Then { pl = PositionProfit(1); ps = MarketPosition(1); } Else { pl = PositionProfit(0); ps = MarketPosition(0); } If LongFlag AND CrossUp( Close , SetHigh) Then { if pl <= 0 or (PL > 0 and ps != 1) Then Buy(); } If ShortFlag AND CrossDown(Close , SetLow) Then { if pl <= 0 or (pl > 0 and ps != -1) then Sell(); } } } #Long Protective Exit If MarketPosition == 1 Then { LongFlag = False; ExitLong("",atstop,SetLow ); ExitLong("BS",atlimit,EntryPrice+특정수익 ); } #Short Protective Exit If MarketPosition == -1 Then { ShortFlag = False; ExitShort("",atstop,SetHigh ); ExitShort("SB",atlimit,EntryPrice-특정수익 ); } input: TsValue(80); var: Hvalue(0),Lvalue(0); If MarketPosition() == 1 Then { Hvalue = Highest(H,BarsSinceEntry+1); ExitLong("trailstop_EL", Atstop, Hvalue-TsValue*PriceScale); } If MarketPosition() == -1 Then { Lvalue = Lowest(L,BarsSinceEntry+1); ExitShort("trailStop_Es", Atstop, Lvalue + TsValue*PriceScale); } 2. 궁금해서 그러는데요. 작성해주신 2번 전략은 정확히 어떻게 작동하는 건가요? 본 전략이랑 성과가 다르긴 한 것 같은데 차트만 봐서는 뭐가 다른지 잘 모르겠습니다. if pl <= 0 or (PL > 0 and ps != 1) Then Buy(); 여기로 이전 수익이랑 마켓 포지션 나누어 놓은 것 같기는 한데요. 정확히 어떻게 작동하는지 궁금합니다. 3. 앞선 질문의 3번 전략도요. 제가 보기엔 진입횟수도 적고 뭔가 제가 생각한 방향으로 안 나왔습니다. 첨부파일 2와 같은 것처럼 진입하게 하고 싶었거든요. 4. 1번 수식도 본수식(특정시간 인트라데이 돌파전략)의 매수 매도 조건을 만약 이전 수익이 특정 수익이상일 때 반대로 (원래 buy 수식이면 sell로, 그러니까 원래는 정방향 진입인데 특정 수익이 발생한 다음 매매에서는 역방향 진입)하는 거였는데 트레일링 스탑에만 있네요. 글로 어설프게 쓰다보니 설명을 잘 못하는 듯 합니다. 수식 도움 좀 부탁드립니다.