거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

TypeToBytes - MetaTrader 4용 라이브러리

조회수:
9153
평가:
(35)
게시됨:
2016.10.27 13:43
업데이트됨:
2017.05.15 16:53
\MQL4\Include\
TypeToBytes.mqh (11.92 KB) 조회
\MQL4\Scripts\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

This cross-platform library allows to conveniently perform byte-wise operation with structures and standard data types.

Features:

  • Byte-wise comparison (== and !=) of the structures and standard data types with each other (in MQL, the operators for comparing structures are absent by default).
  • Determining the byte shift of a structure filed by its name.
  • Reading the value of any standard type by the byte shift in the source data.
  • Writing structures and standard types by byte shift to the source data.
  • Converting structures and standard data types into a byte array.
Everything mentioned applies to simple structures.

A script with detailed comments is attached to demonstrate the capabilities of the library
// MQL4&5-code

#property strict

#include <TypeToBytes.mqh>

#define PRINT(A) ::Print(#A + " = " + (string)A);

void OnStart( void )
{  
  MqlTick Tick;
  ::SymbolInfoTick(::Symbol(), Tick);

  MqlTick CloneTick = Tick;

// Operation with structures
  if (_R(Tick) == CloneTick)             // Now the structures can be compared
    ::Print("Equal");

// Get the result of the required type by shift
  PRINT(_R(Tick)[(datetime)0])           // Check the 'datetime' value with the zero shift in the object of the MqlTick structure - Tick.time

// Get the shift of the structure field
  const int Offset = _OFFSET(Tick, bid); // Found the shift in bytes of the bid field in the MqlTick object

  PRINT(Tick.bid)                        // Checked the value of Tick.bid
  _W(Tick, Offset, (double)1.23456);     // Wrote the (double)1.23456 value at the found shift
  PRINT(Tick.bid)                        // Made sure that the Tick.bid is now equal to 1.23456

  PRINT(_R(Tick)[(double)Offset])        // Printed the 'double' value located at the shift Offset - it is Tick.bid again

  PRINT(_R(Tick).Bytes[8])               // Checked the value of byte with the shift of 8 in the object of the MqlTick structure
  PRINT(_R(Tick)[(uchar)8])              // The same, but using a different method

  PRINT(CloneTick.bid)                   // Checked the value of CloneTick.bid
  _W(CloneTick, 0, Tick);                // Wrote the value of the Tick structure object to the CloneTick at the zero shift
  PRINT(CloneTick.bid)                   // Made sure that CloneTick.bid == Tick.bid

// Operation with the standard types
  color Color = C'241,248,255';

  PRINT(_R(Color)[(uchar)1])             // Green component of the color - 248

  _W(Color, 2, (uchar)230);              // Wrote the (uchar)230 value at the shift of 2.
  PRINT(Color)                           // Made sure that Color is now C'241,248,230'

// Simultaneous operation with mixed types
  if (_R(Tick) != Color)                 // It is even possible to compare structures with standard types
    ::Print("Not equal");

  return;
}

 

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/16282

PriceLines PriceLines

Script for drawing a price markup.

Multi Timeframe Moving Average Multi Timeframe Moving Average

The indicator displays the moving average for the selected timeframe.

News EA Template without DLL News EA Template without DLL

Template EA that downloads news without the use of DLL.

Basket Chart Creator Basket Chart Creator

Basket offline chart creator script using geometric mean method.