본문 바로가기

트레이딩   ( 420 )


메타트레이더 . 코딩 . 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.
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.
ATR. Average True Range. 변동성 측정수단. ATR. Average True Range 개요. ATR 정의. True Range 의 N 이동평균. 설명 : N기간 동안의 가격 변동성 측정 수단 중 하나, 현재시점 가격변동폭 정의시 2개 봉(현재봉+직전봉)의 true range 의 N이동평균으로 정의. 통상 N = 14, 20 많이 사용함. ATR 의미 : 과거 N ~ 현재시점 까지의 봉단위로 측정된 가격폭의 평균 값. ATR 값이 크면 변동성 높음, 작으면 변동성 작음. ATR 활용예 1. 가격 변동성파악. 2. 손절 익절 기준으로도 활용됨. 예 : 손절폭 = ATR 값 x 3, 익절폭 : ATR 값 x 1.5. N 값과 적절한 곱하기 비율은 연구해볼것. True Range 정의. TrueRange = TrueHigh - TrueLow. where.. 2019. 4. 28.
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.
DI. DX. DMI. ADX. ADXR. Directional Movement Index. Directional Movement Index DI, DX(DMI), ADX, ADXR 개요. -DI ( = DIM) 정의. -DI( = DIM) = 전저가 - 현저가, if 전저가 > 현저가 이면서 (현고가 - 전고가) 전고가 이면서 (현고가 - 전고가) > (현저가 - 전저가) ---(2) +DI( = DIP) = 0 if 상기 (2)가 아닌 경우. 의미 : +DI 값이 증가하면 가격 상승중. 0 = 상승은 아님. DX( = DMI, Direct.. 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.
메타트레이더5. 파이썬에서 금융시계열 데이터 쉽게 활용하기 개요 파이썬에서 금융시계열 데이터 가져와서 활용하기 위한 방법으로 메타트레이더5 기반한 방법. 사전 필수 준비사항.1. 메타트레이더 5 설치된 상태. - 암호화폐 거래소 바이빗의 MT5 , IC Market MT5 등 아무거나 설치해도 됨. 2. 상기 1의 MT5 에서 Account 연결된 상태.- 계정은 모의계좌여도 됨. - Account 연결되어있어야 데이터 공급받을 수 있기 때문에 필수. 3. 파이썬 3.7 개발/실행환경 - 본 예에서는 Visual Studio 2019 의 파이썬 개발환경 이용. - VS2019 의 파이썬 개발환경 설치 상세 : https://igotit.tistory.com/2113- PyCharm 이용해도 됨. 4. 파이썬용 메타트레이더5 패키지 - 본 패키지에 의하.. 2019. 4. 21.
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.


비트코인




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