Topics
24 Oct 2020, 15:02
 4
 1377
 1
20 Aug 2020, 12:10
 8
 1269
 1
25 Jun 2020, 12:05
 1713
 3
22 May 2020, 10:18
 3
 1027
 1
14 May 2020, 10:54
 2
 1572
 4
14 May 2020, 10:33
 4
 1125
 1
03 May 2020, 11:42
 2
 1163
 1
03 May 2020, 11:36
 3
 978
 1
03 May 2020, 11:32
 10
 2116
 5
27 Apr 2020, 18:28
 3
 925
 1
27 Apr 2020, 18:23
 3
 997
 1
27 Apr 2020, 12:08
 3
 947
 1
27 Apr 2020, 12:05
 2
 978
 1
23 Apr 2020, 11:33
 15
 1658
 1
23 Apr 2020, 11:24
 4
 1210
 1
Replies

afhacker
14 Nov 2024, 11:39 ( Updated at: 14 Nov 2024, 11:40 )

Hi,

As a workaround you can try setting Button content to a TextBlock with your font properties instead of using Button Text property:

var button = new Button()
{
Content = new TextBlock {Text = "Test", FontFamily = "Consolas", FontSize = 20},
Width = 100,
Height = 30,
IsVisible = true,
};


@afhacker

afhacker
12 Nov 2024, 07:09

Hi,

You can achieve it with reflection:

using System.Collections.Generic;
using System.Reflection;
using cAlgo.API;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None)]
    public class TimeFramesEnumerableTest : Indicator
    {
        protected override void Initialize()
        {
            foreach (var timeFrame in GetTimeFrames())
            {
                Print(timeFrame);
            }
        }

        public override void Calculate(int index)
        {
        }

        private IEnumerable<TimeFrame> GetTimeFrames()
        {
            var timeFrameFields = typeof(TimeFrame).GetFields(BindingFlags.Static | BindingFlags.Public);

            foreach (var timeFrameField in timeFrameFields)
            {
                if (timeFrameField.FieldType != typeof(TimeFrame))
                    continue;
                
                yield return (TimeFrame)timeFrameField.GetValue(null);
            }
        }
    }
}


@afhacker

afhacker
29 Aug 2024, 10:57 ( Updated at: 29 Aug 2024, 14:03 )

Hi,

If you want to you can do this programmatically, you can use ChartRobots API to add robot instances to chart and set each instance parameter values separately.

Or you can use a plugin to manage all your cBot instances with same API.

Checkout these plugin samples:

ctrader-algo-samples/Plugins/ChartRobots Sample at main · spotware/ctrader-algo-samples (github.com)

ctrader-algo-samples/Plugins/AlgoRegistry Sample at main · spotware/ctrader-algo-samples (github.com)


@afhacker

afhacker
02 Apr 2021, 15:20

The numbers appeared on variable names because I copied the code, please use the code snippet of editor to post code as I do.

The variables are not defined, that's why you are getting that error, you have to first define a variable then use it.

