Get Price of Last Deal (Order Executed) - page 2

 
fxsaber:

Forum on trading, automated trading systems and testing trading strategies

Get Price of Last Deal (Order Executed)

Guilherme Mendonca, 2017.05.19 14:51

Hello, 


If I have multiples orders executed in the same trade (same direction) to do averaging price and I would like to get the price of the last order executed, not the final price (average).

How can I get this value?


I tryed to use the function bellow, but this function give me the price of the result of all orders.

PositionGetDouble(POSITION_PRICE_OPEN)


 
Alain Verleyen:
We understood each other. Why bother?
 
fxsaber:

What do you want to say ?

TimeTradeServer() can be greater, equal or higher than TimeCurrent(), you can't never know that.

Anyway what that changes ? Nothing.

 
Alain Verleyen:

What do you want to say ?

I have a different mentality, so I will not fully understand. Sorry.
 
fxsaber:
We understood each other. Why bother?

No problem.

But the code you posted could give a wrong result, depending of the context. I just want people know that.

 
fxsaber:
I have a different mentality, so I will not fully understand. Sorry.

No problem. Unfortunately I can't use Russian language without a translator.

2017.05.19 22:26:14.825    __TEST__ (EURUSD,H1)    TimeCurrent = 23:25:34 IS SMALLER TimeTradeServer = 23:26:14
2017.05.19 22:25:45.196    __TEST__ (EURUSD,H1)    TimeCurrent = 23:26:08 IS GREATER TimeTradeServer = 23:25:45

 
Alain Verleyen:

No problem. Unfortunately I can't use Russian language without a translator.

2017.05.19 22:26:14.825    __TEST__ (EURUSD,H1)    TimeCurrent = 23:25:34 IS SMALLER TimeTradeServer = 23:26:14
2017.05.19 22:25:45.196    __TEST__ (EURUSD,H1)    TimeCurrent = 23:26:08 IS GREATER TimeTradeServer = 23:25:45

My opinion is that now the TimeTradeServer does not work correctly.

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Ошибки, баги, вопросы

fxsaber, 2017.05.19 22:35

TimeTradeServer может возвращать всякую ерунду. Например, значение меньше, чем TimeCurrent. Это сводит полностью на нет его практическое применение.

Если правильно понимаю идею, то TimeTradeServer при работающем терминале должен был вычислять прошедшее время, после получения TimeCurrent и прибавлять эту разность, своего рода эмулируя будущие значения TimeCurrent.

Сейчас же запустив советник

#define TOSTRING(A) #A + " = " + (string)(A) + "\n"

void OnInit()
{
  EventSetTimer(1);
}

void OnTimer()
{
  Comment(TOSTRING(TimeTradeServer()) + TOSTRING(TimeCurrent()));
}

можно увидеть любую ерунду

Обратите внимание на даты.

 
Alain Verleyen:

No problem. Unfortunately I can't use Russian language without a translator.

2017.05.19 22:26:14.825    __TEST__ (EURUSD,H1)    TimeCurrent = 23:25:34 IS SMALLER TimeTradeServer = 23:26:14
2017.05.19 22:25:45.196    __TEST__ (EURUSD,H1)    TimeCurrent = 23:26:08 IS GREATER TimeTradeServer = 23:25:45

I forgot to say I changed my computer time by 1 minutes between this 2 results.
 

Ok, But if would like to input a routine to count how many orders executed my EA already executed in the same trade.


I tryed to use PositionsTotal() but as I'm trading in the same direction to average my price, I think the result is always 1.

But in fact, I need to count, how many Deals (executed order)


Please, give me a light!

 
Guilherme Mendonca:

Ok, But if would like to input a routine to count how many orders executed my EA already executed in the same trade.


I tryed to use PositionsTotal() but as I'm trading in the same direction to average my price, I think the result is always 1.

But in fact, I need to count, how many Deals (executed order)


Please, give me a light!

Use HistorySelectByPosition() to select history of a given position.