Close trend after 2 hours

Created at 28 Mar 2018, 11:02
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!
sifneos4fx's avatar

sifneos4fx

Joined 15.11.2017

Close trend after 2 hours
28 Mar 2018, 11:02


Hello all

I want to measure time (in hours) trades are open. I want to close a trade is open longer than 2 hours.

Doing this var diff = Server.Time - pos.EntryTime works fine, however when I compare if(diff>2) i get the error "can't compare timespan with int".  

Thanks
Patrick


@sifneos4fx
Replies

PanagiotisCharalampous
28 Mar 2018, 11:06

Hi Patrick,

Try diff.Hour

Best Regards,

Panagiotis


@PanagiotisCharalampous