Bar/Pips counter

 

Hi all,

I need a MT4 indicator that counts up/down bars and pips for a certain period. 
Additionally if it is possible, in a small window to count the same on any timeframes.

For Instance: 
EUR/USD 1M Up Bars 432/Down Bars 522 Up pips 6663/Down pips 3342

EUR/USD 5M ......................

etc

I tried this code but it doesn't count correctly.


int start()

  {

//----

   int n, upbar, downbar;

   double candleclose, candleopen, isitupordown;

   datetime some_time=D'2020.01.01 00:00';

   {

      candleclose = iClose(Symbol(), 0, n);

      candleopen = iOpen(Symbol(), 0, n);

      isitupordown = candleclose - candleopen;

      if(isitupordown>0) upbar= upbar+1;

      if(isitupordown<0) downbar= downbar+1;

   }

   Comment(upbar," Bars UP","\n", downbar," Bars DOWN");

//----

   return(0);

  }
 
Please edit your post and

use the code button (Alt+S) when pasting code

I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.



 
Karl T: I tried this code but it doesn't count correctly.

Of course, it doesn't; why does that surprise you? 1) n has no value, so you are reading a random bar. 2) you have no loop; all you get is a random result.

MT4: Learn to code it.
MT5: Begin learning to code it.
If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

or pay (Freelance) someone to code it. Top of every page is the link Code Base.
          Hiring to write script - General - MQL5 programming forum 2019.08.21

Reason: