커뮤니티

전략식 수정 부탁드립니다.

프로필 이미지
고박사122
2017-09-25 20:52:58
164
글번호 113070
답변완료
안녕하세요 다음 전략식에 추가로 MACD 가 기준선 (>0)을 상향돌파 할때를 매수하고 MACD 가 기준선 (<0)을 하향돌파 할때를 매도하되 각각 처음 생기는 신호만 진입되도록 부탁드립니다. input : 거래시간 (1), 시작시간 (160000), 끝시간 (045000),익절틱수 (20),손절틱수 (10); input : TurnLen1(5), StdLen1(26); input : TurnLen2(9), StdLen2(26); var : 전환선1(0),기준선1(0),전환선2(0),기준선2(0), HH(0), LL(0); 전환선1 = (Highest(H, TurnLen1) + Lowest(L, TurnLen1)) / 2; 기준선1 = (Highest(H, StdLen1) + Lowest(L, StdLen1)) / 2; 전환선2 = (Highest(H, TurnLen2) + Lowest(L, TurnLen2)) / 2; 기준선2 = (Highest(H, StdLen2) + Lowest(L, StdLen2)) / 2; if 거래시간 == 1 then condition3 = (stime>=시작시간 or stime<=끝시간); Else if 거래시간 == 2 then condition3 = (stime>=시작시간 and stime<=끝시간); Else condition3 = true; # 매수/매도청산 If MarketPosition == 0 and TotalTrades == TotalTrades[1] and Condition3 == true and 전환선1 > 기준선2 and C < 전환선1 and C > 기준선2 and C > O and C[1] < O[1] Then Sell(); # 매도/매수청산 If MarketPosition == 0 and TotalTrades == TotalTrades[1] and Condition3 == true and 전환선1 < 기준선2 and C > 전환선1 and C < 기준선2 and C < O and C[1] > O[1] Then Buy(); if MarketPosition == 1 Then{ LL = Floor((highest(H,BarsSinceEntry) - EntryPrice)/(PriceScale*손절틱수 )); ExitLong("bx",AtStop,(EntryPrice-(PriceScale*손절틱수 ))+(PriceScale*손절틱수 )*LL); } if MarketPosition == -1 Then{ HH = Floor((EntryPrice-Lowest(L,BarsSinceEntry))/(PriceScale*손절틱수 )); ExitShort("sx",AtStop,(EntryPrice+(PriceScale*손절틱수))-(PriceScale*손절틱수 )*HH); } SetStopProfittarget(PriceScale*익절틱수,PointStop); if stime == 끝시간 or (stime > 끝시간 and stime[1] < 끝시간 ) Then{ if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2017-09-26 11:27:52

안녕하세요 예스스탁입니다. input : 거래시간 (1), 시작시간 (160000), 끝시간 (045000),익절틱수 (20),손절틱수 (10); input : TurnLen1(5), StdLen1(26); input : TurnLen2(9), StdLen2(26); input : short(12),long(26); var : 전환선1(0),기준선1(0),전환선2(0),기준선2(0), HH(0), LL(0),MACDV(0); 전환선1 = (Highest(H, TurnLen1) + Lowest(L, TurnLen1)) / 2; 기준선1 = (Highest(H, StdLen1) + Lowest(L, StdLen1)) / 2; 전환선2 = (Highest(H, TurnLen2) + Lowest(L, TurnLen2)) / 2; 기준선2 = (Highest(H, StdLen2) + Lowest(L, StdLen2)) / 2; MACDV = MACD(short,long); if 거래시간 == 1 then condition3 = (stime>=시작시간 or stime<=끝시간); Else if 거래시간 == 2 then condition3 = (stime>=시작시간 and stime<=끝시간); Else condition3 = true; # 매수/매도청산 If MarketPosition == 0 and TotalTrades == TotalTrades[1] and Condition3 == true and 전환선1 > 기준선2 and C < 전환선1 and C > 기준선2 and C > O and C[1] < O[1] and CrossDown(MACDV,0) Then Sell(); # 매도/매수청산 If MarketPosition == 0 and TotalTrades == TotalTrades[1] and Condition3 == true and 전환선1 < 기준선2 and C > 전환선1 and C < 기준선2 and C < O and C[1] > O[1] and crossup(MACDV,0) Then Buy(); if MarketPosition == 1 Then{ LL = Floor((highest(H,BarsSinceEntry) - EntryPrice)/(PriceScale*손절틱수 )); ExitLong("bx",AtStop,(EntryPrice-(PriceScale*손절틱수 ))+(PriceScale*손절틱수 )*LL); } if MarketPosition == -1 Then{ HH = Floor((EntryPrice-Lowest(L,BarsSinceEntry))/(PriceScale*손절틱수 )); ExitShort("sx",AtStop,(EntryPrice+(PriceScale*손절틱수))-(PriceScale*손절틱수 )*HH); } SetStopProfittarget(PriceScale*익절틱수,PointStop); if stime == 끝시간 or (stime > 끝시간 and stime[1] < 끝시간 ) Then{ if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } 즐거운 하루되세요 > 고박사122 님이 쓴 글입니다. > 제목 : 전략식 수정 부탁드립니다. > 안녕하세요 다음 전략식에 추가로 MACD 가 기준선 (>0)을 상향돌파 할때를 매수하고 MACD 가 기준선 (<0)을 하향돌파 할때를 매도하되 각각 처음 생기는 신호만 진입되도록 부탁드립니다. input : 거래시간 (1), 시작시간 (160000), 끝시간 (045000),익절틱수 (20),손절틱수 (10); input : TurnLen1(5), StdLen1(26); input : TurnLen2(9), StdLen2(26); var : 전환선1(0),기준선1(0),전환선2(0),기준선2(0), HH(0), LL(0); 전환선1 = (Highest(H, TurnLen1) + Lowest(L, TurnLen1)) / 2; 기준선1 = (Highest(H, StdLen1) + Lowest(L, StdLen1)) / 2; 전환선2 = (Highest(H, TurnLen2) + Lowest(L, TurnLen2)) / 2; 기준선2 = (Highest(H, StdLen2) + Lowest(L, StdLen2)) / 2; if 거래시간 == 1 then condition3 = (stime>=시작시간 or stime<=끝시간); Else if 거래시간 == 2 then condition3 = (stime>=시작시간 and stime<=끝시간); Else condition3 = true; # 매수/매도청산 If MarketPosition == 0 and TotalTrades == TotalTrades[1] and Condition3 == true and 전환선1 > 기준선2 and C < 전환선1 and C > 기준선2 and C > O and C[1] < O[1] Then Sell(); # 매도/매수청산 If MarketPosition == 0 and TotalTrades == TotalTrades[1] and Condition3 == true and 전환선1 < 기준선2 and C > 전환선1 and C < 기준선2 and C < O and C[1] > O[1] Then Buy(); if MarketPosition == 1 Then{ LL = Floor((highest(H,BarsSinceEntry) - EntryPrice)/(PriceScale*손절틱수 )); ExitLong("bx",AtStop,(EntryPrice-(PriceScale*손절틱수 ))+(PriceScale*손절틱수 )*LL); } if MarketPosition == -1 Then{ HH = Floor((EntryPrice-Lowest(L,BarsSinceEntry))/(PriceScale*손절틱수 )); ExitShort("sx",AtStop,(EntryPrice+(PriceScale*손절틱수))-(PriceScale*손절틱수 )*HH); } SetStopProfittarget(PriceScale*익절틱수,PointStop); if stime == 끝시간 or (stime > 끝시간 and stime[1] < 끝시간 ) Then{ if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); }