Code to count number candlestick up ( down)

 

Hi all.

I want to count number Bars up ( down ) in x (number) bars, plze help me write this code.

thanks u

 
 


thanks qjol.

Could you help me?

ex: in 50 bars, i want to count ( calculate) number bars up and number bars down.

sory, i'm not programer.

thanks u, qjol.

 

sorry i thought you wanted to count how many bars u have from specific time

 

well if its only 50 bars then why not using for() ?


//+------------------------------------------------------------------+
//| Count Bar Up Down.mq4.mq4
//| © Ricky.Ricx @ BrooksPriceAction.com
//| http://www.brookspriceaction.com
//+------------------------------------------------------------------+
#property copyright "© Ricky.Ricx @ BrooksPriceAction.com"
#property link      "http://www.brookspriceaction.com"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   int n, upbar, downbar;
   double candleclose, candleopen, isitupordown;
   for(n=50; n!=0; n--)
   {
      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);
  }
//+------------------------------------------------------------------+
 
ricx:

well if its only 50 bars then why not using for() ?



thanks u, ricx.

 
Hello friends, i want to count number of candles for this month, can someone help me with the code
 
Vijay Akash T P:  i want to count number of candles for this month, can someone help me with the code
  1. Don't resurrect old threads without a very good reason. A lot has changed since Build 600 and Higher. 2014.02.03

  2. Don't Hijack other threads for your off-topic post. Next time, make your own, new, thread.

  3. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

  4. Get the current date, convert to TimeToStruct, set the day to one, convert back. Find that bar index with iBarShift.
              Find bar of the same time one day ago - MQL4 programming forum 2017.10.06
Reason: