# INT wiht name of String

48

Hello to all,
i need yours help
i need to do a "int" with the name of a string
i know to do a "string" change the name automatically;
example:
```int ix;

for(ix=0;ix<100;ix++)

{

string ff="text"+ix;
Print (ff);
}
```

The result is:

text0

text1

text2

text3

text4

text5

....................etc.

But now, i need make "INT" with this name and assign a value

example

``` int text0=2;
int text0=4;
int text0=7;
int text0=55;
int text0=6;
int text0=9;```

only the names!!!, the values are for example

Thanks,

15934

 Can't generate code via code. ``` int text0=2; int text0=4; int text0=7; int text0=55; int text0=6; int text0=9;``` Use an array: ```int text[6];    text[0]=2;     text[3]=55;    text[1]=4;     text[4]=6;    text[2]=7;     text[5]=9; // Or for constants: int text[] = { 2, 4, 7, 55, 6, 9};```
48

Thank you
I need that the amount of "int's" is automatically created way because on occasion would be more than others

in short, I need to find the number of times a price closes between a price range,

in short, to find how many times in the last 100 closures the price close between 1.3010 and 1.3030 ;
Moderator
10645

MQ-L4:
Thank you
I need that the amount of "int's" is automatically created way because on occasion would be more than others

in short, I need to find the number of times a price closes between a price range,

in short, to find how many times in the last 100 closures the price close between 1.3010 and 1.3030 ;

create an array as WhRoeder has said and the you can re-size the array as required
3243

i dont know what your problem is as WHRoeder said before use arrays

```int text[];

for(ix=0;ix<100;ix++)
{
ArrayResize(text, ix+1);
}
```

then

`ArraySize(text); //your result`

& finally

```text[0]=2;
text[1]=4;
text[2]=7;
text[3]=55;
text[4]=6;
text[5]=9;```
4115

"in short, I need to find the number of times a price closes between a price range, in short, to find how many times in the last 100 closures the price close between 1.3010 and 1.3030 ;"

You might want to make you a little function like this..

```int numberInRange(double upperlimit, double lowerlimit)//function that you call and send along the limits of your range.
{
int closesInRange =0;
for(int i=1;i<=100;i++)//not counting candle zero
{
if(Close[i]<upperlimit && Close[i]>lowerlimit)
closesInRange++;
}
return(closesInRange);// returning the number of closes that fell within your range.
}```
You can see that the for loop just runs through candles 1-100 checking to see if the closes were between the upper and lower limits that you send the function.
If it finds on it bumps up ++ the number and then returns the final results ..... Hope this helps a little.. PipPip..Jimdandy
48

Hello and thank you all for responding
first of all confirmed that they have read each of your answers and somehow try to adapt it to what I need, but I could not

the code in general than I need to create, is a count of how many times the
price CLOSE in respective range, but not only a range, divers ranges, something like:

eurusd:
10 pip ranges from 1.28000 to 1.3000, in total 200 pips, equal to 20 ranges of 10 pips,
so I want to see, the visual mode or in text mode in a separate window, how many times the price close in the last 1000 candles in respective price below:
1.28000-1.28100 =2 times
1.28100-1.28200 =8 times

1.28200-1.28300= 0 times

1.28300-1.28400=1 time

etc
etc.

This is my code, for draw the lines each range that i need,

```#property version   "1.00"
#property strict
#property indicator_chart_window

input int VELAS=1000;  //Numero de velas para extraer datos
input int MAX=120;     //Numero de Pixeles de la vela Mayor
input int PipsAncho=10;//

int Tri=1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping

//---
return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{

ObjectsDeleteAll();

}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[],
{
//---

int mul=0;
int d=Digits;
if (d==3) mul=1;
if (d==5) mul=3;
static double RE=0;

if (Tri==1 && Base>0)
{
RE=Base;
Tri=0;
}

double REMAX=RE+(5000*Point);
double REMIN=RE-(5000*Point);
double Spaces=(PipsAncho*10)*Point;
double lineInterval = Spaces;
double nLines = (REMAX-REMIN)/Spaces;
// Number of total line to draw
// Interval between lines
// Current price is rounded to nearest "10"

for (int ix = 1; ix < nLines; ix++)                // Loop span number of times
{
const long               AID=0;
const string           name="RectLabel";
const int              sub_window=0;

for (int ix = 0; ix < nLines; ix++)                // Loop span number of times
{

ObjectCreate(name+ix, OBJ_HLINE, 0, 0, RE+((ix-(nLines/2))*lineInterval));    // Place half above and half below the current price

ObjectSet(name+ix,OBJPROP_COLOR,DarkSlateGray);      // Make the lines look better
}
return(0); //All done
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
```

but ¿how I count the closures???

Thanks????

3243

i wrote a script a long time ago that's marking on the chart supports and resistance according the price action in 15M TF (never used it since) this will give you an idea

```//+------------------------------------------------------------------+
//|                                                       SnRbPA.mq4 |
//+------------------------------------------------------------------+
double RangeHigh, RangeLow, RangeCenter;
int    BarsForCheck = 64800; //6 Month
int    Count        = 0;
int NoOfCnt[];
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
{
//----
for(int obj = ObjectsTotal() -1; obj >=0; obj--)
{
if (StringSubstr(ObjectName(obj),0, 7) == "resNsup")
{
ObjectDelete(ObjectName(obj));
}
}
int BarsCount = WindowBarsPerChart() + 1;
int FirstBar = WindowFirstVisibleBar();
int LastBar = FirstBar - BarsCount + 1;
if (LastBar < 0 )
{
LastBar = 0;
BarsCount = FirstBar + 1;
}
RangeHigh = High[iHighest(NULL, 0, MODE_HIGH, BarsCount, LastBar)];
RangeLow = Low[iLowest(NULL, 0, MODE_LOW, BarsCount, LastBar)];
//-------
double start = NormalizeDouble(RangeLow,3);
double end = NormalizeDouble(RangeHigh,3);

int times = NormalizeDouble(RangeHigh - RangeLow,4)/(Point*10)/5;
int    element_count=ArrayResize(NoOfCnt, (times+1));
//--------

int i = 0, k = 0;
while (start <= end)
{
Count = 0;
k = 0;
while (k <= BarsForCheck)
{
if (start <= iHigh(NULL, 15, k) &&  start >= iLow(NULL, 15, k))
{
Count++;
}
k++;
}
NoOfCnt[i] = Count;
i++;
ObjectCreate("resNsup"+start, OBJ_TREND, 0, iTime(NULL, 0, (FirstBar-Count)), start, iTime(NULL, 0, FirstBar), start);
ObjectSet("resNsup"+start, OBJPROP_COLOR, Aqua);
ObjectSet("resNsup"+start, OBJPROP_STYLE, STYLE_DASH);
ObjectSet("resNsup"+start, OBJPROP_RAY, true);
ObjectSet("resNsup"+start, OBJPROP_WIDTH, 1);
start = NormalizeDouble(start,4)+(10*Point);
}

//----
return(0);
}
//+------------------------------------------------------------------+

```