Trading times
Trading times
25 Sep 2022, 13:38
Hello,
maybe ask multiple times, but i can´t find it. How can i restrict the execution time of orders to for example 7am till 5pm on weekdays?
thanks in advanced
Alex
Replies
mindfulness
25 Sep 2022, 15:11
( Updated at: 21 Dec 2023, 09:22 )
RE: RE:
mindfulness said:
mindfulness said:
Hello,
maybe ask multiple times, but i can´t find it. How can i restrict the execution time of orders to for example 7am till 5pm on weekdays?
thanks in advanced
Alex
I have tried it now with this, but was not succesfull. The error messages: (sorry in german)
if (Server.Time.TimeOfDay > TimeSpan.ParseExact("07:00")) & (Server.Time.TimeOfDay < TimeSpan.ParseExact("17:00")); { if (bullish) { if (!IsPositionOpenByType(TradeType.Buy)) { OpenPosition(TradeType.Buy); } } if (exit_bullish) { ClosePosition(TradeType.Buy); } if (bearish) { if (!IsPositionOpenByType(TradeType.Sell)) { OpenPosition(TradeType.Sell); } } if (exit_bearish) { ClosePosition(TradeType.Sell); } } }
Also tried this one. Now without error messages, but just ignored when executing.
if ((DateTime.Now.Hour >= 07) & (DateTime.Now.Hour <= 17));
@mindfulness
mindfulness
25 Sep 2022, 17:48
( Updated at: 21 Dec 2023, 09:22 )
RE: RE: RE:
mindfulness said:
mindfulness said:
mindfulness said:
Hello,
maybe ask multiple times, but i can´t find it. How can i restrict the execution time of orders to for example 7am till 5pm on weekdays?
thanks in advanced
Alex
I have tried it now with this, but was not succesfull. The error messages: (sorry in german)
if (Server.Time.TimeOfDay > TimeSpan.ParseExact("07:00")) & (Server.Time.TimeOfDay < TimeSpan.ParseExact("17:00")); { if (bullish) { if (!IsPositionOpenByType(TradeType.Buy)) { OpenPosition(TradeType.Buy); } } if (exit_bullish) { ClosePosition(TradeType.Buy); } if (bearish) { if (!IsPositionOpenByType(TradeType.Sell)) { OpenPosition(TradeType.Sell); } } if (exit_bearish) { ClosePosition(TradeType.Sell); } } }
Also tried this one. Now without error messages, but just ignored when executing.
if ((DateTime.Now.Hour >= 07) & (DateTime.Now.Hour <= 17));
Can be closed, got it working:
var tradingStarts = TimeSpan.ParseExact("08:00", "hh\\:mm", null);
var tradingStops = TimeSpan.ParseExact("18:00", "hh\\:mm", null);
if (Server.Time.TimeOfDay >= tradingStarts && Server.Time.TimeOfDay < tradingStops)
@mindfulness
mindfulness
25 Sep 2022, 14:29
RE:
mindfulness said:
I have tried it now with this, but was not succesfull. The error messages: (sorry in german)
@mindfulness