Time difference? (Duration of trade)

Created at 23 Aug 2016, 18:11
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
CL

cloesd

Joined 28.02.2015

Time difference? (Duration of trade)
23 Aug 2016, 18:11


Hi,

I'm trying to write a bot that uses duration a trade has been opened.

 

So far I've got:

 

 Print(positionPain.EntryTime - Time);

 

Which prints: -00:01:34.47000 etc.

 

But I need to compare this to some set value. For example if trade has been opened for longer than 2 hours.

 

I tried using greater than sign:

"if (positionPain.EntryTime - Time > 120)"

But it didn't work.

How can I conduct logical operations on a 'time' difference?

(please forgive I accidentally posted in Ctrader support forum before, not Calgo)


@cloesd
Replies

... Deleted by UFO ...

commando1
23 Aug 2016, 21:46

if ((Time - Position.EntryTime).TotalMinutes >= 120)

this should work


@commando1

cloesd
23 Aug 2016, 22:30

RE:

I went with the first answer.

Thanks for all replies.

 

 


@cloesd