커뮤니티

수식 수정 부탁드립니다.

프로필 이미지
착한이
2024-09-26 16:10:01
652
글번호 183780
답변완료

첨부 이미지

안녕하세요. 아래의 피라미딩전략에 다소 오류가 있는듯하여 수정 요청드립니다. 감사합니다. 1. 손실시에는 다음 진입신호가 나올때까지 보유하며, 총 5회까지 진입허용 2. 각각의 진입은 수익시에만 트레일링스탑으로 청산 if MarketPosition == 0 Then { if CurrentEntries == 0 Then { if BuyCond == True Then Buy("Long1", AtMarket); } } if MarketPosition == 1 Then { if CurrentEntries == 1 Then { if BuyCond == True Then Buy("Long2", AtMarket); if PositionProfit(0) > 0 Then ExitLong("TStop1-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } if CurrentEntries == 2 Then { if BuyCond == True Then Buy("Long3", AtMarket); if PositionProfit(0) > 0 Then ExitLong("TStop2-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long2"); if PositionProfit(1) > 0 Then ExitLong("TStop2-1", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } if CurrentEntries == 3 Then { if BuyCond == True Then Buy("Long4", AtMarket); if PositionProfit(0) > 0 Then ExitLong("TStop3-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long3"); if PositionProfit(1) > 0 Then ExitLong("TStop3-1", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long2"); if PositionProfit(2) > 0 Then ExitLong("TStop3-2", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } if CurrentEntries == 4 Then { if BuyCond == True Then Buy("Long5", AtMarket); if PositionProfit(0) > 0 Then ExitLong("TStop4-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long4"); if PositionProfit(1) > 0 Then ExitLong("TStop4-1", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long3"); if PositionProfit(2) > 0 Then ExitLong("TStop4-2", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long2"); if PositionProfit(3) > 0 Then ExitLong("TStop4-3", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } if CurrentEntries == 5 Then { if PositionProfit(0) > 0 Then ExitLong("TStop5-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long5"); if PositionProfit(1) > 0 Then ExitLong("TStop5-1", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long4"); if PositionProfit(2) > 0 Then ExitLong("TStop5-2", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long3"); if PositionProfit(3) > 0 Then ExitLong("TStop5-3", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long2"); if PositionProfit(4) > 0 Then ExitLong("TStop5-4", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2024-09-27 11:52:06

안녕하세요 예스스탁입니다. 1 PositionProfit은 포지션의 손익입니다. 0은 현재 진행중인 포지션손익, 1은 직전 거래가 완료된 거래의 손익,2는 그전순입니다. 즉 (1)이상은 현재거래와 관련이 없습니다. 모구 과거 청산완료된 거래의 값입니다. 2 var : HH1(0),HH2(0),HH3(0),HH4(0),HH5(0); var : EP1(0),EP2(0),EP3(0),EP4(0),EP5(0); if MarketPosition == 0 Then { if BuyCond == True Then Buy("Long1", AtMarket); } if MarketPosition == 1 Then { if CurrentContracts > CurrentContracts[1] Then { if MaxEntries == 1 Then { HH1 = LatestEntryPrice(0); EP1 = LatestEntryPrice(0); } if MaxEntries == 2 Then { HH2 = LatestEntryPrice(0); EP2 = LatestEntryPrice(0); } if MaxEntries == 3 Then { HH3 = LatestEntryPrice(0); EP3 = LatestEntryPrice(0); } if MaxEntries == 4 Then { HH4 = LatestEntryPrice(0); EP4 = LatestEntryPrice(0); } if MaxEntries == 5 Then { HH5 = LatestEntryPrice(0); EP5 = LatestEntryPrice(0); } } if MaxEntries >= 1 and H > HH1 Then HH1 = H; if MaxEntries >= 2 and H > HH2 Then HH2 = H; if MaxEntries >= 3 and H > HH3 Then HH3 = H; if MaxEntries >= 4 and H > HH4 Then HH4 = H; if MaxEntries >= 5 and H > HH5 Then HH5 = H; if MaxEntries == 1 and BuyCond == True Then Buy("Long2", AtMarket); if MaxEntries == 2 and BuyCond == True Then Buy("Long3", AtMarket); if MaxEntries == 3 and BuyCond == True Then Buy("Long4", AtMarket); if MaxEntries == 4 and BuyCond == True Then Buy("Long5", AtMarket); if MaxEntries >= 1 and HH1-ATR > EP1 Then ExitLong("TStop1", Atstop, HH1 - ATR, "Long1"); if MaxEntries >= 2 and HH1-ATR > EP2 Then ExitLong("TStop2", Atstop, HH2 - ATR, "Long2"); if MaxEntries >= 3 and HH1-ATR > EP3 Then ExitLong("TStop3", Atstop, HH3 - ATR, "Long3"); if MaxEntries >= 4 and HH1-ATR > EP4 Then ExitLong("TStop4", Atstop, HH4 - ATR, "Long4"); if MaxEntries >= 5 and HH1-ATR > EP5 Then ExitLong("TStop5", Atstop, HH5 - ATR, "Long5"); } Else { HH1 = 0; HH2 = 0; HH3 = 0; HH4 = 0; HH5 = 0; EP1 = 0; EP2 = 0; EP3 = 0; EP4 = 0; EP5 = 0; } 즐거운 하루되세요 > 착한이 님이 쓴 글입니다. > 제목 : 수식 수정 부탁드립니다. > 안녕하세요. 아래의 피라미딩전략에 다소 오류가 있는듯하여 수정 요청드립니다. 감사합니다. 1. 손실시에는 다음 진입신호가 나올때까지 보유하며, 총 5회까지 진입허용 2. 각각의 진입은 수익시에만 트레일링스탑으로 청산 if MarketPosition == 0 Then { if CurrentEntries == 0 Then { if BuyCond == True Then Buy("Long1", AtMarket); } } if MarketPosition == 1 Then { if CurrentEntries == 1 Then { if BuyCond == True Then Buy("Long2", AtMarket); if PositionProfit(0) > 0 Then ExitLong("TStop1-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } if CurrentEntries == 2 Then { if BuyCond == True Then Buy("Long3", AtMarket); if PositionProfit(0) > 0 Then ExitLong("TStop2-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long2"); if PositionProfit(1) > 0 Then ExitLong("TStop2-1", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } if CurrentEntries == 3 Then { if BuyCond == True Then Buy("Long4", AtMarket); if PositionProfit(0) > 0 Then ExitLong("TStop3-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long3"); if PositionProfit(1) > 0 Then ExitLong("TStop3-1", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long2"); if PositionProfit(2) > 0 Then ExitLong("TStop3-2", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } if CurrentEntries == 4 Then { if BuyCond == True Then Buy("Long5", AtMarket); if PositionProfit(0) > 0 Then ExitLong("TStop4-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long4"); if PositionProfit(1) > 0 Then ExitLong("TStop4-1", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long3"); if PositionProfit(2) > 0 Then ExitLong("TStop4-2", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long2"); if PositionProfit(3) > 0 Then ExitLong("TStop4-3", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } if CurrentEntries == 5 Then { if PositionProfit(0) > 0 Then ExitLong("TStop5-0", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long5"); if PositionProfit(1) > 0 Then ExitLong("TStop5-1", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long4"); if PositionProfit(2) > 0 Then ExitLong("TStop5-2", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long3"); if PositionProfit(3) > 0 Then ExitLong("TStop5-3", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long2"); if PositionProfit(4) > 0 Then ExitLong("TStop5-4", Atstop, highest(high,barsSinceEntry+1) - ATR, "Long1"); } }