how to calculate the speed of volume changing ?

 

hi .
I need to calculate the speed of volume changing.

I want make a unique for it like "beat per second" . when I say beat I mean the smallest movement of the volume.

As much as I know the volume is counting of the coming ticks in a candle. if it's true then the unique can be ticks per second.

I don't know if in MQL we have access to seconds coming ordered  or just we can count the ticks time.
if we don't have this access its enough for me to calculate "ticks per second" Approximately.


Sorry if my English is not good enough. 

 
Reza nasimi: I need to calculate the speed of volume changing.

I want make a unique for it like "bit per second" . when I say bit I mean the smallest movement of the volume.

As much as I know the volume is counting of the coming ticks in a candle. if it's true then the unique can be ticks per second.

I don't know if in MQL we have access to seconds coming ordered  or just we can count the ticks time.
if we don't have this access its enough for me to calculate "ticks per second" Approximately.

In MT5 since you can look at Tick Data history, that includes millisecond timing, you can easily calculate almost instantaneous "ticks per second" on history and live data.

In MT4, since you don't have access to Tick history, only live data, you can only approximate it by using Bar Volume data for history data, but can still get reasonable information on live data but only using "seconds" as millisecond timing is not implemented in MT4.

But in any of the cases, you can still get Average "ticks per second" without much difficulty.

 
Fernando Carreiro:

In MT5 since you can look at Tick Data history, that includes millisecond timing, you can easily calculate almost instantaneous "ticks per second" on history and live data.

In MT4, since you don't have access to Tick history, only live data, you can only approximate it by using Bar Volume data for history data, but can still get reasonable information on live data but only using "seconds" as millisecond timing is not implemented in MT4.

But in any of the cases, you can still get Average "ticks per second" without much difficulty.


Thank you very much Fernando Carreiro .

it was very good 

But I'm not a professional programmer and just trying to increase my knowledge and experiences.

Would you please give me more information by writing some codes or at least some keywords  .

thanks a lot .

 

Can anyone help a little more ?

 
Reza nasimi:

Can anyone help a little more ?

Do you need real time data or history data?
 
Mohammad Hossein Sadeghi:
Do you need real time data or history data?

thank you  Mohammad Hossein Sadeghi ,

Problem solved.

but I am not sure if i wrote it  good or not .

//+------------------------------------------------------------------+
//|                                        Seyed Speed Of Volume.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

input int Speed_For_Signal=1000;

datetime LastTickTime=TimeCurrent()-1;
long LastVol=-1;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  //if (Speed()==(int)Speed()){Alert("OK");}
  
  
   Comment("    C 14 :"," ",Volume[14],
           "    C 13 :"," ",Volume[13],
           "    C 12 :"," ",Volume[12],
           "    C 11 :"," ",Volume[11],
           "    C 10 :"," ",Volume[10],
           "    C 9  :"," ",Volume[9],
           "    C 8  :"," ",Volume[8],
           "    C 7  :"," ",Volume[7],
           "    C 6  :"," ",Volume[6],
           "    C 5  :"," ",Volume[5],
           "    C 4  :"," ",Volume[4],
           "    C 3  :"," ",Volume[3],
           "    C 2  :"," ",Volume[2],
           "    C 1  :"," ",Volume[1],
           
           "\nSpeed : ",Speed(),"  TPM");

   
   if(Speed() >=Speed_For_Signal)
     {
      Alert("Good Speed");
     }

  }



//+------------------------------------------------------------------+
long Speed()
     {
     long Spe=0;
      if(LastTickTime!=TimeCurrent())
        {
         long diff=(TimeCurrent()-LastTickTime);
         if(diff>=1)
           {
             Spe=(Volume[0]-LastVol)/diff;

        
           }
else
  {
   Spe = 0;
  }
         //--
         LastTickTime=TimeCurrent();
         LastVol=Volume[0];

        }
        return(Spe);
     }
     
Reason: