시스템트레이딩 게시글

프로프 회사 도전 과제를 위한 브레이크아웃 전략 최적화

첨부파일
49713.zip (3.14 KB, 다운로드 0회)

안녕하세요, 트레이더 여러분!

오늘은 간단하지만 효과적인 브레이크아웃 전략의 업데이트 소식을 전해드릴게요. 이번 코드에는 프로프 회사 도전 과제를 위한 헬퍼 함수들이 추가되었습니다.

프로프 회사 도전을 통과하기 위해서는 일반적으로 세 가지 주요 기준을 충족해야 합니다:

  • 타겟 수익
  • 최대 일일 손실 위반하지 않기
  • 최대 손실 위반하지 않기

이번 코드에서는 '타겟 수익'과 '거의 최대 일일 손실을 위반할 때'를 확인하는 두 가지 함수를 포함하여, 모든 포지션을 자동으로 종료하고 모든 보류 중인 주문을 삭제하는 기능을 추가했습니다. '최대 손실'은 여러분의 전략과 리스크 관리에 따라 달라지기 때문에 MQL5 스크립트에서는 언급하지 않겠습니다.

//+------------------------------------------------------------------+
//| 프로프 회사 헬퍼 함수                                       |
//+------------------------------------------------------------------+

// 모든 보류 중인 주문을 삭제하고 모든 포지션 종료
void ClearAll(string message)
{
   Comment(message);
   for (int i = OrdersTotal() - 1; i >= 0; i--)
   {
      ulong orderTicket = OrderGetTicket(i);
      if (OrderSelect(orderTicket)) 
      {
         trade.OrderDelete(orderTicket);
      }
   }

   for (int i = PositionsTotal() - 1; i >= 0; i--)
   {
      ulong posTicket = PositionGetTicket(i);
      trade.PositionClose(posTicket);
   }
}

// 우리가 목표 수익을 달성했는지 확인
bool isPassed()
{
   return AccountInfoDouble(ACCOUNT_EQUITY) > PASS_CRITERIA;
}

// 최대 일일 손실을 위반할 상황인지 확인
bool isDailyLimit()
{
   MqlDateTime date_time;
   TimeToStruct(TimeCurrent(), date_time);
   int current_day = date_time.day, current_month = date_time.mon, current_year = date_time.year;
   
   // 현재 잔고
   double current_balance = AccountInfoDouble(ACCOUNT_BALANCE);
   
   // 오늘의 마감 거래 PL 가져오기
   HistorySelect(0, TimeCurrent());
   int orders = HistoryDealsTotal();
   
   double PL = 0.0;
   for (int i = orders - 1; i >= 0; i--)
   {
      ulong ticket=HistoryDealGetTicket(i);
      if(ticket==0)
      {
         Print("HistoryDealGetTicket 실패, 거래 내역 없음");
         break;
      }
      double profit = HistoryDealGetDouble(ticket,DEAL_PROFIT);
      if (profit != 0)
      {
         // 거래 시간 가져오기
         MqlDateTime deal_time;
         TimeToStruct(HistoryDealGetInteger(ticket, DEAL_TIME), deal_time);
         // 거래 시간 확인
         if (deal_time.day == current_day && deal_time.mon == current_month && deal_time.year == current_year)
         {
            PL += profit;
         }
         else
            break;
      }
   }
   double starting_balance = current_balance - PL;
   double current_equity   = AccountInfoDouble(ACCOUNT_EQUITY);
   return current_equity < starting_balance - DAILY_LOSS_LIMIT;
}

우리가 설정해야 할 매개변수는 다음과 같습니다:

input string dd = "-------------프로프 회사 도전 과제-----------------";
input bool   isChallenge = false;
input double PASS_CRITERIA = 110100.;
input double DAILY_LOSS_LIMIT = 4500.;

이 스크립트가 여러분에게 도움이 되길 바랍니다.


연관 포스트

댓글 (0)