커뮤니티

죄송한데 수식이 잘안됩니다..도움좀 부탁드립니다.

프로필 이미지
최재영
2013-03-22 04:43:16
194
글번호 61055
답변완료
var : cnt(0),count(0),dayPL(0); count = 0; dayPL = 0; for cnt = 0 to 30{ if sdate == EntryDate(cnt) Then{ count = count+1; dayPL = dayPL+PositionProfit(cnt); } } var1 = var2 = ma(c,5); var2 = var2 = ma(c,20); if crossup(c,var1) or if crossup(c,var2) dayPL <= 0 Then{ if count == 0 Then buy("b1",OnClose,def,1); if count >= 1 and MarketPosition == -1 and C > EntryPrice Then buy("b2",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) < 0 Then buy("b3",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) >= 0 Then buy("b4",OnClose,def,1); if count >= 1 and MarketPosition == -1 and C < EntryPrice Then ExitShort("sx"); } if CrossDown(c,var2) or if CrossDown(c,var1) dayPL <= 0 Then{ if count == 0 Then Sell("s1",OnClose,def,1); if count >= 1 and MarketPosition == 1 and C < EntryPrice Then Sell("s2",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) < 0 Then Sell("s3",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) >= 0 Then Sell("s4",OnClose,def,1); if count >= 1 and MarketPosition == 1 and C > EntryPrice Then ExitLong("bx"); } if count >= 1 and dayPL > 0 Then{ if CrossDown(c,var1) Then exitlong(); if crossup(c,var2) Then ExitShort(); } 수식은.. 5이평이나 20이평 둘중 어느 하나라도 데드하면 매도... 5데드이후 20데드는 그대루유지 5이평이나 20이평을 골드하면 매수..둘중 어느것이라도. 5골드이후 20골드해도 추가매수없구 그대루 보유. 5이평이나 20이평을 둘중 어느하나라도 골드하면 매수이지만.(매도중이였다면 리버스로 매수) 5이평이나 20이평을 둘중 어느하나라도 데드하면매도이지만 (매수중이였다면 리버스로 매도) .......
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2013-03-22 14:01:53

안녕하세요 예스스탁입니다. if문 안에는 또다시 if문이 들어갈수 없습니다. 조건은 and 나 or로 연결해 작성하셔야 합니다. var : cnt(0),count(0),dayPL(0); count = 0; dayPL = 0; for cnt = 0 to 30{ if sdate == EntryDate(cnt) Then{ count = count+1; dayPL = dayPL+PositionProfit(cnt); } } var1 = ma(c,5); var2 = ma(c,20); if (crossup(c,var1) or crossup(c,var2)) Then{ if count == 0 Then buy("b1",OnClose,def,1); if count >= 1 and MarketPosition == -1 and C > EntryPrice Then buy("b2",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) < 0 Then buy("b3",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) >= 0 Then buy("b4",OnClose,def,1); if count >= 1 and MarketPosition == -1 and C < EntryPrice Then ExitShort("sx"); } if (CrossDown(c,var1) or crossdown(c,var2)) and dayPL <= 0 Then{ if count == 0 Then Sell("s1",OnClose,def,1); if count >= 1 and MarketPosition == 1 and C < EntryPrice Then Sell("s2",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) < 0 Then Sell("s3",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) >= 0 Then Sell("s4",OnClose,def,1); if count >= 1 and MarketPosition == 1 and C > EntryPrice Then ExitLong("bx"); } if count >= 1 and dayPL > 0 Then{ if CrossDown(c,var1) Then exitlong(); if crossup(c,var2) Then ExitShort(); } 즐거운 하루되세요 > 최재영 님이 쓴 글입니다. > 제목 : 죄송한데 수식이 잘안됩니다..도움좀 부탁드립니다. > var : cnt(0),count(0),dayPL(0); count = 0; dayPL = 0; for cnt = 0 to 30{ if sdate == EntryDate(cnt) Then{ count = count+1; dayPL = dayPL+PositionProfit(cnt); } } var1 = var2 = ma(c,5); var2 = var2 = ma(c,20); if crossup(c,var1) or if crossup(c,var2) dayPL <= 0 Then{ if count == 0 Then buy("b1",OnClose,def,1); if count >= 1 and MarketPosition == -1 and C > EntryPrice Then buy("b2",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) < 0 Then buy("b3",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) >= 0 Then buy("b4",OnClose,def,1); if count >= 1 and MarketPosition == -1 and C < EntryPrice Then ExitShort("sx"); } if CrossDown(c,var2) or if CrossDown(c,var1) dayPL <= 0 Then{ if count == 0 Then Sell("s1",OnClose,def,1); if count >= 1 and MarketPosition == 1 and C < EntryPrice Then Sell("s2",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) < 0 Then Sell("s3",OnClose,def,CurrentContracts*2); if count >= 1 and MarketPosition == 0 and PositionProfit(1) >= 0 Then Sell("s4",OnClose,def,1); if count >= 1 and MarketPosition == 1 and C > EntryPrice Then ExitLong("bx"); } if count >= 1 and dayPL > 0 Then{ if CrossDown(c,var1) Then exitlong(); if crossup(c,var2) Then ExitShort(); } 수식은.. 5이평이나 20이평 둘중 어느 하나라도 데드하면 매도... 5데드이후 20데드는 그대루유지 5이평이나 20이평을 골드하면 매수..둘중 어느것이라도. 5골드이후 20골드해도 추가매수없구 그대루 보유. 5이평이나 20이평을 둘중 어느하나라도 골드하면 매수이지만.(매도중이였다면 리버스로 매수) 5이평이나 20이평을 둘중 어느하나라도 데드하면매도이지만 (매수중이였다면 리버스로 매도) .......