vdemydiuk / mtapi

MetaTrader API (terminal bridge)
http://mtapi4.net/
MIT License
514 stars 277 forks source link

What limits the number of candles returned by CopyRates()? #225

Closed eabase closed 3 years ago

eabase commented 3 years ago

I'm not sure this is an issue, but is seem like the CopyRates function is only able to receive 3086 candles. Since my terminal MaxBars are set to 512,000, I believe it is a broker issue.

  INFO: CopyRates: Symbol    :  EURUSD
  INFO: CopyRates: TimeFrame :  M5
  INFO: CopyRates: Requested :  10000 candles
  INFO: CopyRates: Received  :  3086 candles
  INFO: CopyRates: ErrorCode :  0

This is approximately (3086 candles * (1 hr/12 candles) * (1 day/24 hr) = 10 days of trading data. This also coincide with the chart scroll back.

Is there a way to see a priori, how much data is available on the chart, given a TF?

KptKuck commented 3 years ago

https://docs.mql4.com/series/copyrates

look at the example

eabase commented 3 years ago

@KptKuck

  1. First of all, I've obviously already looked there, since I am getting the data already, just not the amount I expected. (Also that example is for MQL, and I'm using Python.)
  2. AFAICR @vdemydiuk mentioned in the telegram channel, he implemented the method to get a List<MqlRates> for both MT4 and MT5 version, which is not of the format you linked to.
  3. I'll be the first to admit I don't understand why the MQ docs state to return <int> whereas mtapi choose to deliver a list (as above)?

This works in Py3:

rA  = client.CopyRates(SYM, TF, startPos, count)        # MT4:  List<MqlRates>
len(rA)
# 3112

Look like I a might be able to use iBars()...

cc=client.iBars('EURUSD',5)
# 3112

Still no answer if this is a broker, buffer issue, or an API issue? (What is setting the limit?)

KptKuck commented 3 years ago

Try a restart from MT4 after setting MAX_BARS

eabase commented 3 years ago

This is not a MAX_BARS issue, AFAIK.
Most likely a broker issue. (Scrolling back the charts give the same limits.)

KptKuck commented 3 years ago

@eabase ok

eabase commented 3 years ago

I think I just have a really shitty broker. So I'll close this for now.

KptKuck commented 3 years ago

I think I just have a really shitty broker. So I'll close this for now.

MT5 Python Example Count is at 250000. no problem grafik

eabase commented 3 years ago

@KptKuck Can you show how you got the events to work for you? I'm not able to get the ConnectionStateChanged working properly.

KptKuck commented 3 years ago

@eabase grafik MT5 !!!

eabase commented 3 years ago

Great! My first attempt didn't work for some reason.