Problem with Day && Time orders.
Problem with Day && Time orders.
10 Apr 2017, 18:43
Hello, my problem is when I run this cBot, orders won't be placed.
Solving my problem from somebody's help would be very appreciated.
Thank you..
// -----------------------------------------------------------------------------------------------------------------------------
// Code here :
[Parameter("OpenDay", DefaultValue = 5)]
public int dOpenDayTime { get; set; }
[Parameter("OpenHour", DefaultValue = 13)]
public int dOpenHourTime { get; set; }
[Parameter("OpenMinute", DefaultValue = 59)]
public int dOpenMinuteTime { get; set; }
[Parameter("OpenSecond", DefaultValue = 59)]
public int dOpenSecondTime { get; set; }
protected override void OnTick()
{
var _TimeDays = Server.Time.TimeOfDay.TotalDays;
var _TimeHours = Server.Time.TimeOfDay.TotalHours;
var _TimeMinutes = Server.Time.TimeOfDay.TotalMinutes;
var _TimeSeconds = Server.Time.TimeOfDay.TotalSeconds;
if (_TimeDays == dOpenDayTime && _TimeHours == dOpenHourTime &&
_TimeMinutes == dOpenMinuteTime && _TimeSeconds >= dOpenSecondTime &&
MarketSeries.Close[1] > MarketSeries.Open[0])
{
ExecuteMarketOrder(TradeType.Sell, Symbol, VolumeInUnits, label, StopLoss, TakeProfit);
}
}
Replies
waixiong97@gmail.com
27 May 2017, 03:29
RE:
lucian said:
You can start with this code:
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter("OpenDay", DefaultValue = 5)] public int dOpenDayTime { get; set; } [Parameter("OpenHour", DefaultValue = 13)] public int dOpenHourTime { get; set; } [Parameter("OpenMinute", DefaultValue = 59)] public int dOpenMinuteTime { get; set; } [Parameter("OpenSecond", DefaultValue = 59)] public int dOpenSecondTime { get; set; } protected override void OnTick() { var _TimeDays = (int)Server.Time.DayOfWeek; var _TimeHours = Server.Time.Hour; var _TimeMinutes = Server.Time.Minute; var _TimeSeconds = Server.Time.Second; if (_TimeDays == dOpenDayTime && _TimeHours == dOpenHourTime && _TimeMinutes == dOpenMinuteTime && _TimeSeconds >= dOpenSecondTime && MarketSeries.Close[1] > MarketSeries.Open[0]) { ExecuteMarketOrder(TradeType.Sell, Symbol, 1000, "label", 10, 10); } } } }
I use this as template to do, but when I do the backtesting, still no order is executed
@waixiong97@gmail.com
... Deleted by UFO ...