Here is the code:

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 aNarrowestCI : Robot

    {

        [Parameter(DefaultValue = 0.0)]

        public double Parameter { get; set; }

        private Bars series2, series3;

        private Symbol symbol2, symbol3;

        [Parameter(DefaultValue = "EURUSD")]

        public string Symbol2 { get; set; }

        [Parameter(DefaultValue = "GBPUSD")]

        public string Symbol3 { get; set; }

        protected override void OnStart()

        {

            var dailyBars = MarketData.GetBars(TimeFrame.Daily);

            dailyBars.BarOpened += OnDailyBarsBarOpened;

        }

        void OnDailyBarsBarOpened(BarOpenedEventArgs obj)

        {

            var Lag1USDCADHigh = obj.Bars.HighPrices.Last(1);

            var Lag1USDCADOpen = obj.Bars.OpenPrices.Last(1);

            var Lag1USDCADLow = obj.Bars.LowPrices.Last(1);

            var Lag1USDCADOpenHigh = Lag1USDCADHigh - Lag1USDCADOpen;

            var Lag1USDCADOpenLow = Lag1USDCADOpen - Lag1USDCADLow;

            var Lag1USDCADVolume = obj.Bars.TickVolumes.Last(1);

            var Lag1USDCADPropOH = (Lag1USDCADOpenHigh / Lag1USDCADOpen) * 100;

            var symbol2 = Symbols.GetSymbol(Symbol2);

            series2 = MarketData.GetBars(TimeFrame.Daily, Symbol2);

            var GBPUSDYDaysClose = series2.ClosePrices.Last(0);

            var Lag1GBPUSDHigh = series2.HighPrices.Last(0);

            var Lag1GBPUSDLow = series2.LowPrices.Last(0);

            var Lag1GBPUSDOpen = series2.OpenPrices.Last(0);

            var Lag1GBPUSDOpenLow = Lag1GBPUSDOpen - Lag1GBPUSDLow;

            var Lag1GBPUSDOpenHigh = Lag1GBPUSDHigh - Lag1GBPUSDOpen;

            var Lag1GBPUSDPropHighLow = ((Lag1GBPUSDHigh - Lag1GBPUSDLow) / Lag1GBPUSDOpen) * 100;

            var symbol3 = Symbols.GetSymbol(Symbol3);

            series3 = MarketData.GetBars(TimeFrame.Daily, Symbol3);

            var Lag1EURUSDHigh = series3.HighPrices.Last(0);

            var Lag1EURUSDOpen = series3.OpenPrices.Last(0);

            var Lag1EURUSDVolume = series3.TickVolumes.Last(1);

            // < 1.10

            //Long Model 5

            var FM5LongMath = -1 + (2 * Lag1USDCADHigh) + (3* Lag1USDCADOpenLow) + (4 * Lag1GBPUSDOpenLow) + (-5 * Lag1GBPUSDPropHighLow) + (6 * Lag1EURUSDHigh);

            //Short Model 2

            var FM2ShortMath = -7 + (8 * Lag1USDCADLow) + (9 * Lag1USDCADOpenHigh);

            var FM5LongSL_15 = -10;

            var FM2ShortSL_15 = 9;

            //>= 1.10 GBPUSDYDaysClose < 1.20         

            //Long Model 5

            var FM5LongSL_15_20 = -8;

            //Short Model 3

            var FM3ShortMath = 7 + (6 * Lag1USDCADLow) + (5 * Lag1USDCADOpenHigh) + (-4 * Lag1GBPUSDOpen);

            var FM3ShortSL_15_20 = 3;

            //>= 1.20 GBPUSDYDaysClose < 1.25

            //Long Model 5

            var FM5LongSL_20_25 = 2;

            //Short Model 2

            var FM2ShortSL_20_25 = 1;

            //  >= 1.25 GBPUSDYDaysClose < 1.30

            //Long Model 5

            var FM5LongSL_25_30 = -1;

            //Short Model 2

            var SM2ShortMath = -2 + (3 * Lag1USDCADOpen) + (4 * Lag1USDCADPropOH);

            var SM2ShortSL_25_30 = 5;

            //>= 1.30 GBPUSDYDaysClose < 1.45

            //Long Model 5

            var FM5LongSL_30_45 = -6;

            //Short Model 4

            var FM4ShortMath = 7 + (8 * Lag1USDCADLow) + (9 * Lag1USDCADOpenHigh) + (-8 * Lag1GBPUSDOpen) + (-1 * Lag1USDCADOpenLow);

            var FM4ShortSL_30_45 = 2;

            //GBPUSDYDaysClose >= 1.45

            //Long Model 1

            var BM1LongMath = -3 + (4 * GBPUSDYDaysClose) + (5 * Lag1USDCADOpen) + (-6 * Lag1USDCADVolume) + (-7 * Lag1GBPUSDOpenHigh) + (8 * Lag1EURUSDVolume) + (9 * Lag1USDCADOpenHigh) + (8 * Lag1USDCADOpenLow) + (7 * Lag1GBPUSDPropHighLow) + (6 * Lag1EURUSDOpen);

            var BM1LongSL_45 = -54.13;

            //Short Model 3

            var FM3ShortSL_45 = 102.914;

            double TargetLongMath = 0;
            double TargetShortMath = 0;

            if (GBPUSDYDaysClose < 15)

            {

                TargetLongMath = FM5LongMath;

                // var LongSL = FM5LongSL_15;

                //var TargetShortMath = FM2ShortMath;

                // var ShortSL = FM2ShortSL_15;

            }

            else

            {

                if ((GBPUSDYDaysClose >= 15) && (GBPUSDYDaysClose < 20))

                {

                    TargetLongMath = FM5LongMath;

                    //var LongSL = FM5LongSL_15_20;

                    //var TargetShortMath = FM3ShortMath;

                    //var ShortSL = FM3ShortSL_15_20;

                }

                else if ((GBPUSDYDaysClose >= 20) && (GBPUSDYDaysClose < 25))

                {

                    TargetLongMath = FM5LongMath;

                    // var LongSL = FM5LongSL_20_25;

                    //var TargetShortMath = FM2ShortMath;

                    //var ShortSL = FM2ShortSL_20_25;

                }

                else if ((GBPUSDYDaysClose >= 25) && (GBPUSDYDaysClose < 30))

                {

                    TargetLongMath = FM5LongMath;

                    // var LongSL = FM5LongSL_25_30;

                    //var TargetShortMath = SM2ShortMath;

                    // var ShortSL = SM2ShortSL_25_30;

                }

                else if ((GBPUSDYDaysClose >= 30) && (GBPUSDYDaysClose < 45))

                {

                    TargetLongMath = FM5LongMath;

                    // var LongSL = FM5LongSL_30_45;

                    //var TargetShortMath = FM4ShortMath;

                    //var ShortSL = FM4ShortSL_30_45;

                }

                else if (GBPUSDYDaysClose >= 45)

                {

                    TargetLongMath = BM1LongMath;

                    // var LongSL = BM1LongSL_45;

                    //var TargetShortMath = FM3ShortMath;

                    //var ShortSL = FM3ShortSL_45;

                }

                //Long structure

                //var Targetlong = TargetLongMath;

                var TargetLong = (Math.Round(TargetLongMath, 3));

                var TargetPipslong = TargetLong - Symbol.Bid * Symbol.PipSize;

                var TargetPipsLong = (Math.Round(TargetPipslong, 3));

                //Short structure

                var TargetShort = (Math.Round(TargetShortMath, 3));

                var TargetPipsshort = TargetShort - Symbol.Ask * Symbol.PipSize;

                var TargetPipsShort = (Math.Round(TargetPipsshort, 3));

                foreach (var position in Positions)

                {

                    ClosePosition(position);

                }

                if (TargetPipsLong > 0)

                {

                    if (TargetPipsShort > 0)

                    {

                        var risk = 0.95;

                        double Volume = (long)Math.Ceiling(Account.Equity / 100) * risk;

                        double MaxVolume = Volume / 100;

                        Volume = Symbol.NormalizeVolumeInUnits(Volume, RoundingMode.Down);

                        if (Volume > 100)

                            Volume = 100;

                        var SLprop = 0.0;

                        var SLBid = (Math.Round(Symbol.Bid * SLprop, 2));

                        var SLAsk = (Math.Round(Symbol.Ask * SLprop, 2));

                        var TPBidProp = TargetPipsLong;

                        var TPBid = (Math.Round(TPBidProp * Symbol.PipSize, 2));

                        var TPAskProp = TargetPipsShort;

                        var TPAsk = (Math.Round(TPAskProp * Symbol.PipSize, 2));

                        PlaceStopOrder(TradeType.Buy, SymbolName, Volume, Symbol.Bid + 3 * Symbol.PipSize, "OpenStopBuy", SLBid, TPBid, Server.Time.AddHours(23));

                        PlaceStopOrder(TradeType.Sell, SymbolName, Volume, Symbol.Ask - 3 * Symbol.PipSize, "OpenStopSell", SLAsk, TPAsk, Server.Time.AddHours(23));

                    }

                }

            }

        }

        protected override void OnTick()

        {

            // Put your core logic here

        }

        protected override void OnStop()

        {

            // Put your deinitialization logic here

        }

    }

}

