JA
cBot with Awesome Oscillator
25 Feb 2019, 11:41
Battling with the Function HasCrossedAbove on this cBot
Below is where I think my problem lies.
public override void Calculate(int index) ? and currently do not have anything under parameters also.

Build result is succesful but no trades is being excecuted
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 Elders_Impulse : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
// Put your initialization logic here
}
protected override void OnTick()
{
// Put your core logic here
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Replies
... Deleted by UFO ...
opit78
04 Jun 2020, 00:49
RE: Apologies copied incorrect code, below the code on which I am working on
jpwtrading said:
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 Awesome_Oscillator : Robot { [Parameter("Start Time", DefaultValue = "02:00")] public string StartTime { get; set; } [Parameter("Stop Time", DefaultValue = "22:00")] public string StopTime { get; set; } [Parameter("Stop Loss", DefaultValue = 10)] public int StopLoss { get; set; } [Parameter("Take Profit", DefaultValue = 20)] public int TakeProfit { get; set; } [Parameter("Slippage", DefaultValue = 0.1)] public int Slippage { get; set; } [Parameter("Volume In Units", DefaultValue = 1000)] public double volumeInUnits { get; set; } private AwesomeOscillator AwesomeOscillator; protected override void OnStart() { AwesomeOscillator = Indicators.AwesomeOscillator(); } protected override void OnBar() { var tradingStarts = TimeSpan.ParseExact(StartTime, "hh\\:mm", null); var tradingStops = TimeSpan.ParseExact(StopTime, "hh\\:mm", null); if (Server.Time.TimeOfDay >= tradingStarts && Server.Time.TimeOfDay < tradingStops) if (Functions.IsRising(AwesomeOscillator.Result) && Functions.HasCrossedAbove(AwesomeOscillator.Result, MarketSeries.Close, 10)) ExecuteMarketOrder(TradeType.Buy, Symbol, volumeInUnits, "cBot", StopLoss, TakeProfit, Slippage, "this is a comment"); if (Functions.IsFalling(AwesomeOscillator.Result) && Functions.HasCrossedBelow(AwesomeOscillator.Result, MarketSeries.Close, 10)) ExecuteMarketOrder(TradeType.Sell, Symbol, volumeInUnits, "cBot", StopLoss, TakeProfit, Slippage, "this is a comment"); } protected override void OnStop() { // Put your deinitialization logic here } } }
Have you sorted this out yet ?
@opit78

jamespeterwilkinson
25 Feb 2019, 11:42
Apologies copied incorrect code, below the code on which I am working on
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 Awesome_Oscillator : Robot { [Parameter("Start Time", DefaultValue = "02:00")] public string StartTime { get; set; } [Parameter("Stop Time", DefaultValue = "22:00")] public string StopTime { get; set; } [Parameter("Stop Loss", DefaultValue = 10)] public int StopLoss { get; set; } [Parameter("Take Profit", DefaultValue = 20)] public int TakeProfit { get; set; } [Parameter("Slippage", DefaultValue = 0.1)] public int Slippage { get; set; } [Parameter("Volume In Units", DefaultValue = 1000)] public double volumeInUnits { get; set; } private AwesomeOscillator AwesomeOscillator; protected override void OnStart() { AwesomeOscillator = Indicators.AwesomeOscillator(); } protected override void OnBar() { var tradingStarts = TimeSpan.ParseExact(StartTime, "hh\\:mm", null); var tradingStops = TimeSpan.ParseExact(StopTime, "hh\\:mm", null); if (Server.Time.TimeOfDay >= tradingStarts && Server.Time.TimeOfDay < tradingStops) if (Functions.IsRising(AwesomeOscillator.Result) && Functions.HasCrossedAbove(AwesomeOscillator.Result, MarketSeries.Close, 10)) ExecuteMarketOrder(TradeType.Buy, Symbol, volumeInUnits, "cBot", StopLoss, TakeProfit, Slippage, "this is a comment"); if (Functions.IsFalling(AwesomeOscillator.Result) && Functions.HasCrossedBelow(AwesomeOscillator.Result, MarketSeries.Close, 10)) ExecuteMarketOrder(TradeType.Sell, Symbol, volumeInUnits, "cBot", StopLoss, TakeProfit, Slippage, "this is a comment"); } protected override void OnStop() { // Put your deinitialization logic here } } }@jamespeterwilkinson