Replies

aharonzbaida
16 Aug 2017, 22:50

RE:

solark said:

I'm pretty sure that's not currently possible. To do what you want to do I'd recommend adding a 'Seed' parameter, initialize the Random object using this parameter, then in the calgo "Optimization" tab, "optimize" over this parameter using "Grid Search" (Not genetic). This will get you a table of results you can then plot elsewhere (excel or whatever). Some notes:

1. Im not sure if the seed method will work properly, it depends on the random number generator. A random number generator with a big space of random numbers (for example Mersenne Twister) performs quite welll using a random seed (chance of 2 iterations running using the same sequence of 'random' numbers is very low). Another solution is to pre-generate a large file of random numbers and syncronize access to the file (the optimizer might run your algo in parallel). I think at 10000 times sequentials seeds should be fine but it's worth mentioning.

2. I can't remember how easy it is to export the table of results out of the optimizer. If it's a pain then just add some code `OnStop` to write the results to a file. If you're looking for equity curves you'll pretty much have to do this but it's not so bad (maybe a couple lines of code).

 

Hope that helps.

Solark, thank you for your reply - this is a clever idea. I am not sure how to acess the equity curve data in the optimizer from within the cBot OnStop method. The optimizer only keeps the best 20 runs, and doesn't give option of just dumping the raw data to disk.


@aharonzbaida

aharonzbaida
01 Sep 2016, 09:13

In this regard, is it not possible to hedge (having positions open in opposite directions for same symbol) when using the FIX connectivity?


@aharonzbaida

aharonzbaida
24 Jan 2016, 11:42

RE: RE: RE: RE:
Dinger said:

Tcl DataBase Connectivity (TDBC)

good luck figuring out how to use that.

Also if you use wireshark you can see that calgo is downloading tick data from their website, but that tick data also happens to be in a weird format.

Example:

http://spotware-ticks.s3.amazonaws.com/cs/pepperstone-live/1/eurjpy/b/15/06/11.csv

If their data went far enough back it may actually be worth the time deciphering.

 

aharonzbaida said:

AlexanderRC said:

Spotware said:

Is tick data being downloaded from broker server to user's computer? if yes, where can i find them? if no, would like to know how reliable is tick data backtest in calgo. afaik, in mt4, tick data has to be downloaded locally so not sure if calgo does the same?

cAlgo automatically downloads tick data from Spotware's servers. Tick data is broker specific. Tick data is 100% reliable because it contains every tick. You can find tick data on your machine in the following directory:

C:\Users\%UserName%\AppData\Roaming\%BrokerName%-cAlgo\BacktestingCache\Ticks

For every date there is a separate file in folder named after the symbol. The files are in a proprietary format with scrambling (reversible encryption). The only value of looking at them is to check whether the specific date and symbol has been cached or not.

and it also seems like users need to be connected to the internet to run a backtest, why?

We plan to remove this restriction in the future. Thank you for your feedback.

Please add the ability to use user specified tick data from a CSV file at the same time.

Hi Alexander,

Spotware, and the community, does anyone have news about importing tick data into back tester? The files in the cache directory are not human readable format with .tdbc extension. Any suggestion on converting tick data to this format, or other method available to import historical tick data?

- Roni

 


I am NOT trying to re engineer the system. I am confident that Spotware will realize the need, and sort out the broker concerns to allow this functionality. I would like to see a more sophisticated back tester that allows not only importation of large sets of tick data, but also functions such as dataset splicing for walk forward testing, data cleaning and normalization preprocessing, and Monte Carlo simulation along the lines of what Dr. Howard Bandy describes. Please vote so if you agree.
@aharonzbaida

aharonzbaida
15 Jan 2016, 14:15

RE:
Spotware said:

Dear aharonzbaida,

It's still not possible to backtest using custom tick data. We cannot provide you with an ETA of this feature. Altering cTrader/cAlgo files is prohibited as it is a violation of the EULA.


OK Thanks for reply. please keep us posted on this issue. keep up the good work Roni
@aharonzbaida

aharonzbaida
14 Jan 2016, 23:16

RE: RE:

AlexanderRC said:

Spotware said:

Is tick data being downloaded from broker server to user's computer? if yes, where can i find them? if no, would like to know how reliable is tick data backtest in calgo. afaik, in mt4, tick data has to be downloaded locally so not sure if calgo does the same?

cAlgo automatically downloads tick data from Spotware's servers. Tick data is broker specific. Tick data is 100% reliable because it contains every tick. You can find tick data on your machine in the following directory:

C:\Users\%UserName%\AppData\Roaming\%BrokerName%-cAlgo\BacktestingCache\Ticks

For every date there is a separate file in folder named after the symbol. The files are in a proprietary format with scrambling (reversible encryption). The only value of looking at them is to check whether the specific date and symbol has been cached or not.

