Time difference? (Duration of trade)
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)
Replies
commando1
23 Aug 2016, 21:46
if ((Time - Position.EntryTime).TotalMinutes >= 120)
this should work
@commando1
... Deleted by UFO ...