본문 바로가기

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


MQL5. CHashMap iteration.반복 MQL5 의 컬렉션은 컬렉션 자체의 반복 수단 제공되지 않으며, 컬렉션 요소를 CopyTo 로 array 로 복사한 이후 array로 루프돌림 #include CHashMap map_My; string keys[]; int values[]; map_my.CopyTo(keys, values); // 맵의 키,값을 array 로 복사하고 아래 array 에서 루프돌림. for(int idx=0; idx < map_My.Count(); idx++) { keys[idx]; values[idx]; } 첫 등록 : 2020.11.09 최종 수정 : 단축 주소 : https://igotit.tistory.com/2693 2020. 11. 9.
MQL5. 포지션 함수, 클래스 활용코드 . 심볼1개의 모든 포지션등. 1. 계정의 모든 심볼의 모든 포지션 정보들 확보하기. #include CPositionInfo m_PosiInfo; int Proc_SupplyPosition() { int num_position_all_symbol = PositionsTotal(); // 계좌의 모든 포지션 수량 반환됨. for(int idx_posi = 0 ; idx_posi < num_position_all_symbol; idx_posi++) { m_PosiInfo.SelectByIndex(idx_posi); // 인덱스로 포지션 선택하고, Proc_GetInfoPosi(); // 현재 선택된 포지션 1개에서 필요한 정보 확보. } return 1; } void Proc_GetInfoPosi() { // 필요한정보들 m_PosiI.. 2020. 11. 8.
MQL5. 밀리초, 마이크로초 단위 시간 함수 . 일반 date time GetTickCount - PC 시작 이후 경과시간 밀리초 반환.   Documentation on MQL5: Common Functions / GetTickCountGetTickCount The GetTickCount() function returns the number of milliseconds that elapsed since the system start. Return Value Note Example: #define MAX_SIZE 40 //+------------------------------------------------------------------+ //| Script for measuwww.mql5.comGetMicrosecondCount - "MQL5 프로그램" 시작이후 경과시.. 2020. 10. 15.
MQL5. MqlTick. CopyTicks. 틱 데이터. 구조체 MqlTick // 아래 멤버의 바이트 사이즈는 MQL5 의 경우임. MQL4 는 다를 수 있음. struct MqlTick { datetime time; //8바이트. Time of the last prices update double bid; //8바이트. Current Bid price double ask; //8바이트. Current Ask price double last; //8바이트. Price of the last deal (Last) ulong volume; //8바이트. Volume for the current Last price .. 2020. 10. 15.
MQL5. CopyTime. Open.High.Low.Close.TickVolume.RealVolume.Spread. 개요. MQL5 에서 캔들 데이터의 요소(Time, Open, High, Low, Close, TickVolume, RealVolume, Spread) 개별적으로 배열로 확보하는함수들. 비교. CopyRates 의 경우엔 구조체 MqlRates 의 배열로 확보하는 함수인데, 실제 데이터를 활용하는 경우 MqlRates 의 배열보다는 각 멤버의 배열로 구성된 것이 활용상 더 편리한 경우가 많다. 즉, 구조체 MqlRates 의 배열로 시리즈 데이터를 받은 경우 종가들만 그리기 위해서는 별도로 MqlRates 에서 종가들만 골라내는 추가의 변환코드가 필요한 반면, 각 멤버의 배열로 받아둔 경우 별도의 변환 코드 없이 즉시 활용가능한 시리즈 데이터들이 마련된다. 구조체 MqlRates , MqlRates 의 .. 2020. 10. 12.
MQL5. MqlRates. CopyRates . 캔들 데이터 개요mql5 에서 캔들 데이터들 활용하기 위해서는 함수 CopyRates 호출하면서 마지막 인자에 구조체 MqlRates 배열 전달해주면  MqlRates 로 캔들 데이터 얻을 수 있다.   MqlRatesstruct MqlRates { datetime time; // Period start time double open; // Open price double high; // The highest price of the period double low; // The lowest price of the period double close; // Close price long tick_volu.. 2020. 10. 11.
MQL5. Access to Timeseries and Indicator Data 개요 - MQL5 에서의 timeseries 형식은 인덱스0이 최신의 것이고, 인덱스 증가할 수록 과거 정보가 기록되어있다. - 틱, 캔들, 인디케이터 타임시리즈 데이터를 배열로 복사하는 함수 제공. 캔들 구조체, 캔들 시리즈 확보함수. MQL5. MqlRates. CopyRates MqlRates struct MqlRates { datetime time; // Period start time double open; // Open price double high; // The highest price of the period double low; // The lowest price of the period double close;.. igotit.tistory.com 틱 구조체, 틱 시리즈 확보함수. M.. 2020. 10. 11.
MQL5. AccountInfoString. 메타 연결된 서버 정보. string AccountInfoString( ENUM_ACCOUNT_INFO_STRING property_id // Property identifier ); // example void OnStart() { //--- Show all the information available from the function AccountInfoString() Print("The name of the broker = ",AccountInfoString(ACCOUNT_COMPANY)); Print("Deposit currency = ",AccountInfoString(ACCOUNT_CURRENCY)); Print("Client name = ",AccountInfoString(ACCOUNT_NAME)); Print("T.. 2020. 10. 10.
MQL5. Order, Deal, Position Order , Deal, Position Trading Operations Position Accounting System - 메타트레이더 에서는 Netting, Hedging 시스템 모두 지원되나, 이를 제공하는 브로커에 따라 헷징가능여부 결정됨. Hedging system. 동일종목에서 shot(sell) , long(buy) 동시 포지션 가능하며, 동일방향 에서도 포지션들이 개별적으로 관리됨. 아래 그림의 경우 eurusd 의 buy 포지션이 2개 있으며 개별적으로 핸들링 가능.즉, 각 포지션 별로 수익액이 계산되고 각 포지션별로 청산 가능. 위 그림의 각 컬럼 항목 - Ticket : 개별 포지션 식별용 고유 아이디로 사용됨. - Time : 포지션 오픈 시각. - Type : sell 혹은 bu.. 2019. 6. 23.
MQL5. Account void OnStart() { //--- show all the information available from the function AccountInfoDouble() printf("ACCOUNT_BALANCE = %G",AccountInfoDouble(ACCOUNT_BALANCE)); printf("ACCOUNT_CREDIT = %G",AccountInfoDouble(ACCOUNT_CREDIT)); printf("ACCOUNT_PROFIT = %G",AccountInfoDouble(ACCOUNT_PROFIT)); printf("ACCOUNT_EQUITY = %G",AccountInfoDouble(ACCOUNT_EQUITY)); printf("ACCOUNT_MARGIN = %G",AccountInfo.. 2019. 6. 3.
MQL5. input // MQL5 input example // ea file 이나, 클래스 파일등에서 global 변수로 선언하고 앞에 input 기록하면됨.input ENUM_TIMEFRAMES forecast_timeframe_fortrading = PERIOD_M15;////////////////////// 클래스 멤버 변수에서는 input 지정 불가능. input double test = 0.1; // 클래스에서 사용하는 파라메타에 input 처리할려면 전역변수로 선언되어야 함.class CCyFin_DaFoUnit : public CObject{private: public: CCyFin_DaFoUnit(); ~CCyFin_DaFoUnit(); /////////////////////////////.. 2019. 5. 27.
MQL5. memcpy 사용하기 /// myglobal.mqh etc. #import "msvcrt.dll" int memcpy(char &Destination[], int Source, int Length); int memcpy(char &Destination[], long Source, int Length); int memcpy(int &dst, int src, int cnt); int memcpy(long &dst, long src, int cnt); #import 첫등록 : 2019년 5월 21일 최종수정 : 본 글 단축주소 : https://igotit.tistory.com/2187 2019. 5. 21.
메타트레이더 . 코딩 . 클래스 non-static 멤버함수를 콜백함수로 전달하기 개요상황 : 2개의 클래스 A(예 CCyFinDevice), B(예 CCyFinOnNewBar) 가 있고, A에서 B 인스턴스 만들어 사용중이고, B에게 A측의 콜백함수를 전달해야함. 문제점클래스의 멤버함수는 콜백으로 전달 불가하므로 A에서 콜백함수를 static 으로 선언하면 B 에게 전달은 가능하다. A 의 static 함수 내부에서는 A의 멤버에 접근 못하게 되고 결국에 C스타일 코드 구조가 나와 모듈화가 달성되지 않아 견고한 구조화를 심각하게 방해한다.  해결책- 클래스 A의 non-static 멤버 함수를 콜백으로 사용가능하게 한다.  MQL5 의 EA 에서 클래스 B 로 전달할 콜백함수를 만들고, ea 의 콜백함수 내에서 클래스 A의 멤버함수를 실행하게 하고, 클래스 B측으로 EA의 함수포인터.. 2019. 5. 21.
MQL5. DLL. #import MQL5 에서 DLL 로딩하여 사용가능하며, #import 구문으로 감싸서 DLL 로딩하고 사용할 함수들의 선언들 나열하면, MQL5 코드내에서 해당함수 호출 할 수 있다. /// DLL 로딩예 #import "D:\\CyFin\\64bit\\CyFinDevice.dll" int OpenApi_CyFinDevice(); int CloseApi_CyFinDevice(); int Set_SymbolMaster_CyFinDevice(CyENUM_SYMBOL enum_symbol_master); int Set_SymbolHandling_CyFinDevice(CyENUM_SYMBOL &penum_symbol[], int num_symbol); int Set_TimeframeHandling_CyFinDevice(E.. 2019. 5. 19.
MQL5. Generic Data Collection. CHashMap. 딕셔너리 /////////////// example 1. dictionary CHashMap d; d.Add("one", 1); d.Add("two", 2); d.Add("three", 3); string keys[]; int values[]; d.CopyTo(keys, values); for (int i=0; i 2019. 5. 18.
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) typePrint(func_ptr(10)); // error: there should be.. 2019. 5. 13.


비트코인




            암호화폐/외환/나스닥/골드          
       
현물 |선물 인버스 |선물 USDT , bybit MT5               프랍 트레이딩. MT4,MT5