and it also seems like users need to be connected to the internet to run a backtest, why?

We plan to remove this restriction in the future. Thank you for your feedback.

Please add the ability to use user specified tick data from a CSV file at the same time.

Hi Alexander,

Spotware, and the community, does anyone have news about importing tick data into back tester? The files in the cache directory are not human readable format with .tdbc extension. Any suggestion on converting tick data to this format, or other method available to import historical tick data?

- Roni


@aharonzbaida

aharonzbaida
20 Dec 2015, 06:50

RE:

Spotware said:

Dear Trader,

In cAlgo.API there is no way to trigger an event in the way you want. However, you can take advantage of the C# language used in cAlgo and create an event to be triggered whenever you want. Please have a look at the Events Tutorial on Microsoft.

so either make an inter process communication using anonymous pipes between robots. and have a chart instance for every symbol which will serve to fire price changes from each respective OnStart().

See:

http://stackoverflow.com/questions/528652/what-is-the-simplest-method-of-inter-process-communication-between-2-c-sharp-pro

which suggests using Asynchronous operations with BeginRead/BeginWrite and AsyncCallback. As outlined here:

https://msdn.microsoft.com/en-us/library/bb546102.aspx

 

Or, alternatively use polling to check if Symbol.bid / Ask changed, then fire an event, a variation on outlined here:

 http://stackoverflow.com/questions/19794652/c-sharp-raise-event-when-property-changes-in-foreign-class

 

Both of which are hacks for something that should be built in. 

 

Dear Spotware team, is the second option what you had in mind in your previous answer where you reffered me/us to the MS Event tutorial?

 

Are you planning to integrate events for global price changes? If so, is there a timeline?

 

-Roni


@aharonzbaida

aharonzbaida
29 Nov 2015, 08:46

RE: RE: RE:

Cezary said:

ok, thanks

Spotware said:

Cezary said:

Hi,

 

When is called OnTick event ?

Is it called on every price change ?

 

Thanks!

Cezary

OnTick method is called on each incoming market tick.

 

How do I trigger an event for every incoming tick on each of a list of (or all) symbols, as opposed to OnTick() method being called only for ticks on the symbol the cBot is attached to?


@aharonzbaida

aharonzbaida
28 Nov 2015, 19:16

OnTick() in multi-symbol cBots

In a multi-symbol cBot, will the OnTick() method trigger for each incoming tick on every symbol used, or just on incoming ticks of the associated chart? Do I need to write code to check if Bid/Ask price changed on each symbol, and trigger an event for such occurrence?


@aharonzbaida

aharonzbaida
28 Nov 2015, 19:12

RE: OnTick() in multi-symbol cBots

Spotware said:

Dear Trader,

It's not possible. You could collect bid and ask prices in RunTime and then access them. 

In a multi-symbol cBot, will the OnTick() method trigger for each incoming tick on every symbol used, or just on incoming ticks of the associated chart? Do I need to write code to check if Bid/Ask price changed on each symbol, and trigger an event for such occurrence?


@aharonzbaida

aharonzbaida
28 Nov 2015, 19:11

RE: Multi-Symbol cBot OnTick() events

In a multi-symbol cBot, will the OnTick() method trigger for each incoming tick on every symbol used, or just on incoming ticks of the associated chart? Do I need to write code to check if Bid/Ask price changed on each symbol, and trigger an event for such occurrence?


@aharonzbaida

aharonzbaida
28 Nov 2015, 19:11

RE: Multi-Symbol cBot OnTick() events

In a multi-symbol cBot, will the OnTick() method trigger for each incoming tick on every symbol used, or just on incoming ticks of the associated chart? Do I need to write code to check if Bid/Ask price changed on each symbol, and trigger an event for such occurrence?


@aharonzbaida

aharonzbaida
16 Oct 2015, 09:48

RE: Indicator example: Multi-timeframe moving average

cAlgo_Development said:

In this example, we output moving averages with the same period for different timeframes on a single chart:

 

