Stop loss by date

Created at 27 Dec 2018, 20:33
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!
EL

eliezer_barros

Joined 21.12.2018

Stop loss by date
27 Dec 2018, 20:33


I need to do a observation to stop loss by date, so anybody have a routine?

The exactly idea is for a specific currency, further of indicate the normal stop loss I wish create a rotine to check all position open and I want to close the position if is 90 (ie) days open.

Anybody have this idea? Tks


@eliezer_barros
Replies

PanagiotisCharalampous
28 Dec 2018, 09:56

Hi,

You can try something like the below

            foreach (var position in Positions)
            {
                if ((Server.Time - position.EntryTime).Days > 90)
                    position.Close();
            }

Best Regards,

Panagiotis


@PanagiotisCharalampous

eliezer_barros
28 Dec 2018, 13:36

RE:

Hi,

I installed this routine and error message appear:

'cAlgo.API.Position' does not contain a definition for 'Close' and no extension method 'Close' accepting a first argument ....

Please, can you help me?

tks


@eliezer_barros

PanagiotisCharalampous
02 Jan 2019, 11:05

Hi eliezer_barros,

Which broker's cTrader do you use?

Best Regards,

Panagiotis


@PanagiotisCharalampous

eliezer_barros
15 Jan 2019, 15:39

RE:

Panagiotis Charalampous said:

Hi eliezer_barros,

Which broker's cTrader do you use?

Best Regards,

Panagiotis

Hi,

I use Fxpro


@eliezer_barros

PanagiotisCharalampous
15 Jan 2019, 17:00

Hi eliezer_barros,

I have replied to your email. You cannot use position.Close() with FxPro as it uses an older version of cTrader. You need to use ClosePosition().

Best Regards,

Panagiotis


@PanagiotisCharalampous