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() { //Your code logic here. }
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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
//range open range.range_open = lastTick.ask; 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