Replies

oliveira.phc
03 Jan 2019, 15:02

RE:

Panagiotis Charalampous said:

Hi oliveira.phc,

You can solve your problem by checking both combinations. If the one returns null then you can reverse the strings and check again.

Best Regards,

Panagiotis

Alright, then.


@oliveira.phc

oliveira.phc
03 Jan 2019, 14:45

RE:

Panagiotis Charalampous said:

Hi oliveira.phc,

Thank you for your suggestion. Can you describe to us a use case for this? Symbol names are standard amongst almost all brokers. Also the order of the symbols is significant since it determines the price e.g. EURUSD is EUR/USD = 1.13. if it was USD/EUR it would be 0.88.

Best Regards,

Panagiotis

Thanks for your readiness.

You see, for determining the volume of an order, I would like to use some percentage of my free margin. My current code works well for FOREX because my account is in euros, and the Euro takes precedence over all other currencies.

private double _volume
        {
            get
            {
                double volumeInUnits = (Quantity * Account.FreeMargin * Account.PreciseLeverage) / 100;
                string thisCurrency = Account.Currency;
                string baseCurrency = Symbol.Code.Substring(0, 3);

                if (thisCurrency != baseCurrency)
                {
                    string code = string.Concat(thisCurrency, baseCurrency);
                    Symbol symbol = MarketData.GetSymbol(code);
                    volumeInUnits = volumeInUnits * symbol.Ask;
                }

                return Symbol.NormalizeVolumeInUnits(volumeInUnits);
            }
        }

Should I use another account in dollars, it wouldn't work.


@oliveira.phc

oliveira.phc
28 Dec 2018, 21:52

RE:

Panagiotis Charalampous said:

Hi oliveira.phc,

Can you share the cBot code so that we can check?

Best Regards,

Panagiotis

I got "Close.Count" from a MarketSeries based on Re5, but it took exactly one hour to be printed. Again, the default one was time based and about ~1000, and the aditional one based on Re5 was ~8000.


@oliveira.phc

oliveira.phc
28 Dec 2018, 12:55

RE:

Panagiotis Charalampous said:

Hi oliveira.phc,

Can you share the cBot code so that we can check?

Best Regards,

Panagiotis

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 MarketAnalysis : Robot
    {
        [Parameter("Another TF")]
        public TimeFrame AnotherTF { get; set; }

        private MarketSeries _mSeries;

        protected override void OnStart()
        {
            Print("Default TF: {0}", MarketSeries.Close.Count); // Always gets printed; ~1000 entries

            _mSeries = MarketData.GetSeries(AnotherTF);

            Print("Another TF: {0}", _mSeries.Close.Count); // It works for Time and Tick based, ~8000 entries. It does not work for Re5, Re10 and Re15 unless they are also used as the default one.
        }
    }
}

 


@oliveira.phc

oliveira.phc
28 Dec 2018, 11:59

RE:

Thank you for the tip. I am new to typed programming languages and thought that a type, in order to be possibly null, would require a question mark.


@oliveira.phc

oliveira.phc
21 Dec 2018, 15:40

RE:

Panagiotis Charalampous said:

Hi oliveira.phc,

I am not sure what are you referring too. Position and PendingOrder are reference types thus by default nullable. Actually Nullable types in C# are used to extend value types, not reference types.

Best Regards,

Panagiotis

Thanks for your readiness, Panagiotis.

I am sorry for not being able to especify correctly what I want to say. You see, when using an instance of TradeResult, one is led to believe that the properties Position and PendingOrder should always be instances of their respective cognate classes. The property Error, for example, has a type of "ErrorCode?", meaning that it could be null. I think the same should apply to Position and PendingOrder, for I have been experiencing some crashes when trying to deal with them.


@oliveira.phc

oliveira.phc
17 Dec 2018, 12:58

RE:
Thanks again.
@oliveira.phc

oliveira.phc
17 Dec 2018, 12:28

RE: RE:
Sorry, I meant NOT doable for now.
@oliveira.phc

oliveira.phc
17 Dec 2018, 12:26

RE:
Panagiotis Charalampous said:

Hi oliveira.phc,

A workaround is to get the timeframe as a parameter. See below

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 NewcBot : Robot
    {
        [Parameter]
        public TimeFrame Timeframe { get; set; }

        protected override void OnStart()
        {
            var t = MarketData.GetSeries(Timeframe);
        }

        protected override void OnTick()
        {

        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


Thank you for your readiness, Panagiotis. But, regarding the TimeFrame class, wouldn't it be necessary to update the API in order add properties of type Tick to it? The current API only have properties of type Time. https://ctrader.com/api/reference/timeframe I don't know if it is technically possible for cTrader to have multiple timeframe bots of type Tick, but it seems that it is doable for now. Kind regards, Paulo Oliveira
@oliveira.phc

oliveira.phc
12 Dec 2018, 20:09

RE:

cAlgo_Development said:

We added new functionality to cAlgo - the ability for robots and indicators to retrieve OHLCV data for multiple timeframes. This can be done using the MarketData.GetSeries method:

MarketSeries m5series = MarketData.GetSeries(TimeFrame.Minute5);

We recommend to call the GetSeries method in the Robot.OnStart() or the Indicator.Initialize() methods.

When the series for a specified timeframe is received, you can access the series values or build an indicator based on that series:

private MarketSeries m10;
private MovingAverage ma;

protected override void OnStart()
{
    m10 = MarketData.GetSeries(TimeFrame.Minute10);
    ma = Indicators.SimpleMovingAverage(m10.High, 14);
}

The new version of our Demo cTrader and cAlgo is released and can be downloaded from www.spotware.com

Update: Backtesting of Multi-timeframe robots is supported now.

Hello again.

Is it technically impossible to have multiple timeframes of type "tick"? If not, I will make a suggestion for it.

Kind regards,

Paulo Oliveira


@oliveira.phc

oliveira.phc
06 Dec 2018, 16:49

RE: Adding an instance without a symbol

oliveira.phc said:

Hello there.

I want to have a robot with a single instance for listenning to some events, like `Positions.Closed` and `PendingOrders.Filled`, for example. This robot's responsibility is to create a new record on a database for each kind of event.

Is it possible to have a "symbol-less" instance?

For that matter, also a "timeframe-less" instance?


@oliveira.phc

oliveira.phc
06 Dec 2018, 16:46

Adding an instance without a symbol

Hello there.

I want to have a robot with a single instance for listenning to some events, like `Positions.Closed` and `PendingOrders.Filled`, for example. This robot's responsibility is to create a new record on a database for each kind of event.

Is it possible to have a "symbol-less" instance?


@oliveira.phc

oliveira.phc
17 Nov 2018, 21:59

RE:

oliveira.phc said:

Hello there. While I appreciate having dedicated VPS services for cTrade, it would be nice to have an official AMI for EC2 on AWS. Kind regards

Having AWS SDK for C# already installed would also be nice.


@oliveira.phc