Last, your bot will not work as you expect, please learn C# basics before writing a cBot/indicator.


@afhacker

afhacker
02 Mar 2021, 11:41

RE:

amirus.stark said:

Hi there, 

It's been hours since I'm trying to Display some Chart.DrawStaticText() over a Canvas Rectangle, I need to do it that way because characters have different colors, is there a way to perform this by changing Chart.DrawStaticText()'s Zindex ? if yes, how please ?

Thanks

Why you are not using text block? you are trying to mix chart objects with chart controls, Canvas is a chart control, and the Chart.DrawStaticText draws a chart object on the chart.

You have to use a chart control inside canvas not an object, try text block.

You can add multiple text blocks for each character so they will have different colors.


@afhacker

afhacker
12 Dec 2020, 12:44

There is no "cAlgo.API.Bot" class, you should inherit from "cAlgo.API.Robot" class, it works fine for me both for cBots and indicators.

The only problem is with "Parameter" attribute, if you define your parameters on base class for inherited classes the parameters will not show up on cTrader because they have set the "Parameter" attribute "Inherited" property to "False", not sure why they did that, I hope they fix this issue so we will be able to have our common parameters on single base class, for now the only solution is to make the parameter properties abstract so the child classes must override those parameter properties.


@afhacker

afhacker
23 Oct 2020, 19:29

