Limit Value

 

Hello,
How to limit the output which has results between some range values (for example): 240 < outputvalue < 250. Anyone have an example please?
I am trying with this code, but give no result:

int NumberLimit = 1
double outputvalue;

for (int i=0; i<BarsLimit; i++)
{
    int totals[];
    ArrayInitialize(totals, 0);

    datetime StartTime=iTime(NULL, 0, i);
    int startShift = iBarShift(NULL, 0, StartTime, false);

    outputvalue = get_value(startShift, SOMEINPUT, SOMEINPUT);
    totals[outputvalue]++;

    if (outputvalue>=240.0 && outputvalue<250.0 && totals[outputvalue]<NumberLimit)
    {
         Print("StartTime; ", TimeToString(StartTime, TIME_DATE), " outputvalue: ", outputvalue);
         ........
    }
}

The result so far can see on attachment.
Can someone help me, would really appreciate it. Thank you in advanced.

Files:
Capture212.JPG  118 kb
 
    int totals[];
    totals[outputvalue]++;
Array has no size, you can't put any values into it. You would know that if you had used strict.
Always use strict. Fixing the warnings will save you hours of debugging.
          Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference
 
whroeder1:
Array has no size, you can't put any values into it. You would know that if you had used strict.
Always use strict. Fixing the warnings will save you hours of debugging.
          Program Properties (#property) - Preprocessor - Language Basics - MQL4 Reference

Thank for your response whroeder1. I removed the array, so how to do without array? Can I do within the condition something like this: 

for (outputvalue>=240.0; outputvalue<250.0 && outputvalue<NumberLimit; outputvalue++)
{
    Print("StartTime; ", TimeToString(StartTime, TIME_DATE), " outputvalue: ", outputvalue);
}

But it still give nothing.

 
  1. Panjianom Adi Pratomo: I removed the array, so how to do without array?

    Who said to do that? Don't you still want to limit output by totals[outputvalue] < NumberLimit

  2.    datetime StartTime=iTime(NULL, 0, i);
        int startShift = iBarShift(NULL, 0, StartTime, false);
    
    What is the point of that. startShift will always equal i for the current symbol/TF.
 
whroeder1:
  1. Who said to do that? Don't you still want to limit output by totals[outputvalue] < NumberLimit

  2. What is the point of that. startShift will always equal i for the current symbol/TF.

1. Yes, I am still want to limit by totals[outputvalue] < NumberLimit

2. You're right, I am miss-understand for your response in previous comment on "Array has no size, you can't put any values into it", cause my English language is not good enough.

So I revert back the code and fill the array with ArrayResize, and I got an error when compiling: 'outputvalue' - integer expression expected

ArrayResize(totals, BarsLimit);
ArrayInitialize(totals, 0);
 
totals[outputvalue]++;
Now you're confusing BarsLimit with the range of outputvalue.
Reason: