maxTickNumber and minTickNumber

Back to topics list To post a new topic, please log in or register
avatar
40
EgyAlgoTrader 2015.06.16 19:00
 

Hi, i was trying to just code a simple function that shows on screen as a comment the following info:

1- current spreed

2-tick count in the last 60 minutes

3-max tick count for last 60 minutes

4-minimum tick count for last 60 minutes 

However, i think it is not working properly. I see that i am missing some coding principal here but i do not know which.

On global variables:
 
int maxTickCount= 0;
int minTickCount=0;

 On Tick()

void OnTick()
  {         // here i just want to show the spreed, tick number in the last 60 mintues, max tick number and min tick number
 int tickcount = iVolume("USDEUR",PERIOD_M1,0);
 double brokerSpreed = (Ask -Bid)*10000;
 double normbrokerSpreed = NormalizeDouble (brokerSpreed,2);
 
 
 int totTickCount;
 for(int i=59;i>=0;i--)
 { totTickCount=totTickCount+Volume[i];

   if ( totTickCount > maxTickCount) maxTickCount = totTickCount;
   if ( totTickCount < maxTickCount) minTickCount = totTickCount;
  else
   totTickCount = totTickCount;  
 
 }
 
 
 Comment ( "Current spreed " + normbrokerSpreed + "\n" + 
           "Tick Count in last Hour is " + totTickCount     + "\n" +
           "max Tick Count in last Hour is " + maxTickCount     + "\n" +
           "min Tick Count in last Hour is " + minTickCount     + "\n" );
   
  }

 The result is 

 

avatar
54
PomeGranate 2015.06.16 19:24 #
 

You need to check the values in the (predefined) Volume array for highest and lowest value instead of assigning totTickCount value as soon as it is bigger than maxTickCount (think again what happens when your code is run, step by step)!

Use https://docs.mql4.com/series/ihighest and iVolume[shift] with the iHighest shift for maxTickCount.

This expression is useless: totTickCount = totTickCount; 

Back to topics list  

To add comments, please log in or register