Set the bars in calculation

 

How can a bars in calculation be set by a user input as well as all bars so that it doesn't count all bars each time?

Example, we have an input for bars in calculation which if set for 0 meant to calculate all bars.

Input int BarsInCalc=1000; //Bars In Calc; 0:All

I think I have the right idea using IndicatorCounted() ..

BarsInCalc-(IndicatorCounted()>0?BarsInCalc:IndicatorCounted())

First tick says 1000 and every tick thereafter says 0 ..

How do you use the latest standard??

int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[],
 const double &open[],const double &high[],const double &low[],const double &close[],
 const long &tick_volume[],const long &volume[],const int &spread[])
{
 int iIndicatorCounted=IndicatorCounted();
 int iPrevCalculated=prev_calculated;
 Comment(
  (string)iIndicatorCounted+"\n"+
  (string)(BarsInCalc-(iIndicatorCounted>0?BarsInCalc:iIndicatorCounted))+"\n"+
  (string)(iPrevCalculated)+"\n"+
  (string)(BarsInCalc-(iPrevCalculated>0?BarsInCalc:iPrevCalculated))
  );
}
 
Brian Lillard:

How can a bars in calculation be set by a user input as well as all bars so that it doesn't count all bars each time?

Example, we have an input for bars in calculation which if set for 0 meant to calculate all bars.

I think I have the right idea using IndicatorCounted() ..

First tick says 1000 and every tick thereafter says 0 ..

How do you use the latest standard??

What does your function  IndicatorCounted() do?

 
Keith Watford:

What does your function  IndicatorCounted() do?

rates_total-1-prev_calculated always equals rates_total-1. prev_calculated always equals 0 and IndicatorCounted() equals bars and then equals 0 so what gives? How is this even right?

How can you use the latest standard?
 
Keith Watford:

What does your function  IndicatorCounted() do?

Brian Lillard:

rates_total-1-prev_calculated always equals rates_total-1. prev_calculated always equals 0 and IndicatorCounted() equals bars and then equals 0 so what gives? How is this even right?

How can you use the latest standard?

I have no idea what you are talking about.
Please just show the code for the function  IndicatorCounted() 

 
Keith Watford:

I have no idea what you are talking about.
Please just show the code for the function  IndicatorCounted() 

int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[],
 const double &open[],const double &high[],const double &low[],const double &close[],
 const long &tick_volume[],const long &volume[],const int &spread[])
{
 int iIndicatorCounted=IndicatorCounted();
 int iPrevCalculated=prev_calculated;

 Comment(
  "IndicatorCounted(): "+(string)iIndicatorCounted+"\n"+
  "BarsInCalc & IndicatorCounted(): "+(string)(BarsInCalc-(iIndicatorCounted>0?BarsInCalc:iIndicatorCounted))+"\n"+
  "rates_total-prev_calculated: "+(string)(rates_total-prev_calculated)
  );
}
 
int OnCalculate(const int rates_total,const int prev_calculated,const datetime &time[],
 const double &open[],const double &high[],const double &low[],const double &close[],
 const long &tick_volume[],const long &volume[],const int &spread[])
{
 int iIndicatorCounted=IndicatorCounted();
 int iPrevCalculated=prev_calculated;

 Comment(
  "IndicatorCounted(): "+(string)iIndicatorCounted+"\n"+
  "BarsInCalc & IndicatorCounted(): "+(string)(BarsInCalc-(iIndicatorCounted>0?BarsInCalc:iIndicatorCounted))+"\n"+
  "rates_total-prev_calculated: "+(string)(rates_total-prev_calculated)
  );
}

You are calling a function IndicatorCounted() but you don't show the actual function.

Please show the code for the function  IndicatorCounted()

 
Keith Watford:

You are calling a function IndicatorCounted() but you don't show the actual function.

Please show the code for the function  IndicatorCounted()

It's made by mql5 bro
 
Brian Lillard:
It's made by mql5 bro

There is no such function in MQL5.
Are you using a library?

 
Keith Watford:

There is no such function in MQL5.
Are you using a library?

IndicatorCounted - Custom Indicators - MQL4 Reference
IndicatorCounted - Custom Indicators - MQL4 Reference
  • docs.mql4.com
IndicatorCounted - Custom Indicators - MQL4 Reference
 
Brian Lillard:

That is a MQL4 function.

Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
IndicatorCounted() is an outdated function and it is probably a good idea to stop using it and do all calculations with rates_total and prev_calculated.