cTrader will migrate to .NET core and in future you will be able to use ML.NET, but if you are a serious algo trader and want to use ML on your algos then there is no need to wait, you don't have to use even .NET at all for your ML stuff, use Keras or any other ML library like Sklearn with Spotware Open API.

You can also use ML.NET with Open API, I use Python when it comes to ML and for trading I use Open API.

If you don't want to use Open API or the authentication is hard for you to implement you can use Python ML libs for building your model and then you can send the ML model signal to a cBot with a socket connection.

I love .NET but for ML its not so mature right now. 

 


@afhacker

afhacker
10 Oct 2020, 00:16

RE:

hslagter said:

I was excited about cTrader and wanted to move from MQL5 EAs to cTrader cBots. Unfortunately, cTrader does not work on Linux (wine). Are there any prospects if it ever will to work on Linux?

It works with VirtualBox on Linux and Mac.


@afhacker

afhacker
28 Sep 2020, 21:54 ( Updated at: 21 Dec 2023, 09:22 )

RE: RE:

ctid2032775 said:

PanagiotisCharalampous said:

Hi Christian,

The procedure explains how to compile C# files. this is what I use as well and works fine.

Best Regards,

Panagiotis 

Join us on Telegram

Hi Panagiotis,

when I try this I get the following error:

Translation:

The system cannot find the mentioned file.

Can you please provide me with exactly the version you are using to compile .proto into .cs!

Thanks and best regards,
Christian

You can compile the Open API proto files with the latest version of Protobuf, you can use my library which is based on latest version of Protobuf: 

 


@afhacker

afhacker
19 Sep 2020, 11:37

RE: RE: RE:

rad256 said:

afhacker said:

rad256 said:

Hi All,

Does anyone know of a bot that can send an alert SMS to tell me when price has hit a set moveing average. If it is not already available, who can I contact to discuss the making of such a robot.

Any suggestion will be welcome.  I look forward to hearing from you.

 

Kind Regards

 

Ranford

SMS is slow, expensive, and not that easy to implement but yes its possible to use it on a cTrader indicator/cBot via 3rd party services, instead you should use Telegram, its much easier to implement, faster, and it doesn't cost you anything.

If you want to implement Telegram alert on your indicator/cBot you can do it with just one line of code by using my free open source alert popup library: 

Thanks for your reply.  I would like to try your code. How do I get it and the intructions on how to set it up? I already have Telegram on my phone so that is good news.

I look forward to hearing from you.

Regards... Ranford

 

All you need for implementing the popup library on your indicator/cBot is here: 

 


@afhacker

afhacker
18 Sep 2020, 12:20

RE:

rad256 said:

Hi All,

Does anyone know of a bot that can send an alert SMS to tell me when price has hit a set moveing average. If it is not already available, who can I contact to discuss the making of such a robot.

Any suggestion will be welcome.  I look forward to hearing from you.

 

