Creating a TickCounter using MqlTick and CopyTicks [suggestions plz] - page 2

 
Vasyl Nosal:

Why just not create counter?

This topic is about mql5.
 
yalewang:

i tried to copy  MQLtick ,but in different MT5 terminal ,the result is different .

the flags is 6 or 24 .

the volume is 0 or a very large number .

I think MQLtick is not a practical stucture .

MqlTick() is working well. What is your problem ?
 

Hi all,

Thanks for the replies, but, i still cant get this to work.

All i wanted was to "create" a rolling vector of the last N tick directions.


i.e.:

MT5 flashes last tick as blue in market watch -> upward change

MT5 flashes last tick as red in market watch -> downward change


i even tried the MQL support , but without any success..

if i managed to do this, i'd them use this "vector | structure of rolling directions" to infer some kind of trading signal. or maybe even calculating some indicator out of it.

 
I still don't understand anything to your problem. MqlTick gives you the direction of a tick. If you want to average direction of last N ticks, just calculate it, what is so difficult ?
 
Alain Verleyen:
  If you want to average direction of last N ticks, just calculate it, what is so difficult ?

I find this exact point extremely difficult, since I would have to store a vector of N ticks that is updated every new tick.

Suppose i want to calculate the sum of the last 100 ticks direction , a vector of  "0..1...0...-1...0..1...0....1....-1....-1....(goes until 100 elements big)" where 0 is "same value of last tick", +1 is "new tick is higer" and -1 is "new tick is lower", all of them compared to the previous tick.

By the time i have the first 100 ticks, i will need to start ditching the "oldest tick direction" in this vector, and adding the newest one, so i constantly have 100 (N) ticks in my vector, so only then i can calculate whatever it is using it.

I appreciate any ideas on how to do so! :)

 

Do you consider the fact that you don't get every tick - you might miss the highest high or lowest low of a bar on the chart!

In cases of average building I use more and more the ema. It doesn't need any ind of build, admin, and refresh and calc. the arrays. It's a lot easier and faster!

If you want to detect the a development (keyword vector) I would use two ema. One with a slower and one with a longer constant and then check fast>slow or vice versa!

 
Eduardo Gonzatti:

I find this exact point extremely difficult, since I would have to store a vector of N ticks that is updated every new tick.

Suppose i want to calculate the sum of the last 100 ticks direction , a vector of  "0..1...0...-1...0..1...0....1....-1....-1....(goes until 100 elements big)" where 0 is "same value of last tick", +1 is "new tick is higer" and -1 is "new tick is lower", all of them compared to the previous tick.

By the time i have the first 100 ticks, i will need to start ditching the "oldest tick direction" in this vector, and adding the newest one, so i constantly have 100 (N) ticks in my vector, so only then i can calculate whatever it is using it.

I appreciate any ideas on how to do so! :)

Why do you need a vector ??? CopyTicks already gives you the last N ticks.

   MqlTick ticks[];
   int copied=CopyTicks(NULL,ticks,COPY_TICKS_TRADE,0,100);
   
   for(int i=0;i<copied;i++)
     {
      uint flag=ticks[i].flags;
      //--- Analyze the flag
      // ...
     }
It seems you like to overcomplicate things, not ?
 
Carl Schreiber:

Do you consider the fact that you don't get every tick - you might miss the highest high or lowest low of a bar on the chart!

In cases of average building I use more and more the ema. It doesn't need any ind of build, admin, and refresh and calc. the arrays. It's a lot easier and faster!

If you want to detect the a development (keyword vector) I would use two ema. One with a slower and one with a longer constant and then check fast>slow or vice versa!

hi there, thanks for the info.

i am, indeed, assuming that i do get every tick, as the broker here have informed us (specific brokerage from brazil), some have conduced tests and we have seen that there are actually no losses at all. but i agree with your approach, if there is the risk of losing some ticks in the way.

 
Alain Verleyen:

Why do you need a vector ??? CopyTicks already gives you the last N ticks.

It seems you like to overcomplicate things, not ?

Hi there!

Not at all, Alain, i do not like to over-complicate things! that would only give me more trouble for nothing!

But, indeed, i can do so, over-complicate some simple task, if i cant get it to be done in a easy straightforward way.


thanks for the tip, ill try this way as i had not understood, from my reading of the documentation, that CopyTicks was able to do that!

i guess my troubles started when i was trying to flag the last tick directions as 0,+1 and -1 and then summing all of these in the "copied" size vector created (in your code snippet)


thanks again

 
Eduardo Gonzatti:

Hi there!

Not at all, Alain, i do not like to over-complicate things! that would only give me more trouble for nothing!

But, indeed, i can do so, over-complicate some simple task, if i cant get it to be done in a easy straightforward way.

thanks for the tip, ill try this way as i had not understood, from my reading of the documentation, that CopyTicks was able to do that!

i guess my troubles started when i was trying to flag the last tick directions as 0,+1 and -1 and then summing all of these in the "copied" size vector created (in your code snippet)

thanks again

I think you have to delete the info in the array everytime a new tick is created(freememory), when you are using copyticks they only copy the number that you have put into the array at time 0. Newest tick will not be created...

 Example;

 MqlTick ticks[];
 int copied=CopyTicks(NULL,ticks,COPY_TICKS_TRADE,0,10); // You will only get 10 lastest ticks at time 0. When time is 1, it will generate an amount of new tick. right? This function will stand at same place. I think you have to refresh it, freememory and make a new copy then for every new tick. Then you can compare current tick.
 

Reason: