본문 바로가기

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


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.
MQL5. PositionsTotal PositionsTotal Returns the number of open positions. int PositionsTotal(); Return Value Value of int type. 설명. - 헷징 계좌인 경우엔 2개 이상의 포지션 가능. 헷징계좌아닌 경우엔 1개의 포지션만 가능. - EA 가 배치된 챠트의 symbol 포지션 이 아닌 계좌에서 오픈된 "모든 symbol"의 포지션 수량 반환. 상세. https://www.mql5.com/en/docs/trading/positionstotal Documentation on MQL5: Trade Functions / PositionsTotal www.mql5.com 첫등록 : 2019년4월19일 최종수정 : 본 글 단축주소 : https://igo.. 2019. 4. 19.
MQL5. NormalizeDouble NormalizeDouble Rounding floating point number to a specified accuracy. double NormalizeDouble( double value, // normalized number int digits // number of digits after decimal point ); 사용목적 : 실수값의 소수점이하 자리수 명시적으로 지정하여 실수값의 정확도 달성하기 위함. 사용예. double a; // 변수 선언. a = 12.456 * 블라블라.. //이것저것 연산으로 a 값을 계산, double a_nom = NormalizeDouble(a, Digits()) ; Digits() : EA 가 적용중인 symbol 의 소수점이하 자리수를 반환하며 symb.. 2019. 4. 19.
메타트레이더 5. MetaEditor. MQL5 Script. CyClosePositionAll 개요 MQL5 에서의 Script 는 챠트에 배치되면 1회 실행 되며 코드 내에서 OnStart 라는 이벤트 핸들러가 있다. 1. MetaEditor 에서 Script 파일 생성하는법. 2. 스크립트 코드 구현예로 스크립트 실행시 보유한 포지션 모두 청산시키는 기능 구현 코딩 과정 보임. 기타. 용어 "스크립트" 때문에 "스크립트 언어" 와 유사한 형식의 것인가? 라고 생각할 수 도 있는데, C++ (MQL5) 로 작성되며 컴파일하여 실행바이너리 생성된다. MetaEditor 에서 신규 스크립트 생성하기. - 본 예에서는 Scripts 하위에 폴더 igotit 를 만들고 이곳에 스크립트 파일(이름 예 : CyClosePositionAll ) 생성한다. 코드 - 아래 소스 코드 처럼 작성하자. 기본 생성된.. 2019. 4. 19.


비트코인




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