커뮤니티

재질문입니다

프로필 이미지
noriter
2013-03-20 10:15:08
176
글번호 60962
답변완료
Input : af(0.02), maxAF(0.2) ; Var : value(0),entryP1(0),entryP2(0),entryP3(0),h1(0),h2(0),h3(0); value = csar(af,maxAF); If MarketPosition == 0 and crossup(C,value)Then{ Buy("b1"); entryP1 = C; h1 = H; } if MarketPosition == 1 Then{ if CurrentEntries == 1 and C >= H[1]*1.03 Then{ buy("b2",OnClose,def,CurrentContracts*2); entryP2 = C; H2 = H; } if CurrentEntries == 2 and C >= H[1]*1.03 Then{ buy("b3",OnClose,def,CurrentContracts*3); entryP3 = C; h3 = H; } if H > h1 Then h1 = H; if H > h2 Then h2 = h; if H > h3 Then h3 = h; if C < value Then ExitLong(); if MaxEntries >= 1 Then{ exitlong("손절1",AtStop,entryp1*0.9,"b1"); if h1 >= entryP1*1.05 Then ExitLong("tr1",AtStop,h1*0.96,"b1"); } if MaxEntries >= 2 Then{ exitlong("손절2",AtStop,entryp2*0.95,"b2"); if h2 >= entryP2*1.03 Then ExitLong("tr2",AtStop,h1*0.98,"b2"); } if MaxEntries >= 3 Then{ exitlong("손절3",AtStop,entryp3*0.97,"b3"); if h3 >= entryP3*1.02 Then ExitLong("tr3",AtStop,h1*0.99,"b3"); } } 손절1,2,3은 잘 발동 하는듯하나 tr1,2,3은 제대로 적용이 안됩니다 무엇이 문제인지 잘 모르겠어요..수정 좀 부탁드립니다
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2013-03-20 13:58:11

안녕하세요 예스스탁입니다. 식을 수정했습니다. Input : af(0.02), maxAF(0.2) ; Var : value(0),entryP1(0),entryP2(0),entryP3(0),h1(0),h2(0),h3(0); value = csar(af,maxAF); If MarketPosition == 0 and crossup(C,value)Then{ Buy("b1"); entryP1 = C; h1 = H; } if MarketPosition == 1 Then{ if CurrentEntries == 1 and C >= H[1]*1.03 Then{ buy("b2",OnClose,def,CurrentContracts*2); entryP2 = C; H2 = H; } if CurrentEntries == 2 and C >= H[1]*1.03 Then{ buy("b3",OnClose,def,CurrentContracts*3); entryP3 = C; h3 = H; } if H > h1 Then h1 = H; if H > h2 Then h2 = h; if H > h3 Then h3 = h; if C < value Then ExitLong(); if MaxEntries >= 1 Then{ exitlong("손절1",AtStop,entryp1*0.9,"b1"); if h1 >= entryP1*1.05 Then ExitLong("tr1",AtStop,h1*0.96,"b1"); } if MaxEntries >= 2 Then{ exitlong("손절2",AtStop,entryp2*0.95,"b2"); if h2 >= entryP2*1.03 Then ExitLong("tr2",AtStop,h2*0.98,"b2"); } if MaxEntries >= 3 Then{ exitlong("손절3",AtStop,entryp3*0.97,"b3"); if h3 >= entryP3*1.02 Then ExitLong("tr3",AtStop,h3*0.99,"b3"); } } 각 진입이 한번씩만 발생하고자 하시면 피라미딩을 다른진입신호만 허용으로 설정하시고 추가 진입식의 if조건에 countif(CurrentContracts < CurrentContracts[1],BarsSinceEntry) < 1 조건을 추가하시기 바랍니다. 다른진입신호만허용은 해당 이름이 진입하고 해당이름의 수량이 모두 청산이 되면 이후 조건이 만족하면 다시 진입입니다. 즉 현재까지의 수량에 해당이름으로 진입된 수량이 있으면 더이상 진입하지 않지만 해당이름으로 진입한 수량이 모두 청산되면 다시 발생됩니다. 즐거운 하루되세요 > noriter 님이 쓴 글입니다. > 제목 : 재질문입니다 > Input : af(0.02), maxAF(0.2) ; Var : value(0),entryP1(0),entryP2(0),entryP3(0),h1(0),h2(0),h3(0); value = csar(af,maxAF); If MarketPosition == 0 and crossup(C,value)Then{ Buy("b1"); entryP1 = C; h1 = H; } if MarketPosition == 1 Then{ if CurrentEntries == 1 and C >= H[1]*1.03 Then{ buy("b2",OnClose,def,CurrentContracts*2); entryP2 = C; H2 = H; } if CurrentEntries == 2 and C >= H[1]*1.03 Then{ buy("b3",OnClose,def,CurrentContracts*3); entryP3 = C; h3 = H; } if H > h1 Then h1 = H; if H > h2 Then h2 = h; if H > h3 Then h3 = h; if C < value Then ExitLong(); if MaxEntries >= 1 Then{ exitlong("손절1",AtStop,entryp1*0.9,"b1"); if h1 >= entryP1*1.05 Then ExitLong("tr1",AtStop,h1*0.96,"b1"); } if MaxEntries >= 2 Then{ exitlong("손절2",AtStop,entryp2*0.95,"b2"); if h2 >= entryP2*1.03 Then ExitLong("tr2",AtStop,h1*0.98,"b2"); } if MaxEntries >= 3 Then{ exitlong("손절3",AtStop,entryp3*0.97,"b3"); if h3 >= entryP3*1.02 Then ExitLong("tr3",AtStop,h1*0.99,"b3"); } } 손절1,2,3은 잘 발동 하는듯하나 tr1,2,3은 제대로 적용이 안됩니다 무엇이 문제인지 잘 모르겠어요..수정 좀 부탁드립니다