Topics
09 Oct 2021, 16:30
 3
 1013
 1
12 Sep 2020, 13:12
 5
 1538
 1
09 Mar 2020, 16:58
 4
 947
 1
24 Feb 2020, 11:31
 4
 1131
 1
24 Feb 2020, 11:19
 2
 1004
 2
17 Mar 2014, 18:32
 2520
 3
30 Jan 2014, 15:43
 2730
 1
Replies

abotrader
13 Oct 2023, 14:32

Fractal indicators with API

hello,

Please, Can you add Bars as paramater to Fractal indicators method creation to use it in MultiSymbols cBots and Indicators 

 


@abotrader

abotrader
18 Feb 2021, 15:05

RE:

PanagiotisCharalampous said:

Hi abtraderdemo,

The plan is for Q3 2021.

Best Regards,

Panagiotis 

Join us on Telegram

This version will be with .NET 6.0 LTS?

Microsoft publish a preview verion :

 


@abotrader

abotrader
28 Jan 2021, 14:29

RE:

Thanks,

With the Swap feature also?

Best Regards,

 

PanagiotisCharalampous said:

Hi abtraderdemo,

The plan is for Q3 2021.

Best Regards,

Panagiotis 

Join us on Telegram

 


@abotrader

abotrader
27 Jan 2021, 21:20

Swap in backtesting and optimization and .Net 5.0

Hi,

Thanks for your effort, but I'm waiting for Swap in backtesting and optimization for testing my strategies with cBot (it's too long).

Have you a deadline (estimationb) for cTrader with .Net 5.0?


@abotrader

abotrader
06 Jan 2021, 12:15

RE:

PanagiotisCharalampous said:

Hi acrigney,

The team is already working on this. However we do not have an ETA for this since it is a complicated task.

Best Regards,

Panagiotis 

Join us on Telegram

Hi,

@PanagiotisCharalampous and what about the UI evolution there is a migration of UI to .NET 5.0 and 6.0 after this also to be compatible with OSX, Linux, Mobile...?

