# Open and Close of a Candle

526

If I can utilize iHighest to find the highest high within 100 periods, and then find the Open of that period / candle. Would I use the following code to find the Open of a specific period. For example, if the highest high was on the 70 the period, and I want to find the Open of the 73rd period.

Thanks

```
CntBarsz = 100;

int maxshiftz=iHighest(NULL,0,MODE_OPEN,CntBarsz,0);
double Maximumz=Open[maxshiftz];
datetime maxtimez=Time[maxshiftz];

double MXOp = iOpen(NULL,PERIOD_D1,maxshiftz);

int XMXOp = (maxshiftz-3);  //  Third Candle from Highest

// Would I use the following loop to count forwards and / or backwards to find the Open of the above Candle

for(int i=1; i<=Bars; i++)

{
while(i == XMXOp)
{
Alert("Open of ",XMXOp," Candle =  ",Open);
}
}

```
Moderator
18021

Yellowbeard:

If I can utilize iHighest to find the highest high within 100 periods, and then find the Open of that period / candle. Would I use the following code to find the Open of a specific period. For example, if the highest high was on the 70 the period, and I want to find the Open of the 73rd period.

Not quite . . .

`int maxshiftz = iHighest(NULL, 0, MODE_OPEN, CntBarsz, 0);`

. . . will find the highest open price because you used MODE_OPEN

If you want to find the Open of the 3 bar along from the highest . . .

```int maxshiftz = iHighest(NULL, 0, MODE_HIGH, CntBarsz, 0);

int XMXOp = (maxshiftz-3);  //  Third Candle from Highest

Alert("Open of ",XMXOp," Candle =  ",Open[XMXOp]);```
526

Thanks! I knew I had to be close. And yet, so far. Now, if I want to identify the period / candle, on a chart, with an arrow. Would I do so as such. This places an arrow on the same period as iHighest but at a different value. Not on the third candle from the highest.
```
ObjectCreate("UpSymbolZz", OBJ_ARROW, 0, maxtimez,Open[XMXOp]);
ObjectSet("UpSymbolZz", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
ObjectSet("UpSymbolZz", OBJPROP_COLOR,Aqua); ```
Moderator
18021

Yellowbeard:
Thanks! I knew I had to be close. And yet, so far. Now, if I want to identify the period / candle, on a chart, with an arrow. Would I do so as such. This places an arrow on the same period as iHighest but at a different value. Not on the third candle from the highest.

You could do this . . .

```        ObjectCreate("UpSymbolZz", OBJ_ARROW, 0,   Time[XMXOp],   Open[XMXOp]);
ObjectSet("UpSymbolZz", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
ObjectSet("UpSymbolZz", OBJPROP_COLOR,Aqua);```
526

RaptorUK:

You could do this . . .

Thanks again, RaptorUK, for all your help. That worked.

Yellowbeard