trying to draw horizontal line for opening price of range

hey there,

i am trying to work out how to draw a line on the opening price of a range i have defined in my EA.

I am able to draw the high of the range in green, the low of the range in red... but i cant figure out how to draw the actual opening price

so i understand the concept

if the lastTick.time is bigger or equal to the start of the range and if the lastTick.time is smaller than the end of the range we are inside the range
Then store the high of the range in range.high using the last ask price that is the highest
Then store the low of the range in range.low using the last bid price that is the lowest

but how do u store only the first opening price of the range without that price move every time there is a new tick?

``` //range calculation
if(lastTick.time >= range.start_time && lastTick.time <  range.end_time){ //inside range

//new high
if(lastTick.ask > range.high){     //if the last price is high that the range high
range.high = lastTick.ask;      // store the highest price in range.high
DrawObjects();                  // draw the high
}
//new low
if(lastTick.bid < range.low){      //if the last price is lower that the range low
range.low = lastTick.bid;       // store the lowest price in range.low
DrawObjects();                  // draw the low
}```

I tried

```      //range open
DrawObjects();```

but with this my open line moves everytime theres a new tick... which also makes sense cause lastTick is the most recent tick and price is always moving using that

Can you give me some advice?

Kind regards

pebs85:

hey there,

i am trying to work out how to draw a line on the opening price of a range i have defined in my EA.

I am able to draw the high of the range in green, the low of the range in red... but i cant figure out how to draw the actual opening price

so i understand the concept

if the lastTick.time is bigger or equal to the start of the range and if the lastTick.time is smaller than the end of the range we are inside the range
Then store the high of the range in range.high using the last ask price that is the highest
Then store the low of the range in range.low using the last bid price that is the lowest

but how do u store only the first opening price of the range without that price move every time there is a new tick?

I tried

but with this my open line moves everytime theres a new tick... which also makes sense cause lastTick is the most recent tick and price is always moving using that

Can you give me some advice?

Kind regards

if you want to store opening price use this

```//declare global variable

double openprice ;

void OnInit()
{openprice =
lastTick.Bid ;}

void OnTick()
{