...I would like to design a strategy which would enter a position at the open price and exit the position at the close price.
Every time a tick is made the start() funciton is called. How can it be detected if it is a first tick of a new bar (open price) or if it is the last tick of a bar (close price) or is it somethning esle?
Thanx
Every time a tick is made the start() funciton is called. How can it be detected if it is a first tick of a new bar (open price) or if it is the last tick of a bar (close price) or is it somethning esle?
Thanx
Ok,
The current tick number is tick=Volume[i];
The first tick = 1.
Open[i] = Close[i] at tick 1 of current bar;
Close[i] at tick "n" is your last tick.
However, you cannot detect last tick in the current bar because the bar is shifted to i+1 with the last tick so it is to late to open or close order when you detect the last tick.
Essentially at tick 1 you can read Open[i] same as Close[i] and Close[i+1] of previous bar.
Princ,
I usually use
I usually use
int start() { if (Volume[0]>1) return; // check bar#1 (Open[1], Close[1], iMA(....., 1); etc. for // the values and indicators of the bar which was just completed .... }
Markus
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Every time a tick is made the start() funciton is called. How can it be detected if it is a first tick of a new bar (open price) or if it is the last tick of a bar (close price) or is it somethning esle?
Thanx