Dumbination:
Greetings! I'm trying to use the above as a bar counting method but my current time seems to be behind my position open time. May anyone know why?
int total = PositionsTotal(); for (int c = 0; c <= total; c++) // Must be < as you have total positions indexed from 0 to total-1 {ulong ticket = PositionGetTicket(c); if (PositionSelectByTicket(ticket)) // Useless as your position is already selected by previous PositionGetTicket() { datetime open_time = PositionGetInteger(POSITION_TIME); datetime current_time = TimeCurrent(); bar_count = Bars(_Symbol,_Period,open_time,current_time); Comment("Candle count = ",bar_count, ". Position time = ",open_time, ". Current time = ",current_time, ". Position ticket = ",ticket,"."); } }
What is the output produced ?
Alain Verleyen:
The time on the chart isn't updating. Tried using the TimeTradeServer() function and a modified TimeGMT() function as well. The aim is to count the bars after opening aWhat is the output produced ?
position.
Dumbination:
The time on the chart isn't updating. Tried using the TimeTradeServer() function and a modified TimeGMT() function as well. The aim is to count the bars after opening a
I know what is the aim, I am asking you "what is the output", what is printed on the chart ? What are the values ?
The time on the chart isn't updating. Tried using the TimeTradeServer() function and a modified TimeGMT() function as well. The aim is to count the bars after opening a
position.
changed the current time to SymbolInfoInteger(_Symbol,SYMBOL_TIME) and the time started updating. The only problem is that it would increase the position volume every time it did and would not update if it could not increase the volume.

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
Greetings! I'm trying to use the above as a bar counting method but my current time seems to be behind my position open time. May anyone know why?