거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Twitter에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
32
평가:
(4)
게시됨:
\MQL5\Scripts\
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

기술 개요

ProjectTemplateGen.mq5는 표준화된 Expert Advisor 프로젝트 구조의 생성을 자동화하는 메타트레이더 5 스크립트 유틸리티입니다. 이 유틸리티는 확장 가능한 트레이딩 시스템 개발을 위한 일관된 기반을 구축하면서 MQL5의 보안 제약 내에서 프로그래밍 방식의 파일 시스템 작업을 구현합니다.


핵심 기능

  • 프로그래밍 방식 파일 운영: 디렉터리 생성 및 구조화된 콘텐츠 작성을 위한 MQL5의 파일 처리 API를 시연합니다.
  • 템플릿 기반 생성: 적절한 이벤트 핸들러 스켈레톤을 사용하여 바로 컴파일할 수 있는 MQL5 소스 파일 생성
  • 구성 가능한 출력: 소스 코드를 수정하지 않고 입력 매개변수를 통해 런타임 커스터마이징 가능
  • 샌드박스 준수: 메타트레이더 5의 보안 실행 환경 내에서 작동합니다.

구현 세부 사항

파일 운영 아키텍처

이 스크립트는 파일 생성에 대한 모듈식 접근 방식을 구현하여 프로젝트 생성의 다양한 측면을 처리하는 별개의 함수를 사용합니다:

// OnStart()의 기본 오케스트레이션
string projectPath = "Files\\" + ProjectName + "\\";
if(!FolderCreate(projectPath)) { /* 오류 처리 */ }
if(!CreateMainEA(projectPath + ProjectName + ".mq5")) return;
if(CreateIncludeFile) CreateInclude(projectPath + ProjectName + ".mqh");
CreateManifest(projectPath + "README.txt");

생성된 프로젝트 구조

MQL5/Files/[ProjectName]/
├── [ProjectName].mq5      #  Main Expert Advisor source file
├── [ProjectName].mqh      #  Optional header/class definition file  
└── README.txt            #  Project documentation and instructions


주요 기술 구성 요소

1. 동적 경로 구성

string projectPath = "Files\\" + ProjectName + "\\";

  • MQL5 샌드박스 제한 사항을 준수하는 상대 경로 사용
  • 동적 파일 시스템 탐색을 위한 문자열 연결 시연

2. 오류 처리를 통한 강력한 파일 생성

int h = FileOpen(filePath, FILE_WRITE | FILE_TXT | FILE_ANSI);
if(h == INVALID_HANDLE)
{
    Print("ERROR: Cannot create main EA file. Error: ", GetLastError());
    return false;
}

  • 파일 작업에 대한 포괄적인 오류 검사 구현
  • 시스템 오류 코드와 함께 의미 있는 오류 메시지 제공
  • FileClose() 호출로 적절한 리소스 정리 보장

3. 구조화된 콘텐츠 생성

FileWrite(h,"//+------------------------------------------------------------------+");
FileWrite(h,"//| " + ProjectName + ".mq5");
FileWrite(h,"//| Author: " + AuthorName);
FileWrite(h,"#property strict");
FileWrite(h,"int OnInit()");
FileWrite(h,"{");
FileWrite(h,"   return INIT_SUCCEEDED;");
FileWrite(h,"}");

  • 구문적으로 유효한 MQL5 코드 생성
  • 일관된 서식 및 코딩 표준 유지
  • 컴파일 가능한 상용구 코드 생성

사용 지침

기본 작동

  • 컴파일: 메타에디터에서 ProjectTemplateGen.mq5 컴파일(F7)
  • 실행: 내비게이터에서 스크립트를 아무 차트에나 드래그합니다.
  • 구성: 구성: 입력 대화 상자에서 매개변수를 설정합니다:
  • ProjectName: 대상 폴더 및 파일 이름
  • 작성자 이름: 저작권 및 문서 속성
  • CreateIncludeFile: 헤더 파일 생성 토글
  • 출력: 전문가 탭에서 생성 상태 및 경로 정보를 확인합니다.

생성 후 워크플로

이 스크립트는 MQL5 스크립트 보안 제한으로 인해 MQL5\파일\[프로젝트 이름]\에 프로젝트를 생성합니다.

다음과 같이 설정을 완료합니다:

  1. 폴더를 MQL5\Experts\로 수동으로 이동합니다.
  2. 메타에디터에서 기본 .mq5 파일 열기
  3. 제공된 함수 스켈레톤에서 트레이딩 로직 구현하기

고급 워크플로우를 위한 확장 기회

확장성 향상

  1. 다중 파일 템플릿: 인디케이터 스크립트, 라이브러리 파일 또는 리소스 매니페스트 생성으로 확장 가능
  2. 구성 파일: 매개변수 관리를 위한 JSON/XML 구성 파일 생성 추가
  3. 스크립트 빌드: 일괄 컴파일 또는 종속성 관리 파일 통합



Code :

//+------------------------------------------------------------------+
//|ProjectTemplateGen.mq5 |
//|저작권 2025, 클레멘트 벤자민 | |
//|https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, Clemence Benjamin"
#property link      "https://www.mql5.com"
#property strict
#property description "Generates EA project template in MQL5//Files"
#property script_show_inputs
#property version "2.01"