Source code:

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
    public class MultiTF_MA : Indicator
    {
        [Parameter(DefaultValue = 50)]
        public int Period { get; set; }

        [Output("MA", Color = Colors.Yellow)]
        public IndicatorDataSeries MA { get; set; }

        [Output("MA5", Color = Colors.Orange)]
        public IndicatorDataSeries MA5 { get; set; }

        [Output("MA10", Color = Colors.Red)]
        public IndicatorDataSeries MA10 { get; set; }

        private MarketSeries series5;
        private MarketSeries series10;

        private MovingAverage ma;
        private MovingAverage ma5;
        private MovingAverage ma10;

        protected override void Initialize()
        {
            series5 = MarketData.GetSeries(TimeFrame.Minute5);
            series10 = MarketData.GetSeries(TimeFrame.Minute10);

            ma = Indicators.MovingAverage(MarketSeries.Close, Period, MovingAverageType.Triangular);
            ma5 = Indicators.MovingAverage(series5.Close, Period, MovingAverageType.Triangular);
            ma10 = Indicators.MovingAverage(series10.Close, Period, MovingAverageType.Triangular);
        }

        public override void Calculate(int index)
        {
            MA[index] = ma.Result[index];

            var index5 = GetIndexByDate(series5, MarketSeries.OpenTime[index]);
            if (index5 != -1)
                MA5[index] = ma5.Result[index5];

            var index10 = GetIndexByDate(series10, MarketSeries.OpenTime[index]);
            if (index10 != -1)
                MA10[index] = ma10.Result[index10];
        }


        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            for (int i = series.Close.Count - 1; i > 0; i--)
            {
                if (time == series.OpenTime[i])
                    return i;
            }
            return -1;
        }
    }
}

 

A modification to the above example that solves missing values when attaching indicator to chart of lower time frame than the M5: the index function returns a match,or the closest previous value in higher time frame series.

//modified GetIndexByDate() from ctdn example

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
    public class MultiTF_MA : Indicator
    {
        [Parameter(DefaultValue = 50)]
        public int Period { get; set; }
        
        [Output("MA", Color = Colors.Yellow)]
        public IndicatorDataSeries MA { get; set; }

        [Output("MA5", Color = Colors.Orange)]
        public IndicatorDataSeries MA5 { get; set; }

        [Output("MA10", Color = Colors.Red)]
        public IndicatorDataSeries MA10 { get; set; }

        private MarketSeries series5;
        private MarketSeries series10;

        private MovingAverage ma;
        private MovingAverage ma5;
        private MovingAverage ma10;

        protected override void Initialize()
        {
            series5 = MarketData.GetSeries(TimeFrame.Minute5);
            series10 = MarketData.GetSeries(TimeFrame.Minute10);

            ma = Indicators.MovingAverage(MarketSeries.Close, Period, MovingAverageType.Triangular);
            ma5 = Indicators.MovingAverage(series5.Close, Period, MovingAverageType.Triangular);
            ma10 = Indicators.MovingAverage(series10.Close, Period, MovingAverageType.Triangular);
        }

        public override void Calculate(int index)
        {
            MA[index] = ma.Result[index];

            //var index5 = GetIndexByDate(series5, MarketSeries.OpenTime[index]);
            var index5 = GetIndexByTime(series5, MarketSeries.OpenTime[index]); 
            if (index5 != -1)
                MA5[index] = ma5.Result[index5];

            //var index10 = GetIndexByDate(series10, MarketSeries.OpenTime[index]);
            var index10 = GetIndexByTime(series10, MarketSeries.OpenTime[index]);
            if (index10 != -1)
                MA10[index] = ma10.Result[index10];
        }


        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            for (int i = series.Close.Count - 1; i > 0; i--)
            {
                if (time == series.OpenTime[i])
                    return i;
            }
            return -1;
        }

        private int GetIndexByTime(MarketSeries searchSeries, DateTime desiredTime)
        {
            Print("desired time=" + desiredTime.ToString());
            //loop over time series backwards till closest match found
            for (int i = searchSeries.Close.Count - 1; i > 0; i--)
            {
                if (desiredTime == searchSeries.OpenTime[i])
                {
                    return i;
                }
                else if (searchSeries.OpenTime[i] < desiredTime) return i; //return last value prev. to desired
                
            }
            return -1;
        }
    }
}


@aharonzbaida

aharonzbaida
08 Sep 2015, 18:39

Thanks


@aharonzbaida

aharonzbaida
06 Sep 2015, 02:16

RE:

cAlgo_Development said:

We added new functionality to cAlgo - the ability for robots and indicators to work with multiple symbols. Now it's possible to use multiple symbol prices, OHLCV series and trade different symbols.

 

Requesting symbol

Robots and indicators can request a symbol specifying its symbol code. Symbol objects behave like the default Symbol object of a robot or indicator, containing current Ask, Bid, PipSize and other useful properties.

Symbol symbol = MarketData.GetSymbol("USDJPY");

Print("Symbol: {0}, Ask: {1}, Bid: {2}", symbol.Code, symbol.Ask, symbol.Bid);

 

Requesting OHLCV series

Robots and indicators can request OHLCV series for multiple symbols and timeframes and build indicators based on it.

MarketSeries series = MarketData.GetSeries("EURCAD", TimeFrame.Minute15);
MovingAverage ma = Indicators.SimpleMovingAverage(series.Close, 20);

