Close Position Button

Created at 10 Aug 2023, 06:03
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!
1308's avatar

1308

Joined 18.07.2023

Close Position Button
10 Aug 2023, 06:03


HI,

 

me is missing the parameter “Close position which is older then 5 days”

 

Can you add that? Or have you a script for that?

 

BR


Daniel

https://ct.spotware.com/copy/strategy/71142?u=daniel.schaeftlein

 


cTrader
@1308
Replies

firemyst
17 Aug 2023, 00:59

This is an easy enough bot to write.

Just have your bot check all your positions 1 per hour, every 4 hours, every 15 minutes, or however often you want for any positions open more than 5 days.

//pseudo code
DateTime currentTime = DateTime.Now;
foreach (Position p in Positions)
{
    if (p.EntryTime < (currentTime - (5 days)) )
         p.Close();  
}

@firemyst

sniper_FTX-News_com
17 Aug 2023, 12:58

RE: Close Position Button

firemyst said: 

This is an easy enough bot to write.

Just have your bot check all your positions 1 per hour, every 4 hours, every 15 minutes, or however often you want for any positions open more than 5 days.

//pseudo codeDateTime currentTime = DateTime.Now;foreach (Position p in Positions){    if (p.EntryTime < (currentTime - (5 days)) )         p.Close();  }

Big Thxs


@sniper_FTX-News_com