Kind Regards

 

Ranford

SMS is slow, expensive, and not that easy to implement but yes its possible to use it on a cTrader indicator/cBot via 3rd party services, instead you should use Telegram, its much easier to implement, faster, and it doesn't cost you anything.

If you want to implement Telegram alert on your indicator/cBot you can do it with just one line of code by using my free open source alert popup library: 

 


@afhacker

afhacker
13 Sep 2020, 18:34

RE:

christintr95 said:

Trade multiple accounts in cTrader.
I want from a cTrader platform
trade multiple accounts with different brokers.
How does that work best?
Would it be possible to create an account with cTrader copy,
So main platform (strategy provider) and my other accounts in slave mode (investor) to trade?
Or is there a plugin or something like that?

Thanks 

cc

Check cMAM: 

 


@afhacker

afhacker
26 Jul 2020, 10:31

RE:

tgjobscv said:

FiX API - copy positions from demo to live ?

How ?

You can do it with Open API instead, for an example check out cMAM: 

 


@afhacker

afhacker
30 Jun 2020, 20:13

Try our custom period chart indicator: 

It creates higher Renko periods from lower ones with high/low.


@afhacker

afhacker
29 Jun 2020, 10:52

Learn C# and you will be able to start developing a cTrader cBot or indicator in a couple of hours, there are lots of resources available to learn C# online and the amount of C# resources aren't comparable with MQL at all.

Another advantage of learning C# instead of platform-specific languages like MQL is you can apply your C# knowledge on anything in future, you can use a different trading platform like NT or in case you are serious about algo trading you can develop your algos directly linked with a broker API instead of using any platform at all.

Why waste your time on something that might not be available in the next few years? if you learn C# you can develop trading algos for all kinds of markets and platforms and as a programmer for me its much easier to write C# code than writing MQL code.

Learning C# gives you lots of more opportunities in life, and it's a great skill to have.


@afhacker

afhacker
28 Jun 2020, 09:09

RE:

cTrader visual back tester allows you to replay the market, and if you want to manually backtest something you can do it via a cBot, try our manual back tester: 

There are other free alternatives available on the site.


@afhacker

afhacker
25 Jun 2020, 09:43

RE:

riccardo.buttari said:

 

I think it would be useful keys to navigate through the list of assets and change selected item without having to scroll and click the mouse each time.
Thank you very much

Try this: 

 


@afhacker

afhacker
14 May 2020, 14:32

RE:

PanagiotisCharalampous said:

Hi afhacker,

Third party integrations are completely dependent on the third parties therefore there is not much we can do on our side. It would be more effective if your pushed them instead of us :)

Best Regards,

Panagiotis 

Join us on Telegram

 

I just sent an email to QuantConnect and asked them to integrate cTrader.

Supporting platforms like QuantConnect or TradingView will attract more brokers to use cTrader, and bring lots of more users to cTrader.

With Connect API you can allow cTrader users to trade from any other platform, why not using its potential? your marketing regarding Connect API is very weak, I'm sure most of these companies aren't aware of cTrader connect API, even most of the cTrader users aren't aware of it, so if you contact these third party companies and ask them to integrate cTrader it will be much better.


@afhacker

afhacker
14 May 2020, 10:46

RE:

PanagiotisCharalampous said:

Hi ikozelkov,

You can find the explanation here.

Best Regards,

Panagiotis 

Join us on Telegram

 

What's the problem of cTrader with US regulations? as I can see it's not related to brokers, why at the bottom of the site we have this disclaimer:

"The services provided by Spotware Systems Ltd. are not available to citizens or residents of the USA. Neither is the information on our websites directed toward soliciting citizens or residents of the USA."

If it depends on brokers why you have added that disclaimer? why do you care? let the brokers deal with regulations or who they want to allow to use their service, you are not providing any financial service to anyone, Spotware is a tech company and there is no need for you to deal with CFTC or any other regulatory organization.

Spotware position regarding the US is very confusing, please remove these disclaimers or if there is something in cTrader that is not compatible with US laws then tell us.


@afhacker

afhacker
12 May 2020, 09:31

Please vote for it: 

 


@afhacker