Need help to Modify a Custom indicator

 

Hello;

I have a code to count number Bars up ( down ) in 50 (number) bars;

I just need help to modify this by

1-to add an input so that I change the number of bars to any number x, not to be redistricted to only 50 bars

2- a way to put two or more of this indicator on the chart side by side if I change x, ex: 50 bars and 20 bars each has won counts showing separately on the same chart

I tried to do that but I couldn't as I don't know programing

any help would be appreciated

thanks

and here is the code I have:

//+------------------------------------------------------------------+
//| 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);
  }
//+------------------------------------------------------------------+

Documentation on MQL5: Timeseries and Indicators Access / Bars
Documentation on MQL5: Timeseries and Indicators Access / Bars
  • www.mql5.com
If the start_time and stop_time parameters are defined, the function returns the number of bars in the specified time interval, otherwise it returns the total number of bars. If data for the timeseries with specified parameters are not formed in the terminal by the time of the Bars() function call, or data of the timeseries are not synchronized...
 
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.
 
  1. Post in the correct section: MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  3. FAHA313: 1-to add an input so that I change the number of bars to any number x, not to be redistricted to only 50 bars

    Perhaps you should read the manual. MQL4 ReferenceLanguage BasicsVariablesInput Variables
       How To Ask Questions The Smart Way. 2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  4. FAHA313: 2- a way to put two or more of this indicator on the chart side by side if I change x, ex: 50 bars and 20 bars each has won counts showing separately on the same chart

    Either one indicator with multiple inputs and a combined output, or stop using Comment, create a label object with a Y offset input (so labels don't overlap).

  5. FAHA313: I couldn't as I don't know programing

    any help would be appreciated

    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

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
              No free help 2017.04.21

Reason: