i keep trying
i keep trying
18 Aug 2020, 20:57
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;
samuel.jus.cornelio
19 Aug 2020, 02:28
RE:
samuel.jus.cornelio said:
I already managed to solve the problem
@samuel.jus.cornelio