//--- 입력
input string ProjectName       = "Type your project name";//프로젝트 이름
input string AuthorName        = "Type your name eg. Clemence Benjamin"; // 작성자 이름
input bool   CreateIncludeFile = true;// 헤더 파일 생성

//+------------------------------------------------------------------+
//| 스크립트 입력|
//+------------------------------------------------------------------+
void OnStart()
  {
   Print("=== MQL5 Project Template Generator Started ===");
   Print("Project Name: ", ProjectName);
   Print("Author: ", AuthorName);

//--- 허용된 샌드박스 경로
   string projectPath = "Files\\" + ProjectName + "\\";

   Print("Target path (sandbox-safe): ", projectPath);

//--- 프로젝트 폴더 만들기
   if(!FolderCreate(projectPath))
     {
      Print("ERROR: Cannot create project folder. Error: ", GetLastError());
      return;
     }

//--- EA 파일 만들기
   if(!CreateMainEA(projectPath + ProjectName + ".mq5"))
      return;

//--- 인클루드 파일 생성
   if(CreateIncludeFile)
      CreateInclude(projectPath + ProjectName + ".mqh");

//--- 매니페스트 생성
   CreateManifest(projectPath + "README.txt");

   Print("SUCCESS: Project created in MQL5\\Files\\", ProjectName);
   Print("ACTION REQUIRED: Move folder to MQL5\\Experts\\ manually");
   Print("Folder path: ", TerminalInfoString(TERMINAL_DATA_PATH) + "\\" + projectPath);
  }

//+------------------------------------------------------------------+
//| 메인 EA 만들기|
//+------------------------------------------------------------------+
bool CreateMainEA(const string filePath)
  {
   int h = FileOpen(filePath, FILE_WRITE | FILE_TXT | FILE_ANSI);
   if(h == INVALID_HANDLE)
     {
      Print("ERROR: Cannot create main EA file. Error: ", GetLastError());
      return false;
     }

   FileWrite(h,"//+------------------------------------------------------------------+");
   FileWrite(h,"//| " + ProjectName + ".mq5");
   FileWrite(h,"//| Author: " + AuthorName);
   FileWrite(h,"//+------------------------------------------------------------------+");
   FileWrite(h,"#property strict");
   FileWrite(h,"");
   FileWrite(h,"int OnInit()");
   FileWrite(h,"{");
   FileWrite(h,"   return INIT_SUCCEEDED;");
   FileWrite(h,"}");
   FileWrite(h,"");
   FileWrite(h,"void OnTick()");
   FileWrite(h,"{");
   FileWrite(h,"}");
   FileClose(h);
   return true;
  }

//+------------------------------------------------------------------+
//| 인클루드 파일 생성|
//+------------------------------------------------------------------+
void CreateInclude(const string filePath)
  {
   int h = FileOpen(filePath, FILE_WRITE | FILE_TXT | FILE_ANSI);
   if(h == INVALID_HANDLE)
      return;

   FileWrite(h,"#ifndef __" + ProjectName + "_MQH__");
   FileWrite(h,"#define __" + ProjectName + "_MQH__");
   FileWrite(h,"class C" + ProjectName + " {};");
   FileWrite(h,"#endif");
   FileClose(h);
  }

//+------------------------------------------------------------------+
//| 매니페스트 생성|
//+------------------------------------------------------------------+
void CreateManifest(const string filePath)
  {
   int h = FileOpen(filePath, FILE_WRITE | FILE_TXT | FILE_ANSI);
   if(h == INVALID_HANDLE)
      return;

   FileWrite(h,"PROJECT TEMPLATE");
   FileWrite(h,"Name: " + ProjectName);
   FileWrite(h,"Author: " + AuthorName);
   FileWrite(h,"");
   FileWrite(h,"NOTE:");
   FileWrite(h,"Move this folder to MQL5\\Experts\\ to compile.");
   FileClose(h);
  }
//+------------------------------------------------------------------+

MetaQuotes Ltd에서 영어로 번역함.
원본 코드: https://www.mql5.com/en/code/68598

VR Breakdown level - 이전 고가 또는 저가 돌파 기반 트레이딩 전략 VR Breakdown level - 이전 고가 또는 저가 돌파 기반 트레이딩 전략

이전 고가 또는 저가 수준의 단순 돌파에 기반한 트레이딩 전략

Modern Time Panel - Candle Time Modern Time Panel - Candle Time

Modern Time Panel for MT5 The Modern Time Panel is a sleek, minimalist custom indicator for MetaTrader 5 that helps you track time with precision. Fixed neatly at the top-right corner of your chart, it displays the current Broker Time, Local Time, and a live countdown to the next candlestick (New Bar). Built with an independent 1-second timer, the countdown continuously runs even when the market is slow or there are no incoming ticks. Fully customizable and dark-mode friendly, it is the perfect non-intrusive tool to ensure you never miss a candle close.

EA Duplicate Detector EA Duplicate Detector

EA가 조건에 따라 차트에 중복 EA가 있는지 여부를 결정하도록 허용합니다.

Trade With MA Trade With MA

Trade using MA. An easy indicator to identify the trend direction on a specific timeframe.