0

I am using MetaTrader4.Manager.Wrapper

I want to get all currency (Symbol in MT4) and their bid & ask from MT4. I tried using :

public IList<Symbol> Get()
    {
        using (var metatrader = new ClrWrapper(new ConnectionParameters
        {
            Login = serverdata.Login,
            Password = serverdata.Password,
            Server = serverdata.Server
        }, serverdata.path))
        {
            var Refresh = metatrader.SymbolsRefresh();

            IList<Symbol> Live = metatrader.SymbolsGetAll();
            return Live;

        }
    }

From the code i got the Name : AUDCAD, AUDCHF, EURCHF, etc, but BidTickValue and AskTickValue return 0.0.

I tried using this answer but the Symbol return null and Bid return 0.

Is there another way to get the Name and Bid and Ask value? And what is Pumping Mode means? Thank you before

Community
  • 1
  • 1

2 Answers2

0

Pumping is MT4 mode, when you subscribe to different events and MT4 server sends you updates, without requesting it manually.

For example: quotes, trades, users.

SymbolsGetAll will return you quotes only when you in pumping mode, and it will return latest received quote.

If you are not going to use pumping mode, you can get latest quote user ChartRequest method, but it will be much slower.

Uriil
  • 11,948
  • 11
  • 47
  • 68
  • If i'm using `ChartRequest`, i only get bid value using `Mode = ChartRequestMode.RangeLast` in `period = ChartPeriod.M1`. How can i get the ask value? I also try using pumping mode. Here is the code : – Chang Hong Mar 07 '17 at 04:45
  • http://imgur.com/a/WHndk (the code). i copy paste from you example in github. All i get is the same one without pumping mode. Can you give me any example to get the bid and ask using asp.net web api + MetaTrader4.Manager.Wrapper? @Uriil – Chang Hong Mar 07 '17 at 04:57
  • Here I have example: https://github.com/Uriil/MetaTrader4.Manager.Wrapper/wiki/Real-time-ticks – Uriil Mar 07 '17 at 05:30
  • i'm using your example but in `symbolsInfos` return null. – Chang Hong Mar 07 '17 at 05:53
  • if i'm using `ChartRequest` i got `Open` value from `Rateinfo`. After i compare it with market watch the `Open` value = Bid in market watch, then how do i get the ask value? @uriil – Chang Hong Mar 07 '17 at 07:23
  • @ChangHong to get ask, you need to add bid, which you can get from symbol configuration structure. Regarding `symbolInfos == null`. Please provide me example with temporary credentials, so I can check it. Because I think you missing something and above code works for me – Uriil Mar 07 '17 at 07:40
  • i change `Console` to `Debug` and it come out, now how to return it because i'm using web api and i cant return it. Which one symbol configuration structure? – Chang Hong Mar 07 '17 at 07:52
  • It's to wide question and we can not discuss it in comments. – Uriil Mar 07 '17 at 07:59
  • is there any way? maybe email ? Can you explained more detailed how to get the ask? – Chang Hong Mar 07 '17 at 08:05
0

You can get the quotes with bid and ask directly without manager API. Simply you can send a socket to MT4 server. Here is an example:

// 1. Start Session.
$ptr=fsockopen('127.0.0.1',443);
// error check
if (!$ptr){
  echo "Connection error";
  exit;
}
// 2. Send request to MT4
fputs($ptr,"WQUOTES-EURUSD,GBPUSD,USDJPY,\nQUIT\n");
// 3. Reading and processing server responses
while(!feof($ptr))
  {
   // read line of symbols
   $line=fgets($ptr,128); 
   // the symbol of the end of result transfer
   if($line=="end\r\n") break; 
   // process
   print $line; 

  }
// 4. Session completion
  fclose($ptr);

The above will print the quotes in this format: direction symbol bid ask date time.

M.Hatoum
  • 69
  • 3