-1

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

I.E.

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

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?

2 Answers2

4

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

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 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... )

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.


Second, let's focus on your target

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.

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 ).

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

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

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


Third, let's go get the job done

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

  • If not, go and ask them to open it for you.

If not,

  • change the Broker to such one, who will.

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.

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

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.

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

Passive TAMARA-sniffer reads your Broker inter-arrival times (msec) see fastest vs. typical TimeDOMAIN alignments for Hard-Real-Time-System mode of operations

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 ).

( 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)

Active SONAR-echo response latency End-to-End (msec) - read the details on Terminal screen

)

Worth doing the job right nevertheless.

user3666197
  • 1
  • 6
  • 50
  • 92
  • 1
    Not bad...you have a solid grasp of market depth. Seems like you are experienced in algorithmic trading data models. Ever work with Quantopian? – Frank Tudor Jul 15 '14 at 17:55
  • @user3666197 Your response is gorgeous, probably art. You have opened my eyes to a lot. But I am still confused about actually how to dump the data and hopefully in the fastest possibly manner. I will be running a momentum physics calculation directly against the data. –  Jul 15 '14 at 20:36
  • @user3766148 Data acquisition is possible. Depends on your Broker response(s). Solution integrated into MT4/MQL4 environment works fine via low-latency distributed processing. First get rather your Broker answers, that could save your Project a lot of time+efforts. – user3666197 Jul 17 '14 at 07:05
  • @user3766148 Your idea about momentum shall take into consideration a rather **wild** fact, that Financial Markets have an unparallel *advantage* of having **Zero Momentums of Inertia** ( the less their products ) -- so be carefull :o) – user3666197 Jul 17 '14 at 07:07
  • @FrankTudor Thanks for your compliment, Frank. Yes, after some 25 years in trenches, there shall be some overview to work with. With regards to Quantopian, I tested this community project few years ago and it was in rather early stage those days. Speaking in technical terms, have successfully integrated heterogenous multi-process use of **python** processes integrated to **MT4** threads processing for many purposes -- as ExternalCLI, -- as CentralSysLOG, -- as ExternalSupportVectorMachineAI component, -- as ExternalTradinSignalRCVR, -- as ExternalTradingSignalXMIT ... to name a few at least – user3666197 Jul 17 '14 at 07:19
  • as stated in the original question. how do I retrieve the market data from btc-e. I am not concerned forex or other, just btc-e for now. Here I found the url for an http GET https://btc-e.com/api/2/btc_usd/depth (which is the exact/identical data I am looking for) but doing 50 http GET request to that API per second, to ensure proper reporting, just doesn't seem to me to be the correct method. Is there a PUSH service with btc-e? How do others get accurate reporting on market depth and ticker data? depth can be slower, but ticker has to be real time. –  Jul 25 '14 at 10:13
-1

There are two volume types. One is iVolume and then there is iOBV or on balance volume.

Here is the volume document:

http://docs.mql4.com/series/ivolume

On balance volume is nice for targeting the mean volume based on your symbol for a duration of time. Having a long term obv can generate a trend.

Here is obv:

http://docs.mql4.com/indicators/iobv

Now about volume. There is no way determine 'pending' volume it is always a historical indicator.

If you have a guy who has 10 ltc and wants to sell for 7.50 and someone wanting to buy 10 for 7.49 and there is no order change you have no volume as one waits the other out and who knows how long it takes.

With that said you might want to look at open interest on the buy and sell side and possibly extrapolate the potential.

Last point. LTC and BTC are very difficult to peg trends. I have looked at the technicals and all I can say is that stocks look like a tame kitten compared to LTC OR BTC.

Finally. I bet you didn't know that Stack Exchange has a bitcoin site. I bet this question would get more airplay over there. http://bitcoin.stackexchange.com

Good luck!

Frank Tudor
  • 4,226
  • 2
  • 23
  • 43
  • iVolume does not list all of the pending orders and neither does iOBV. I do not want another parties volume calculation, I want to do my own. on bitcoinwisdom, they have the pending orders, the chart on the right hand side. I want the exact same information without having to use scrapy. –  Jul 15 '14 at 00:24
  • @data scraping: as far as low-latency near-RT-loop mentioned above, there are much more productive techniques for this emergency-mode data acquisition. Having developed options pricing model scanners for LSE/FTSE, AMS/AEX, PAR/CAC and FKT/DAX options, there is a way to go ahead without a need to subscribe to scrapy. – user3666197 Jul 15 '14 at 08:48
  • iOBV does me no good. It only reports total volume. I am trying to do volume analysis and need the raw data and 'not' the result. –  Jul 25 '14 at 10:19