유용합니다! ...색상 변경 기준을 알고 싶습니다.
이 훌륭한 지표에 대해 많은 감사를 드립니다.
이전 버전도 새 버전만큼이나 흥미롭고 유용하거나 사실 더 유용하다는 것을 알았습니다.
이전 버전도 mq5로 포팅해 주실 수 있나요? 가능하다면 정말 감사하겠습니다.
건배, 그리고 미리 감사드립니다 !!!
이 인디케이터에서 신호를 만들려고 했지만 실패했습니다...
도움이 필요하신가요?
//+------------------------------------------------------------------+ //|COG.mqh | //|브루노 피오 | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Bruno Pio" #property link "http://www.mql5.com" #property version "1.00" #include "..\ExpertSignal.mqh" // CExpertSignal은 ExpertSignal 파일에 있습니다. #property tester_indicator "CenterOfGravity.ex5" // 마법사 설명 시작 //+------------------------------------------------------------------+ //| 클래스 설명| //| 제목=중심의 신호| //| 유형=신호 고급| //| Name=My_COG| //| ShortName=CG| //| Class=COG| //| 페이지=필요 없음| //| Parameter=Period_,int,10,지표 평균 기간 | //| 파라미터=스무드 주기,int,3,신호선 평활화 주기 | //| 파라미터=MA_Method_,ENUM_MA_METHOD,MODE_EMA,신호 방법 | //| Parameter=AppliedPrice,int,1,가격 상수 | //+------------------------------------------------------------------+ // 마법사 설명 종료 //+------------------------------------------------------------------+ //|| //+------------------------------------------------------------------+ class COG : public CExpertSignal { private: CiCustom m_COG; // 객체로서의 표시기 //--- 구성 가능한 모듈 매개변수 int m_Period_; // 지표 평균화 기간 int m_SmoothPeriod; // 신호선 평활화 기간 ENUM_MA_METHOD m_MA_Method_; // 신호 라인 평균화 방법 int m_AppliedPrice; // 가격 상수 public: COG(void); ~COG(void); //--- 입력 데이터의 정확성 확인 bool ValidationSettings(); //--- 신호 모듈에 대한 지표 및 시계열 만들기 bool InitIndicators(CIndicators *indicators); //--- 표시기 데이터에 액세스 double CG(const int index) const { return(m_COG.GetData(0,index)); } double Signal(const int index) const { return(m_COG.GetData(1,index)); } //--- 매수 및 매도 조건 확인 virtual int LongCondition(); virtual int ShortCondition(); //--- 설정 방법 void Period_(int value) { m_Period_=value; } void SmoothPeriod(int value) { m_SmoothPeriod=value; } void MA_Method_(ENUM_MA_METHOD value) { m_MA_Method_=value; } void AppliedPrice(int value) { m_AppliedPrice=value; } protected: //--- 표시기 만들기 bool CreateCOG(CIndicators *indicators); }; //+------------------------------------------------------------------+ //| 생성자| //+------------------------------------------------------------------+ COG::COG(void) : m_Period_(10), // 지표 평균화 기간 m_SmoothPeriod(3), // 신호선 평활화 기간 m_MA_Method_(MODE_EMA), // 신호 라인 평균화 방법 m_AppliedPrice(1) // 가격 상수 { } //+------------------------------------------------------------------+ //|| //+------------------------------------------------------------------+ COG::~COG() { } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| 입력 매개변수를 확인하고 모든 것이 정상인 경우 참을 반환합니다. //+------------------------------------------------------------------+ bool COG:: ValidationSettings() { //--- 베이스 클래스 메서드 호출 if(!CExpertSignal::ValidationSettings()) return(false); //--- MA >=1 계산을 위한 주기, 막대 수 확인 if(m_Period_<1) { PrintFormat("Incorrect value set for one of the period! Period_=%d", m_Period_); return false; } //--- MA >=1 계산을 위한 주기, 막대 수 확인 if(m_SmoothPeriod<1) { PrintFormat("Incorrect value set for one of the period! m_SmoothPeriod=%d", m_SmoothPeriod); return false; } //--- 고속 MA 평활화 유형은 열거형의 네 가지 값 중 하나여야 합니다. if(m_MA_Method_!=MODE_SMA && m_MA_Method_!=MODE_EMA && m_MA_Method_!=MODE_SMMA && m_MA_Method_!=MODE_LWMA) { PrintFormat("Invalid type of smoothing of the fast MA!"); return false; } //--- m_AppliedPrice가 유효해야 합니다. if(m_AppliedPrice<1 || m_AppliedPrice>11) { PrintFormat("Invalid type of Price!"); return false; } //--- 모든 검사 완료, 모든 것이 정상입니다. return true; } //+------------------------------------------------------------------+ //| 지표 생성| //| 입력: 지표 모음에 대한 포인터 | //| 출력: 성공하면 참, 그렇지 않으면 거짓 | //+------------------------------------------------------------------+ bool COG::InitIndicators(CIndicators *indicators) { //--- NULL에 대한 표시기 컬렉션의 표준 검사 if(indicators==NULL) return(false); //--- 추가 필터에서 지표 및 시계열 초기화하기 if(!CExpertSignal::InitIndicators(indicators)) return(false); //--- 지표 만들기 if(!CreateCOG(indicators)) return(false); //--- 이 부분에 도달했으므로 함수가 성공했습니다, 참을 반환합니다. return(true); } //+------------------------------------------------------------------+ //| "COG" 표시기를 생성합니다.| //+------------------------------------------------------------------+ bool COG::CreateCOG(CIndicators *indicators) { //--- 포인터 확인 if(indicators==NULL) return(false); //--- 컬렉션에 객체 추가하기 if(!indicators.Add(GetPointer(m_COG))) { printf(__FUNCTION__+": Error adding an object of the COG"); return(false); } //--- COG의 매개변수 설정 MqlParam parameters[5]; //--- parameters[0].type=TYPE_STRING; parameters[0].string_value="CenterOfGravity.ex5"; parameters[1].type=TYPE_INT; parameters[1].integer_value=m_Period_; // 기간 parameters[2].type=TYPE_INT; parameters[2].integer_value=m_SmoothPeriod; // 신호선 평활화 기간 parameters[3].type=TYPE_INT; parameters[3].integer_value=m_MA_Method_; // 신호 라인 평균화 방법 parameters[4].type=TYPE_INT; parameters[4].integer_value=m_AppliedPrice; // 가격 상수 //--- 개체 초기화 if(!m_COG.Create(m_symbol.Name(),0,IND_CUSTOM,5,parameters)) { printf(__FUNCTION__+": Error initializing the object of the COG"); return(false); } //--- 버퍼 개수 if(!m_COG.NumBuffers(2)) return(false); //--- 이 부분에 도달했으므로 함수가 성공했습니다, 참을 반환합니다. return(true); } //+------------------------------------------------------------------+ //| 매수 신호의 강도를 반환합니다.| //+------------------------------------------------------------------+ int COG::LongCondition() { int signal=0; //--- 틱이 있는 연산의 경우 idx=0, 바가 형성된 연산의 경우 idx=1 int idx=StartIndex(); //--- 마지막으로 형성된 막대의 COG 값 double last_fast_value=CG(idx); double last_slow_value=Signal(idx); //--- 마지막에 형성된 막대 하나만 남긴 COG 값 double prev_fast_value=CG(idx+1); double prev_slow_value=Signal(idx+1); //--- CG > 신호 && CG-1 < 신호-1인 경우 if((last_fast_value>last_slow_value) && (prev_fast_value<prev_slow_value)) { signal=100; // 매수 신호가 있습니다. } //--- 신호 값을 반환합니다. return(signal); } //+------------------------------------------------------------------+ //| 매도 신호의 강도를 반환합니다.| //+------------------------------------------------------------------+ int COG::ShortCondition() { int signal=0; //--- 틱이 있는 연산의 경우 idx=0, 바가 형성된 연산의 경우 idx=1 int idx=StartIndex(); //--- 마지막으로 형성된 막대의 COG 값 double last_fast_value=CG(idx); double last_slow_value=Signal(idx); //--- 마지막에 형성된 막대 하나만 남긴 COG 값 double prev_fast_value=CG(idx+1); double prev_slow_value=Signal(idx+1); //--- CG < 신호 && CG-1 > 신호-1이면 if((last_fast_value<last_slow_value) && (prev_fast_value>prev_slow_value)) { signal=100; // 판매 신호가 있습니다. } //--- 신호 값을 반환합니다. return(signal); }
흥미로운 점은... 전투 조건에서 알고리즘을 결정해야 한다는 것입니다.


엘러스 무게 중심 - 무게 중심 J. F. Ehlers:
중력의 중심은 존 엘러스가 개발한 오실레이터로, 2002년 5월호 주식 및 상품에 소개된 바 있습니다.
Author: Nikolay Kositsin