Print("Symbol: {0}, TimeFrame: {1}", series.SymbolCode, series.TimeFrame);
Print("Last Close: {0}, Average Close: {1}", series.Close.LastValue, ma.Result.LastValue);

 

Trading multiple symbols

Robots in cAlgo can execute orders for different symbols. To do this, the robot must request the needed symbol by its code. Then, it will be possible to use it in a trade request:

 Symbol symbol = MarketData.GetSymbol("GBPCHF");
 ExecuteMarketOrder(TradeType.Buy, symbol, 10000);

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

Backtesting of Multi-symbol robots in not supported at least for now. It can be implemented in future.

Is it possible to access bid/ask as time series? i.e. bid[index]. I don't see t1 as option timeframe  MarketData.GetSeries("EURUSD", TimeFrame.t1), or is that something I would have to build myself?

Thanks


@aharonzbaida

aharonzbaida
06 Sep 2015, 02:16

RE:

cAlgo_Development said:

We added new functionality to cAlgo - the ability for robots and indicators to work with multiple symbols. Now it's possible to use multiple symbol prices, OHLCV series and trade different symbols.

 

Requesting symbol

Robots and indicators can request a symbol specifying its symbol code. Symbol objects behave like the default Symbol object of a robot or indicator, containing current Ask, Bid, PipSize and other useful properties.

Symbol symbol = MarketData.GetSymbol("USDJPY");

Print("Symbol: {0}, Ask: {1}, Bid: {2}", symbol.Code, symbol.Ask, symbol.Bid);

 

Requesting OHLCV series

Robots and indicators can request OHLCV series for multiple symbols and timeframes and build indicators based on it.

MarketSeries series = MarketData.GetSeries("EURCAD", TimeFrame.Minute15);
MovingAverage ma = Indicators.SimpleMovingAverage(series.Close, 20);

Print("Symbol: {0}, TimeFrame: {1}", series.SymbolCode, series.TimeFrame);
Print("Last Close: {0}, Average Close: {1}", series.Close.LastValue, ma.Result.LastValue);

 

Trading multiple symbols

Robots in cAlgo can execute orders for different symbols. To do this, the robot must request the needed symbol by its code. Then, it will be possible to use it in a trade request:

 Symbol symbol = MarketData.GetSymbol("GBPCHF");
 ExecuteMarketOrder(TradeType.Buy, symbol, 10000);

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

Backtesting of Multi-symbol robots in not supported at least for now. It can be implemented in future.

Is it possible to access bid/ask as time series? i.e. bid[index]. I don't see t1 as option timeframe  MarketData.GetSeries("EURUSD", TimeFrame.t1), or is that something I would have to build myself?

Thanks


@aharonzbaida

aharonzbaida
30 Aug 2015, 22:19

RE:

moneybiz said:

The hack doesn't work on Visual Studio 2015 Enterprise.

Try changing the work "Community" to "Enterprise" where appropriate 


@aharonzbaida

aharonzbaida
30 Aug 2015, 17:12

RE:
Paul_Hayes said:

this should be a sticky in the forum, its very important. nice job.


Thanks Paul
@aharonzbaida

aharonzbaida
30 Aug 2015, 14:39

RE:

badmonkeyface said:

Hi,

I've removed VS2012 and replaced with VS2013. When I click 'edit in visual studio' nothing happens. How do I re-run the integration?

Thanks.

 

I had similar issue with Visual Studio Community 2015. It refused to install the VSIX, and did not show it in the VS under Tools>Extensions and Updates>Online . 

I found the "cBots and Custom Indicators" VSIX package on the visual studio gallery website, and downloaded it. 

I then used 7zip to open the archive, and used it to edit the extension.vsixmanifest file as outlined here.

I added the following entries to the extension.vsixmanifest file under the </SupportedProducts> tag and got it to work (only one of the entries is sufficient, but I didn't check which):

<VisualStudio Version="11.0">
        <Edition>Community</Edition>
      </VisualStudio>
      <VisualStudio Version="12.0">
        <Edition>Community</Edition>
      </VisualStudio>
      <VisualStudio Version="13.0">
        <Edition>Community</Edition>
      </VisualStudio>
      <VisualStudio Version="14.0">
        <Edition>Community</Edition>
      </VisualStudio>
      <VisualStudio Version="15.0">
        <Edition>Community</Edition>
      </VisualStudio>


    I also suggested Spotware add it to the VSIX.

All the best


@aharonzbaida

aharonzbaida
29 Aug 2015, 19:39

Is anything new regarding this request? Robots should return to on/off state that was prior to cAlgo restart event.


@aharonzbaida

aharonzbaida
20 Aug 2015, 23:53

Changed a long type parameter to int, and that solved the error.


@aharonzbaida