And what about using CTrader in Container or Cloud in the future (Ex to do Front-End (Desktop or WEB) and Back-End (REST or Other in Container or Cloud Ex. for cBot... )?


@abotrader

abotrader
12 Sep 2020, 15:55

I agree also, with the version .Net 5.0 and also the future version 6.0 (UI mutli platform Mac OS, Linux...).


@abotrader

abotrader
12 Sep 2020, 13:52

RE: UserVoice

ctdn_voter said:

cAlgo platform made to operate on a Mac. It doesn't need to be available in the app store, however, a downloadable version made for Mac would be great.

I think it's possible to start migration to Dot Net 5 and 6 for multi platform.
There is a roadmap for this migration?


@abotrader

abotrader
12 Jul 2020, 20:57

RE:

PanagiotisCharalampous said:

Hi all,

We are currently working on migrating cTrader to .Net Core.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi,

It will be a good thing to deploy CBot on Cloud and Container (Linux and Windows) with .NET Core.

Best Regards,

AB Trader


@abotrader

abotrader
09 Mar 2020, 18:03

Can you please also add TimeFrame parameter to Optimization


@abotrader

abotrader
15 Jun 2019, 20:18 ( Updated at: 21 Dec 2023, 09:21 )

Hi,

I sent an email to the support of myfxbook.com and he below their answer, can you investigate on your side please or see with myfxbook team.

  Best Regards,


@abotrader

abotrader
08 Jun 2019, 08:43

RE:

lec0456 said:

HI, I made some changes to my Bot and it has slowed down to a crawl. It takes 2 hrs to run 6 month of tick data. I was wondering if anyone knew how I could isolate the code that is slowing it down? Is there a technique or a way through Visual studio?  Any help would be much apprieciated

Hi,

I thanks that may be you can do a "Profiling with Diagnostics Tools in Visual Studio" ses a small video at https://www.youtube.com/watch?v=LhhGqNAGQHU

Best Regards,


@abotrader

abotrader
10 Oct 2018, 14:25

Please retry with this method 


        void OnPositionOpened(PositionOpenedEventArgs args)
        {
            if (RunningMode != RunningMode.Optimization)
            {
                Chart.DrawVerticalLine(Guid.NewGuid().ToString(), args.Position.EntryTime, (args.Position.TradeType == TradeType.Buy ? Color.Red : Color.Blue));
                Chart.DrawText(Guid.NewGuid().ToString(), "Opened " + args.Position.TradeType, args.Position.EntryTime, args.Position.EntryPrice, Color.White);
            }
        }

 


@abotrader

abotrader
09 Oct 2018, 20:50

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MACD_PSAR_STOCH : Robot
    {
        const string Label = "MACD_PSAR_STOCH";

        [Parameter(DefaultValue = 1, Step = 1, MaxValue = 1, MinValue = 1)]
        public int MaxTrades { get; set; }

        [Parameter(DefaultValue = 70, Step = 1, MaxValue = 300, MinValue = 70)]
        public double TakeProfit { get; set; }

        [Parameter(DefaultValue = 300, Step = 1, MaxValue = 350, MinValue = 70)]
        public double StopLoss { get; set; }

        // MACD
        [Parameter(DefaultValue = 26, Step = 1, MaxValue = 50, MinValue = 1)]
        public int LongCycle { get; set; }

        [Parameter(DefaultValue = 14, Step = 1, MaxValue = 30, MinValue = 1)]
        public int ShortCycle { get; set; }

        [Parameter(DefaultValue = 9, Step = 1, MaxValue = 50, MinValue = 1)]
        public int Period { get; set; }

        // Stochastic
        [Parameter(DefaultValue = 14, Step = 1, MaxValue = 50, MinValue = 1)]
        public int Kperiod { get; set; }

        [Parameter(DefaultValue = 3, Step = 1, MaxValue = 50, MinValue = 1)]
        public int KSlowing { get; set; }

        [Parameter(DefaultValue = 9, Step = 1, MaxValue = 50, MinValue = 1)]
        public int Dperiod { get; set; }

        [Parameter(DefaultValue = 2, Step = 1)]
        public int RiskPercent { get; set; }

        [Parameter(DefaultValue = 10, Step = 10)]
        public int Volume { get; set; }

        [Parameter(DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MAType { get; set; }

        MacdCrossOver macd;
        ParabolicSAR sar;
        StochasticOscillator stoch;

        protected override void OnStart()
        {
            Positions.Opened += OnPositionOpened;
            Positions.Closed += OnPositionClosed;
            macd = Indicators.MacdCrossOver(MarketSeries.Close, LongCycle, ShortCycle, Period);
            sar = Indicators.ParabolicSAR(0.02, 0.2);
            stoch = Indicators.StochasticOscillator(Kperiod, KSlowing, Dperiod, MAType);
        }

        protected override void OnTick()
        {
            double Bid = Symbol.Bid;
            double Ask = Symbol.Ask;
            double Point = Symbol.TickSize;
            if (sar.Result.Last(1) > Bid && macd.MACD.IsRising() && macd.MACD.HasCrossedAbove(macd.Signal, 0) && (stoch.PercentK.Last(0) < 35 || (stoch.PercentK.HasCrossedAbove(stoch.PercentD, 0) && stoch.PercentK.IsRising())))
            {
                ClosePositions(TradeType.Sell);
                if (Check())
                {
                    ExecuteMarketOrder(TradeType.Buy, Symbol, CalculateVolume(), Label, StopLoss, TakeProfit);
                }
            }
            else if (sar.Result.Last(1) < Ask && macd.MACD.IsFalling() && macd.MACD.HasCrossedBelow(macd.Signal, 0) && (stoch.PercentK.Last(0) > 60 || (stoch.PercentD.HasCrossedAbove(stoch.PercentK, 0) && stoch.PercentD.IsRising())))
            {
                ClosePositions(TradeType.Buy);
                if (Check())
                {
                    ExecuteMarketOrder(TradeType.Sell, Symbol, CalculateVolume(), Label, StopLoss, TakeProfit);
                }
            }
        }
          protected override void OnStop()
        {
            if (IsBacktesting)
            {
                foreach (var pos in Positions.FindAll(Label, Symbol))
                {
                    ClosePosition(pos);
                }
            }
        }

        void OnPositionOpened(PositionOpenedEventArgs args)
        {
            if (RunningMode != RunningMode.Optimization)
            {
                Chart.DrawVerticalLine(Guid.NewGuid().ToString(), args.Position.EntryTime, (args.Position.TradeType == TradeType.Buy ? Color.Red : Color.Blue));
                //Chart.DrawText(Guid.NewGuid().ToString(), "Opened " + args.Position.TradeType, args.Position.EntryTime, args.Position.EntryPrice, Color.White);
            }
        }

        void OnPositionClosed(PositionClosedEventArgs args)
        {

        }


        double CalculateVolume()
        {
            double _volume = 0;
            if (Volume == 0)
            {
                // Our total balance is our account balance plus any reserve funds. We do not always keep all our money in the trading account.
                double totalBalance = Account.Balance / MaxTrades;

                // Calculate the total risk allowed per trade.
                double riskPerTrade = (totalBalance * RiskPercent) / 100;
                // Add the stop loss, commission pips and spread to get the total pips used for the volume calculation.
                double totalPips = StopLoss + Symbol.Spread + 0.8;
                // CommissionPips
                // Calculate the exact volume to be traded. Then round the volume to the nearest 100,000 and convert to an int so that it can be returned to the caller.
                _volume = Math.Round(riskPerTrade / (Symbol.PipValue * totalPips), 2);

            }
            else
            {
                _volume = Volume;
            }
            return Symbol.NormalizeVolumeInUnits(_volume);
        }

        int NumberOfOpenOrders()
        {
            return Positions.FindAll(Label, Symbol).Length;
        }

        bool Check()
        {

            bool result = true;
            if (NumberOfOpenOrders() >= MaxTrades)
            {
                result = false;
            }
            else if (Account.MarginLevel != null && Account.MarginLevel < 130)
            {
                string msg = String.Format("{0} Check => Equity {1} MarginLevel {2} ", Server.Time, Account.Equity, Account.MarginLevel);
                Print(msg);
                result = false;
            }
            return result;
        }

        void ClosePositions(TradeType tradeType)
        {
            foreach (var position in Positions.FindAll(Label, Symbol, tradeType))
            {
                ClosePosition(position);
            }
        }

        double NormalizePrice(double d)
        {
            return Math.Round(d, Symbol.Digits);
        }

        protected override void OnError(Error error)
        {
            Print("Error Code : {0} ", error.Code);
            if (error.Code == ErrorCode.NoMoney)
                Stop();
        }
    }
}

parameter !

 

[ChartParameters]
Symbol = MICROSOFT
Timeframe = m1

[cBotParameters]
MaxTrades = 1
TakeProfit = 178
StopLoss = 235
LongCycle = 17
ShortCycle = 5
Period = 15
Kperiod = 11
KSlowing = 38
Dperiod = 20
RiskPercent = 2
Volume = 1
MAType = TimeSeries


@abotrader

abotrader
08 Oct 2018, 23:05

HI,

My cAlgo version 3.03 is freezing in visual testing when i add this code :

        void OnPositionOpened(PositionOpenedEventArgs args)
        {
            if (RunningMode != RunningMode.Optimization)
            {
                Chart.DrawVerticalLine(Guid.NewGuid().ToString(), args.Position.EntryTime, (args.Position.TradeType == TradeType.Buy ? Color.Red : Color.Blue));
                Chart.DrawText(Guid.NewGuid().ToString(), "Opened " + args.Position.TradeType, args.Position.EntryTime, args.Position.EntryPrice, Color.White);
            }
        }

 


@abotrader

abotrader
17 Mar 2014, 21:56

RE:

aboukerker said:

it's possible to use  History in backtesting ? 

History don't work in backtesting


@abotrader

abotrader
01 Mar 2014, 22:27

           if (pos == null)
               return  new TriState();

to know exception in your code  do :

try {

// your code here

            } catch (Exception e)
            {
                Print("{0} ", e.StackTrace);

}

 

 


@abotrader

abotrader
24 Feb 2014, 18:05

RE:

aboukerker said:

22/02/2014 15:22:30.683 | Backtesting stopped: Error #494830 occurred

I can't test cBots with TimeFrame M20 


@abotrader

abotrader
29 Sep 2013, 06:42

Using RSI INdicator

admin said:

Use this code to create a custom RSI in order to make modifications such as adjusting the Levels of the RSI indicator. 

For example you may change the code of [Levels(25, 50, 75)] to the values of your choice.

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator]
    [Levels(25, 50, 75)]
    public class RSI:Indicator
    {
        [Parameter]
        public DataSeries Source { get; set; }

        [Parameter(DefaultValue = 14, MinValue = 1)]
        public int Periods { get; set; }

        [Output("Main", Color = Colors.Green)]
        public IndicatorDataSeries Result { get; set; }

        private IndicatorDataSeries _profit;
        private IndicatorDataSeries _loss;

        private ExponentialMovingAverage _emaProfit;
        private ExponentialMovingAverage _emaLoss;

        protected override void Initialize()
        {
            _profit = CreateDataSeries();
            _loss = CreateDataSeries();
            
            var emaPeriods = 2 * Periods - 1;

            _emaProfit = Indicators.ExponentialMovingAverage(_profit, emaPeriods);
            _emaLoss = Indicators.ExponentialMovingAverage(_loss, emaPeriods);
        }

        public override void Calculate(int index)
        {
            var lastPrice = Source[index];
            var previousPrice = Source[index - 1];

            if (lastPrice > previousPrice)
            {
                _profit[index] = lastPrice - previousPrice;
                _loss[index] = 0.0;
            }
            else if (lastPrice < previousPrice)
            {
                _profit[index] = 0.0;
                _loss[index] = previousPrice - lastPrice;
            }
            else
            {
                _profit[index] = 0.0;
                _loss[index] = 0.0;
            }

            var relativeStrength = _emaProfit.Result[index] / _emaLoss.Result[index];

            Result[index] = 100 - (100 / (1 + relativeStrength));
            
        }
    }
}

Hello,

How to use this indicator in Robot and wht mean

 [Levels(25, 50, 75)]

Best regards


@abotrader