User timezone in indicator

Created at 21 Jun 2021, 20:59
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!
IR

IRCtrader

Joined 17.06.2021

User timezone in indicator
21 Jun 2021, 20:59


I calculate daily net profit. But it calculate positions that closed in utc not user timezone. How could i add this feature to my indicator?


@IRCtrader
Replies

Symposium
22 Jun 2021, 02:57 ( Updated at: 22 Jun 2021, 03:01 )

Include User timezone in indicator

 using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

//Timezone AEDST 1 TimeZone = TimeZones.CentralPacificStandardTime (UTC +11)
//Timezone AEST 2 TimeZone = TimeZones.EAustraliaStandardTime (UTC +10)

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None, TimeZone = TimeZones.EAustraliaStandardTime)]
    public class DailyStrengthTFStrategy : Indicator
    {

Hi khoshroomahdi, you need to find your TZ (UTC) under TimeZones in the automate menu (right side of screen). As seen above I notate UTC+11 and UTC +10 (Australia) above the Indicator code so it is just a matter of cut and paste when day light saving time applies.

Hope this is of help. Cheers


@Symposium

IRCtrader
22 Jun 2021, 18:28 ( Updated at: 22 Jun 2021, 18:31 )

i know that. but i want dynamic time zone. when user change time zone in ctradr indicator should change.


@IRCtrader

amusleh
22 Jun 2021, 19:57

RE:

khoshroomahdi said:

i know that. but i want dynamic time zone. when user change time zone in ctradr indicator should change.

Hi,

You can use the Application.UserTimeOffset to get the user Time zone offset, and if user change the time zone you can use the Application.UserTimeOffsetChanged event to get user new time zone offset.

Check the example code of Application on API references.


@amusleh

IRCtrader
22 Jun 2021, 20:00 ( Updated at: 22 Jun 2021, 20:10 )

RE: RE:

amusleh said:

khoshroomahdi said:

i know that. but i want dynamic time zone. when user change time zone in ctradr indicator should change.

Hi,

You can use the Application.UserTimeOffset to get the user Time zone offset, and if user change the time zone you can use the Application.UserTimeOffsetChanged event to get user new time zone offset.

Check the example code of Application on API references.

could you please give me sample code .My code is below post

cTDN Forum - Help: show daily percent profit on chart (ctrader.com)


@IRCtrader