Topics

Forum Topics not found

Replies

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