How to open one position in a exact hour, for example 02:00 AM

Created at 16 May 2019, 17:12
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

How to open one position in a exact hour, for example 02:00 AM
16 May 2019, 17:12


I wish only one open position in this hour and again next day, in the same hour, even that I am using the frame different of hours, for example 15 min, or 30 min.

I appreciate this help

Tks


@eliezer_barros
Replies

firemyst
22 Sep 2019, 15:55

RE:

eliezer_barros said:

I wish only one open position in this hour and again next day, in the same hour, even that I am using the frame different of hours, for example 15 min, or 30 min.

I appreciate this help

Tks

//Only enter at specified time
if (Server.Time.Hour == ServerHourToPlaceOrderParameter)
{
  ///place your order
}

 


@firemyst

mparama
27 Sep 2019, 04:20

[Parameter("===== SELL Time =====", DefaultValue = "============")]
        public string sep1 { get; set; }
        [Parameter("SELL", DefaultValue = true)]
        public bool Sell { get; set; }
        [Parameter("Start Hour", DefaultValue = 10, MinValue = 2, MaxValue = 21)]
        public int StartTimeHour_Sell { get; set; }
        [Parameter("Start Minutes", DefaultValue = 15, MinValue = 0, MaxValue = 59)]
        public int StartTimeMinutes_Sell { get; set; }
         //-------------
        [Parameter("======= BUY Time ======", DefaultValue = "============")]
        public string sep2 { get; set; }
        [Parameter("Buy", DefaultValue = false)]
        public bool Buy { get; set; }
        [Parameter("Start Hour", DefaultValue = 13, MinValue = 2, MaxValue = 21)]
        public int StartTimeHour_Buy { get; set; }
        [Parameter("Start Minutes", DefaultValue = 30, MinValue = 0, MaxValue = 59)]
        public int StartTimeMinutes_Buy { get; set; }      
        //=========================================================================

........................................

........................................

//============== =====================
            var currentHours = Server.TimeInUtc.TimeOfDay.Hours;
            var currentMinute = Server.TimeInUtc.TimeOfDay.Minutes;
            //------- Time in UTC -------
            if (Server.TimeInUtc.IsDaylightSavingTime())
            {
                //----- Server Time Ora Legale ------
                currentHours = Server.TimeInUtc.AddHours(+1).TimeOfDay.Hours;
                currentMinute = Server.TimeInUtc.TimeOfDay.Minutes;
            }
            if (Server.TimeInUtc.IsDaylightSavingTime() == false)
            {
                //----- Server Time NO Ora Legale ------
                currentHours = Server.TimeInUtc.AddHours(+2).TimeOfDay.Hours;
                currentMinute = Server.TimeInUtc.TimeOfDay.Minutes;
            }
            //-----------------------------------------------
            var Time_Buy = currentHours == StartTimeHour_Buy && currentMinute == StartTimeMinutes_Buy;
            var Time_Sell = currentHours == StartTimeHour_Sell && currentMinute == StartTimeMinutes_Sell;


@mparama