본문 바로가기

트레이딩/메타트레이더 코딩   ( 66 )


MQL5. Arrays. 배열 MQL5 에서 정적 배열 - 일반 C와 동일. // MQL5 에서 정적 배열. 일반 C 문법과 동일. double myData[100]; MQL5 에서 동적배열. - 일반 C와 다르며, 사용 편리. // MQL5 Dnamic array double myData[]; // 배열 크기 기록없이 선언하면 동적배열이됨. ArrayResize(myData, 99); // 사용하기 전에 배열 크기 지정함수 호출해서 설정. ArrayResize(myData, 15); // 앞에서 설정된 99를 15로 줄인것. ArrayResize(myData, 0); // 앞에서 설정된 15를 0로 줄인것. ArrayFree(myData); // myData 해제하는것. ArrayResize(myData, 0); 과동일 효과. bo.. 2019. 5. 17.
MQL5. struct. 구조체, DLL 함수인자에 구조체 전달 방법 MQL5 구조체 타입선언. // MQL5 에서구조체 선언형식. struct ST_DATA { double V1; ... }; // 즉 아래와 같은 형식은 MQL5 에서는 지원안됨. typedef struct __st_data { double V1; ... }ST_DATA, *PST_DATA; MQL5 에서 DLL함수 인자로 구조체 전달. - 아래 구문에서 DLL 함수인자가 구조체 포인터인 경우 MQL5 에서 import 부분의 처리가 C와 스타일이 다름에 주의.암튼 작용은 C에서 포인터 전달하는것과 동일한 개념은 달성됨. void function(ST_DATA st_dapa); // DLL 함수 인자 구조체인 경우. // MQL5 에서 호출하려면, #import "mydll.dll" void functi.. 2019. 5. 16.
메타트레이더 . 코딩 . function pointer . 콜백 함수 메타트레이더의 함수 포인터, 콜백 - C 에서의 함수 포인터, 콜백 개념 / 문법 과 동일. typedef int (*TFunc)(int,int); TFunc func_ptr; int sub(int x,int y) { return(x-y); } int add(int x,int y) { return(x+y); } int neg(int x) { return(~x); } func_ptr=sub; Print(func_ptr(10,5)); func_ptr=add; Print(func_ptr(10,5)); func_ptr=neg; // error: neg is not of int (int,int) type Print(func_ptr(10)); // error: there should be two parameters.. 2019. 5. 13.
MQL5. EventChartCustom https://igotit.tistory.com/2156 Custom Event 발생예제코드. void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam) { switch(id) { case CHARTEVENT_KEYDOWN: EventFire(); break; } } // eventing to all charts except this chart. void EventFire() { long currChart = ChartFirst(); int i=1;//1 for except current chart id =0 while(i= CHARTEVENT_CUSTOM && id 2019. 5. 11.
MQL5. Custom Indicator MQL5 에서 Custom Indicator 파일 생성하기. 기본 생성된 Indicator 파일의 골격 코드. #property indicator_chart_window int OnInit() { return(INIT_SUCCEEDED); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { return(rates.. 2019. 5. 10.
MQL5. 소켓통신 메타트레이더 5에서 원격소켓서버와 통신 가능하게 하기 위한 설정. Options 창에서 Allow WebRequest for listed URL 체크하고 통신대상 소켓서버의 아이피 주소 기록해둔다. MQ5 에서 소켓통신 코드예. 실행예. - MQL5 에서 파이썬으로 구현된 소켓서버로 틱데이터 중 Ask 가격을 실시간 전송하는 예. 연관 - 파이썬 측 소켓통신 소스 코드. Python. 소켓통신 Python 소켓서버 구현 코드예. 소켓통신 실행 시험. - 소켓클라이언트로 하이퍼터미널 이용. 상기 파이썬 소켓서버 와 통신하는 소켓클라이언트로 하이퍼 터미널을 이용해도 된다. 아래 동영상에서는 다른 PC에 하.. igotit.tistory.com 첫등록 : 2019년 5월 8일 최종수정 : 본 글 단축주소 : .. 2019. 5. 9.
MQL5. 수직선 그리기 아래 예와 같은 수직선 그리기. 코드. int OnInit() { Init_myLine3(); return(INIT_SUCCEEDED); } void OnTick() { MqlRates rates_myCandle[]; ArraySetAsSeries(rates_myCandle,true); // the index = 0 is current candle CopyRates(_Symbol, _Period,0,100,rates_myCandle ); // Copy price data into rates_myCandle[] ObjectMove(_Symbol, "Line3",0,rates_myCandle[99].time,0); // draw line } void Init_myLine3() { ObjectCreate( 0.. 2019. 4. 29.
MQL5. 캔들 변경 지점 검출 개요. - MQL5 의 OnTick 에서 호출하여 신규 캔들 시작되는 지점 검출 하기. 코드 int NumBars_Prev = 0 ; int OnInit() { Init_NewBar(); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { } void OnTick() { if(Check_NewBar() == 1) { Print("New Bar"); } } /* caller : OnInit */ void Init_NewBar() { NumBars_Prev = Bars(_Symbol,_Period); } /* caller : OnTick */ int Check_NewBar() { int retv = 0; int numbar_crnt = Bars(_Sym.. 2019. 4. 29.
MQL5. 사각형 그리기 MQL5 에서 챠트에 사각형그리기 (아래 그림 같은것) 코드. void OnTick() { MqlRates rates_myCandle[]; ArraySetAsSeries(rates_myCandle,true); // the index = 0 is current candle CopyRates(_Symbol, _Period,0,100,rates_myCandle ); // Copy price data into rates_myCandle[] ReDraw_myRect1(rates_myCandle[99].time, rates_myCandle[99].high, rates_myCandle[0].time, rates_myCandle[0].low); } void ReDraw_myRect1(datetime x1_time,do.. 2019. 4. 29.
MQL5. 클래스 만들기 MQL5 에서는 C++과 동일 문법의 클래스 만들 수 있고, 활용가능하다. 통상 C++ 에서는 클래스 코드작성시 헤더파일에 선언 몰아두고 함수정의는 c 파일에서 작성하나, MQL5 에서는 확장자mqh (헤더파일에 해당) 파일 1개에서 선언과 정의를 모두 구현한다. MQL5 에서 클래스 생성하기. 클래스 이름 예 클래스이름 CCyNewBar 만드는 예. 본인이 만든 클래스 파일들 몰아둘 폴더를 하나 만들고 이 폴더속에 자신이 만든 클래스 몰아두는게 편하다. 본예에서는 아래처럼 CyClass 라는 폴더를 이용한다. 동영상. - MQL5 에서 클래스 만드는 방법과 EA코드내에서 활용하는 과정 전체. MQL5 제공 클래스 상세정보 : https://www.mql5.com/en/docs/basis/types/cl.. 2019. 4. 29.
MQL5. ATR ( Average True Range ) 개요. - MQL5 EA코드내에서 ATR 활용하기. - MQL5 내장함수인 iATR 호출 간단 구현가능. - iATR() 호출하면 챠트에 ATR 인디게이터가 표현된다. 코드. void OnTick() { double atr_crnt; atr_crnt = Get_ATR(_Symbol,_Period); } double Get_ATR(string symbol,ENUM_TIMEFRAMES timeframe) { double arrATR[]; int ATRretv = iATR(symbol,timeframe,14); ArraySetAsSeries(arrATR,true); // sort as index 0 is current CopyBuffer(ATRretv,0,0,3,arrATR); // double ATR_Crn.. 2019. 4. 28.
MQL5. 캔들 중 최고가 구하고 라인표현 개요 아래 메타트레이더 5의 챠트에 현재 이전 지정된 캔들 수량(예 100개) 중 최고가를 찾고 이를 화면상에서 수평선 표현하는 코드 소스 정리. 아래 코드의 함수 get_Highest(int num_candle) 는 인자로 전달된 현재시점기준 과거 num_candle 수량중에서 최고가를 반환하는 함수. 이를 OnTick 에서 호출하여 print 하는 예. void OnTick() { Print(Get_Highest(100)); } double Get_Highest(int num_candle) { int idx_highest_candle; double arr_high[]; ArraySetAsSeries(arr_high, true); // CopyHigh(_Symbol,_Period,0,num_candle.. 2019. 4. 27.
MQL5. 수평선 그리기 메타트레이더5의 챠트 화면에 수평선 그리기. - 아래 그림에서 백색 수평선과 같은것을 MQL5 코드에서 구현하는 방법. 전체 코드. int OnInit() { Init_myLine(); return(INIT_SUCCEEDED); } void OnTick() { double price_ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK); // get price ask. ObjectMove(_Symbol, "Line1",0,0,price_ask); // draw line } void Init_myLine() { ObjectCreate( _Symbol, "Line1", OBJ_HLINE, 0, //int sub_window 0, //datetime time1 0 // y value .. 2019. 4. 27.
MQL5. Data Collections. Data Arrays Use of classes of dynamic data arrays will save time when creating a custom data stores of various formats (including multidimensional arrays). MQL5 Standard Library (in terms of arrays of data) is located in the working directory of the terminal in the Include\Arrays folder. Class Description CArray Base class of dynamic data array CArrayChar Dynamic array of char or uchar variables.. 2019. 4. 24.
MQL5. 포지션 함수, 클래스. MQL5 의 포지션 함수 모든 포지션 관련함수 PositionsTotal Returns the number of open positions PositionGetSymbol Returns the symbol corresponding to the open position PositionSelect Chooses an open position for further working with it PositionSelectByTicket Selects a position to work with by the ticket number specified in it PositionGetDouble Returns the requested property of an open position (double) PositionGe.. 2019. 4. 23.
MQL5. CPositionInfo CPositionInfo - 포지션정보 클래스 상세 ...더보기 CPositionInfo is a class for easy access to the open position properties. Description CPositionInfo class provides easy access to the open position properties. Declaration class CPositionInfo : public CObject Title #include Inheritance hierarchy CObject CPositionInfo Class methods by groups Access to integer type properties Time Gets the time of position openi.. 2019. 4. 23.
MQL5. PositionGetSymbol PositionGetSymbol Returns the symbol corresponding to the open position and automatically selects the position for further working with it using functions PositionGetDouble, PositionGetInteger, PositionGetString. string PositionGetSymbol( int index // Number in the list of positions ); Parameters index [in] Number of the position in the list of open positions. Return Value Value of the string ty.. 2019. 4. 19.
MQL5. PositionSelect, PositionGetDouble, PositionGetInteger, PositionGetString PositionSelect Chooses an open position for further working with it. Returns true if the function is successfully completed. Returns false in case of failure. To obtain information about the error, call GetLastError(). bool PositionSelect( string symbol // Symbol name ); 반환값. - true : 함수호출결과 성공인 경우, fasle : 호출결과 실패인 경우 포지션0인 경우에도 false 반환됨. 설명. - 인자로 전달된 심볼 1개에 포지션 여러 개인 경우엔 ticket 번호가장 작은 것 1개만.. 2019. 4. 19.


 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5