Trades at specific times
Trades at specific times
17 Aug 2020, 16:10
Hello, I'm trying to create a code to start trading at a specific time. But I'm not succeeding
follow the example below
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class bot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
[Parameter("Begin Trading Hour", DefaultValue = 6)]
public int Begin { get; set; }
[Parameter("Ending Trading Hour", DefaultValue = 18)]
public int Ending { get; set; }
private DateTime startTime;
private DateTime endTime;
protected override void OnTick()
{
startTime = Server.Time.Date.AddHours(Begin);
endTime = Server.Time.Date.AddHours(Ending);
if (Trade.IsExecuting)
return;
bool tradeTime = false;
if (Begin < Ending)
tradeTime = Server.Time.Hour >= Begin && Server.Time.Hour < Ending;
if (Ending < Begin)
tradeTime = Server.Time.Hour >= Begin || Server.Time.Hour <= Ending;
if (!tradeTime)
return;
Replies
samuel.jus.cornelio
17 Aug 2020, 17:05
RE:
PanagiotisCharalampous said:
Hi Sam,
Can you explain what is the problem?
Best Regards,
Panagiotis
Hey bro the code simply does not work, no error message appears, but the code continues making trades outside the specified time
@samuel.jus.cornelio
PanagiotisCharalampous
17 Aug 2020, 16:46
Hi Sam,
Can you explain what is the problem?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous