need help setting a specific day and time to close trades .... i.e. Friday near market close

Created at 23 Jan 2021, 17:41
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!
CT

ctid1074959

Joined 19.03.2019

need help setting a specific day and time to close trades .... i.e. Friday near market close
23 Jan 2021, 17:41


I'm using this to try to close all positions on Friday near the close...

but it is not working...

 

           System.DayOfWeek today = System.DateTime.Today.DayOfWeek;

            if (Server.Time.DayOfWeek == DayOfWeek.Friday && reSet == 0 && reSetGo == 1)
            {
                reSetTime = Server.Time.AddHours(22);

                if (Server.Time > reSetTime)
                {
                    reSet = 1;
                    foreach (var position in Positions)
                    {
                        ClosePosition(position);
                    }
                }
            }

When I use this:  Print("reSetTime = {0}", reSetTime);

I see this: reSetTime = 1/1/0001 12:00:00 AM

 

How can I do this?

 

Thanks!

 


@ctid1074959
Replies

ClickAlgo
23 Jan 2021, 19:20 ( Updated at: 23 Jan 2021, 19:22 )

I think this contains source code for closing positions on a Friday.

There is also a video: 

 


@ClickAlgo