Open Close...

To add comments, please log in or register
Forex Trader
114484
Forex Trader  
...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
Forex Trader
114484
Forex Trader  
...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

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.
Forex Trader
114484
Forex Trader  
Princ,

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

To add comments, please log in or register