如何使用MQL4获取市场数据? [英] How do I get market data with MQL4?

查看:563
本文介绍了如何使用MQL4获取市场数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用metatrader4,可以从btc-e中获取任何信息,但可以从"市场数据中获取 http://docs.mql4.com/constants/environment_state/marketinfoconstants

I am using metatrader4 and I can get any information 'but' the market data from btc-e http://docs.mql4.com/constants/environment_state/marketinfoconstants

IE.

double pending = MarketInfo(Symbol(),MODE_PENDING);
MessageBox(
  DoubleToStr(pending)
);

就像此图表右侧的市场数据一样 https://bitcoinwisdom.com/markets/btce/ltcusd ,所有待处理的买卖订单,相同的市场以及所有其他内容. 如何使用MQL4转储挂起的卷?

just like the market data on the right hand side of this chart https://bitcoinwisdom.com/markets/btce/ltcusd , all the pending buy/sell orders, same market and everything. How do I dump the pending volume using MQL4?

推荐答案

首先,让我们从< 代码>-片段错误概念

First, let's start with the <code>-snippet mis-concept

如提供的< code >-片段中所示,存在主要错误/错误概念.虽然MQL4代码的语法在编译器阶段是可行的(将其处理为可操作的.ex4运行时代码),但结果基本上是错误的.

As seen in the provided <code>-snippet, there is a principal error/mis-concept. While the syntax of the MQL4-code is compiler-phase feasible ( it gets processed into an operational .ex4 runtime-code ), the result is principally wrong.

MQL4具有许多枚举常量,在MetaLang.exe编译阶段,这些常量过去用于零使用上下文检查. (是的,不得不说曾经拥有",由于MetaQuotes,Inc.的事实,最近对隐藏"语言的修改已改变了许多系统行为,即使是在MQL4的语法中,也将其称为还是Orwel风格的"New" -MQL4,因此在移动沙子的情况下,人们甚至必须更加注意细节...

MQL4 has a lot of enumerated constants, which used to have zero context-of-use checking in the MetaLang.exe compilation phase. ( Yes, had to say "used to have", due to the fact MetaQuotes, Inc., recent move into "hidden"-language modifications has changed a lot of system behaviour, even in the syntax of MQL4, calling it in a rather Orwel-style "New"-MQL4, so one has to pay attention to detail even more under the conditions of moving sands... )

如前所述,ENUM_CONST就像您尝试使用 MODE_PENDING 一样,在语言中具有合理的含义,但是除了编译时替换值.因此,可以在任何地方声明 MODE_HIGH (btw == 2),其中 MODE_SMMA (btw == 2)具有适当的上下文-使用.这些只是在编译器解析阶段的符号替换.

As expressed, an ENUM_CONST alike your attempt to use MODE_PENDING, has a fair meaning in the language, but that does not guarantee anything but a compile-time substitution of a value of int. Thus one might state a MODE_HIGH ( btw == 2 ) in any place, where MODE_SMMA ( btw == 2 either ) would have an appropriate context-of-use. These are just symbolic substitutions during the compiler parsing phase.

第二,让我们专注于目标

如所见,您希望以某种方式对一组有关总金额和费用的知识进行操作.待处理订单的各自大小,它们在市场转为活跃之前先等待".这是一项复杂而艰巨的任务.由于FX没有中心"市场,因此可以收集全球总和.

As seen, you would like to somehow operate on a set of knowledge about an overall amount & respective sizes of pending orders, that wait "on the table" before the market turns them active. This is a complex and non-trivial task. The more as FX has no "central" marketplace, to collect the global overall sum of sums.

谈论其"音量"带来了另一种困惑.正如在MQL4中实现的 Volume ,它是一个离散的整数值,与相应条形图中的累积价格变化量有关.因此,在aNewBarEVENT上,Volume[0] == 1(第一个价格报价行情刚到并已带来aNewBarEVENT本身的指示),并且该值在整个实时柱([0])期间逐步增加.可能还会有人注意到,对于没有来自市场"的价格报价出现的柱线,MT4在图中没有显示任何柱线(缺少蜡烛).

Speaking about "volume" thereof opens another confusion. Volume, as implemented in MQL4 is rather a discrete integer value related to a cummulative amount of price changes within the respective bar. Thus, on aNewBarEVENT, the Volume[0] == 1 ( the first price-bearing-quote has just arrived & has brought the indication of aNewBarEVENT per se ) and this value is step-wise increasing throughout the live-bar ( [0] ) duration. One may also note, that for bars, where no price-quote appeared "from Market", the MT4 does not show any bar in the graph ( a missing candle ).

因此,请务必谨慎使用 Volume 一词,以确保获得完整的使用范围.

So always be carefull on using the word Volume, to assure, one gets it's full context-of-use.

从您的帖子中可以发现的您的意图是获取 OrderBook LEVEL-2 又称市场深度.

Your intention, as far as detectable from your post, is to obtain an OrderBook LEVEL-2 a.k.a. Depth-Of-Market.

尽管这是可能的,但与MQL4代码中的单行代码相比,这将需要更多的组装工作.

While this is possible, this will require more efforts to assemble, than just a one-liner in MQL4 code.

第三,让我们完成工作

可能是,您的经纪人已准备好API服务,供您收集和使用.处理L2 DoM.

May be, your Broker has an API-service ready for you to collect & process the L2 DoM.

  • 如果不是,请让他们为您打开它.

如果没有,

  • 将经纪人更改为愿意的经纪人.

还有其他来源可以构建&保持二级DoM,但您的交易执行场所的相关性尚待验证,因为一旦与模型进行交易,某些交易可能会通过MarketMaking角色使您的策略瘫痪.

There are other sources to build & maintaing L2 DoM, but the relevance for your Trade-Execution-Venue is to be verified, as some could make your strategy crippled via a MarketMaking role, once trading against your model.

您的经纪人-本地" L2 DoM Rulez. 始终如此.不值得为此付出损失以检验相反的情况.

Your Broker-"local" L2 DoM rulez. Always. Not worth the losses to test the contrary.

如果准备好执行此任务,请准备在超低延迟的体系结构上运行,因为L2 DoM演化动态中的亚毫秒级节奏并不罕见.

If getting ready for this task, be ready to operate on ultra low latency architecture, as sub-milisecond cadencies in L2 DoM evolution dynamics are not uncommon.

一旦上路",您很快就会注意到,MQL4的计时器分辨率高于 1毫秒.

Once "on the road", you will soon notice, that MQL4 has a timer resolution above 1 msec.

因此,您用于查询+收集+清理+处理+处理+发布+使用自己的本地L2 DoM映射的计算策略从一开始就存在麻烦(更不用说由于端到端传输而导致的地图主要倾斜)延迟).

Thus your computational strategy to query+gather+sanitize+process+publish+use your own local L2 DoM mapping has a trouble right from the start ( not speaking about your principal skew of the map due to end-to-end transport latency ).

(还请记住,MQL4仅具有几个线程,这些线程绝对是您无法控制的.因此,必须设计仔细的多处理设计,以便在接近于非阻塞的情况下进行操作, RealTime模式,拥有类似的集成系统,您的Project确实很激动地实现目标,相信我:o)

( Kindly also do bear in mind, that MQL4 has just a few threads, that are absolutely out of your control. Thus a carefull multi-processing design has to be designed, so as to operate in a non-blocking near-RealTime mode. Having integrated systems alike this, your Project is indeed quite thrilling to achieve the goal, believe me :o)

)

尽管如此,还是值得做的.

这篇关于如何使用MQL4获取市场数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