- We will never get these information on Forex, simply because they are not provided by the broker. On some broker (still talking about Forex) you will find FLAG_BUY and FLAG_SELL set, but always both at the same time.
- There is an undocumented flag (=128), seems it's more internal information from MT5, I asked to the developer but I didn't understand clearly the answer.
- CopyTicks() and CopyTicksRange() have several weaknesses (or bugs ? ), and they seems to be too slow. Well they can manipulate a lot of data so it takes time but it seems too much time. I am currently trying to get answers from developers.
Thank you Alain for your reply!
ADD: We will never get these information on Forex, simply because they are not provided by the broker. On some broker (still talking about Forex) you will find FLAG_BUY and FLAG_SELL set, but always both at the same time.
Ok, that makes sense then.
ADD: There is an undocumented flag (=128), seems it's more internal information from MT5, I asked to the developer but I didn't understand clearly the answer.
I need to look at this...
From your answer, it looks like to me that the only way to separate between BUY and SELL ist to use BID, ASK and LAST from MqlTick as shown by the user above. However, as stated, the LAST value is Always 0. Could this be one of the bugs you mentioned? if not, is this an information not provided by the broker then? However, due to the fact that CopyTicks is super slow it seems not to be an option too...
I haven't looked yed really into the volume/tick Indicators available at https://www.mql5.com/en/code/mt5/indicators. However, it seems that there are some that can provide the number of BUY/SELL ticks. Question really is, if this is correct or not when there might still be some Bugs. Alternatively, they might use different information to calcualte which I haven't yet came across?!
- www.mql5.com
...
From your answer, it looks like to me that the only way to separate between BUY and SELL ist to use BID, ASK and LAST from MqlTick as shown by the user above. However, as stated, the LAST value is Always 0. Could this be one of the bugs you mentioned? if not, is this an information not provided by the broker then? However, due to the fact that CopyTicks is super slow it seems not to be an option too...
I haven't looked yed really into the volume/tick Indicators available at https://www.mql5.com/en/code/mt5/indicators. However, it seems that there are some that can provide the number of BUY/SELL ticks. Question really is, if this is correct or not when there might still be some Bugs. Alternatively, they might use different information to calcualte which I haven't yet came across?!
Already answered. If they provide BUY/SELL ticks that's not on Forex, if they claims it is they are wrong, unless they use some external data (maybe).
Thanks Alain and Zee for your comments so far. I took some time to rethink about this Topic and I am agree with you that you do not get BUY and SELL Tick Data from Forex. However, what I probably actually meant was to decompose the tick volume you get from iVOlume into its Bid and Ask ticks. I searched the Code base and found an indicator stating the following:
"This indicator provides the analysis of tick volume deltas. It monitors up and down ticks and sums them up as separate volumes for buys and sells, as well as their delta volumes."
This is actually I want to achieve too. I guess I am right saying that the author means the Bid and Ask ticks by using the Notation Up and Down ticks?!
So, I tested this using the following Code:
if(NewBar()) { Print("ASK_N: ", ASK_N); Print("BID_N: ", BID_N); Print("iVolume: ",iVolume(_Symbol,_Period,1)); Print("--------------------------"); } MqlTick tick; if(SymbolInfoTick(Symbol(),tick)) { if(ASK!=tick.ask) { ASK=tick.ask; ASK_N++; } if(BID!=tick.bid) { BID=tick.bid; BID_N++; } }
The result is for 3 bars is:
2018.12.08 14:34:28.840 2018.07.16 00:10:00 ASK_N: 127 2018.12.08 14:34:28.840 2018.07.16 00:10:00 BID_N: 101 2018.12.08 14:34:28.840 2018.07.16 00:10:00 iVolume: 170 2018.12.08 14:34:28.840 2018.07.16 00:10:00 -------------------------- 2018.12.08 14:34:32.628 2018.07.16 00:20:01 ASK_N: 215 2018.12.08 14:34:32.628 2018.07.16 00:20:01 BID_N: 188 2018.12.08 14:34:32.628 2018.07.16 00:20:01 iVolume: 118 2018.12.08 14:34:32.628 2018.07.16 00:20:01 -------------------------- 2018.12.08 14:34:35.722 2018.07.16 00:30:02 ASK_N: 269 2018.12.08 14:34:35.722 2018.07.16 00:30:02 BID_N: 252 2018.12.08 14:34:35.722 2018.07.16 00:30:02 iVolume: 88 2018.12.08 14:34:35.722 2018.07.16 00:30:02 --------------------------
As can bee seen, the sum of the ASK and BID ticks is pretty different to the tick volume recevied bei the iVolme function.
After reading through this Topic, the only thing I can think of is that iVolume is increased when a DEAL is performed and a change in ASK and BID does not Always result in a DEAL?
Any ideas on that? Best!
What I just found is that:
https://www.mql5.com/en/forum/109552/page2#comment_3049186
In particular: "Volume is equal to the number of ticks received, i.e. the number of times the start() function was called, it is not specifically trades or Bid/Ask changes. Change in MarketInfo()triggers a tick, and tick count = volume."
So, the Question might rather be: Is there any link/correlation between the BID/ASK ticks and the Tick Volume?
Luckily my first research is not into ticks. Otherwise it will be no ending conclusion. :/
Trying to count the number of buy and sell ticks is like having the observer effect in physics.
I.e. by the time you count it, the actual value has already changed.
You can try to get an estimate, but never an accurate value on the number of buy/sell ticks.
Ticks are instantaneous ticks, but you are measuring it in what time granularity?
I will just take what is given by iVolume (number of ticks per unit period) as it is the more reliable figure, and use it to "simulate" buy/sell volume.
And tick.ask and tick.bid will only be used when checking prices and spread before opening a trade.
algotrader01:
I totally agree with @Zee Zhou Ma post above, but let's see why it's an illusion.
Thanks Alain and Zee for your comments so far. I took some time to rethink about this Topic and I am agree with you that you do not get BUY and SELL Tick Data from Forex. However, what I probably actually meant was to decompose the tick volume you get from iVOlume into its Bid and Ask ticks. I searched the Code base and found an indicator stating the following:
"This indicator provides the analysis of tick volume deltas. It monitors up and down ticks and sums them up as separate volumes for buys and sells, as well as their delta volumes."
This is actually I want to achieve too. I guess I am right saying that the author means the Bid and Ask ticks by using the Notation Up and Down ticks?!
It's plain wrong assumptions. Who said a tick is a trade ? Bid/Ask are changing for different reasons, one of them is there was a trade but that's not even the main one. What is the meaning of a tick where Bid and Ask both changed ?
Most people are fooling themselves on that matter, in the best case, in the worst you have scammers trying you to sell you a grail. Be careful.
So, I tested this using the following Code:
The result is for 3 bars is:
As can bee seen, the sum of the ASK and BID ticks is pretty different to the tick volume recevied bei the iVolme function.
After reading through this Topic, the only thing I can think of is that iVolume is increased when a DEAL is performed and a change in ASK and BID does not Always result in a DEAL?
Any ideas on that? Best!
What I just found is that:
https://www.mql5.com/en/forum/109552/page2#comment_3049186
In particular: "Volume is equal to the number of ticks received, i.e. the number of times the start() function was called, it is not specifically trades or Bid/Ask changes. Change in MarketInfo()triggers a tick, and tick count = volume."
So, the Question might rather be: Is there any link/correlation between the BID/ASK ticks and the Tick Volume?
iVolume() doesn't take into account "Ask only" ticks. See here.
So I repeat again, there is NO WAY to get Buy/Sell information on Forex with MT4 or MT5 data.
- 2018.11.26
- www.mql5.com
What I know already is that tick.flags is a sum of different FLAGs. However the total sum of all flags is (64+32+16+8+4+2) 126. So what does it mean when tick.flag is 130 or 134 as seen in the output?
As we can see there seem to exist to different Methods to count the number of SELL and BUY ticks:
1. Using Tick.Last and compare it to Tick.Buy and Tick.Sell
2. Use the TICK_FLAG_* Information
However, I don't quite understand by now how to use the second method to separate the volume into BUY and SELL ticks.
I further do not understand why I only get the string BID| , ASK| and BID|ASK and Nothing for the volume and the BUY and SELL flag. I read that BUY and SELL Flag depends on the broker or on the market itself? I tested two different Brokers, JDF and ActivTrades and in both cases EUR/USD results in BID|, ASK| and BID|ASK| and every Index in BID|ASK| only.
Can also anybody Image why CopyTicks using COPY_TICKS_TRADE slows down the Backtester so much?
Can anyone please shed some more light into this?
might be late but i just started playing around with MQL5 around 3 weeks ago..i hope this below snippet of the backtester log can give you a clearer view, not sure if this would fit your case
MH 0 02:26:29.507 Tester _Near=3 JI 0 02:26:29.507 Tester _Far=9 RL 0 02:26:29.554 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 Start copying bar data from previous 4 EH 0 02:26:32.101 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 USDJPY: received 8230272 ticks in 2547 ms ID 0 02:26:32.101 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 Last tick time = 2020.05.01 23:57:41.204 DD 0 02:26:32.101 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 First tick time = 2019.11.25 00:00:01.108 NP 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 Tick array size is 63| CHARTMODE=SYMBOL_CHART_MODE_BID | ThisBar TickVolume: 49 HK 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 Looping the tick_array after CopyTicksRange MN 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:1 LR 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:2 OF 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:3 NJ 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:4 MN 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:5 PR 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:6 OF 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:7 FJ 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:8 IN 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:9 GP 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:10 RD 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:11 QH 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:12 PL 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:13 KP 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:14 FS 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:15 EG 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:16 HK 0 02:26:32.122 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:17 LO 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:18 ES 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:19 MG 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:20 PK 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:21 OO 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:22 FR 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:23 IF 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:24 HJ 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:25 CN 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:26 RR 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:27 EF 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:28 HJ 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:29 RN 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:30 CQ 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:31 DE 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:32 EI 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:33 FM 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:34 OQ 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:35 LE 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:36 MI 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:37 FM 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:38 KP 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:39 GD 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:40 FH 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:41 EL 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:42 LP 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:43 KD 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:44 RH 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:45 QL 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:46 DO 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:47 OS 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:134 count:48 RG 0 02:26:32.123 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:49 GD 0 02:26:32.136 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 Tick array size is 195| CHARTMODE=SYMBOL_CHART_MODE_BID | ThisBar TickVolume: 119 GE 0 02:26:32.136 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 Looping the tick_array after CopyTicksRange PJ 0 02:26:32.136 RGJ2EMA3-267 (USDJPY,M6) 2020.05.04 00:00:00 This tick FLAG NO:130 count:1
since my broker set the chart mode to bid, i removed the flag no 4 which the "ask" and i got the consistent count value between copyticks result and
tickvolume from copyrates..hope this helps..
Correct, a bid-price change = tick-volume change,
ask-price change doesn't add to the tick-volume.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hey folks, i pretty much read all forum entries regarding CopyTicks, TICK_FLAG_*, TickCounter functions etc. but I still struggle to understand what is going on there. I also could not find any Website clearly explaining that. Here is my code so far:
The code for EUR/USD results in:
The string s prints either BID| , ASK| or BID|ASK| but nothing else.
The code for any Index results in:
The string s prints Always BID|ASK|
The MQL5 Indicator
prints the Volume in the Backtester and as well R, iVolume and iTickVolume return all the same values. So that is fine!
What I want to achieve is to separate the Tick Volume for a Bar into the number of BUY and SELL ticks. So, for instance, a bar has 60 ticks, I want to know in how many BUY and SELL ticks it separates.
In this forum, I also found the following code to count the BUY and SELL ticks. However, I cannot use it as tick.last is Always 0. The same appears to tick.volume even though R, iVolume and iTickVolume return some Volumes.
What I know already is that tick.flags is a sum of different FLAGs. However the total sum of all flags is (64+32+16+8+4+2) 126. So what does it mean when tick.flag is 130 or 134 as seen in the output?
As we can see there seem to exist to different Methods to count the number of SELL and BUY ticks:
1. Using Tick.Last and compare it to Tick.Buy and Tick.Sell
2. Use the TICK_FLAG_* Information
However, I don't quite understand by now how to use the second method to separate the volume into BUY and SELL ticks.
I further do not understand why I only get the string BID| , ASK| and BID|ASK and Nothing for the volume and the BUY and SELL flag. I read that BUY and SELL Flag depends on the broker or on the market itself? I tested two different Brokers, JDF and ActivTrades and in both cases EUR/USD results in BID|, ASK| and BID|ASK| and every Index in BID|ASK| only.
Can also anybody Image why CopyTicks using COPY_TICKS_TRADE slows down the Backtester so much?
Can anyone please shed some more light into this?