Topics
05 Dec 2014, 00:00
 2644
 1
Replies

admin
20 Nov 2012, 11:27

The technical error is due to the take profit value in the CreateBuyStopOrder. It cannot be the same as the target price.

 


@admin

admin
19 Nov 2012, 16:01

Thank you. You may start a conversation with us at engage@ctrader.com in order to send us your algorithms to investigate if you like. This will expedite our tests so that we can better assist you.

The reason we asked you for the version is for our testing purposes. 

 


@admin

admin
19 Nov 2012, 15:07

Are you logged in to two different instances of cAlgo with the same account? Also, which version of cAlgo are you using is it Spotware cAlgo for instance?

 


@admin

admin
19 Nov 2012, 14:27

Hello,

 

We truly apologize for this inconvenience you are experiencing. If you could, please send us the code of your robots and we will investigate the issue promptly.

 


@admin

admin
19 Nov 2012, 13:29

Hello,

 

What you are referring to is not currently possible because it requires multi-timeframe support.  This will be added soon to the cAlgo platform.

 

 


@admin

admin
19 Nov 2012, 12:09

We will add the ability to access the timeframe from the cAlgo API soon.

For the time being you might be able to use a workaround method. Please see this sample code: /forum/calgo-reference-samples/163

 


@admin

admin
19 Nov 2012, 12:05

OBSOLETE
OBSOLETE
Use Timeframe Instead
See: Multi-timeframe robots/indicators

// -------------------------------------------------------------------------------
//
//    This is a Template used as a guideline to build your own Robot. 
//    Please use the “Feedback” tab to provide us with your suggestions about cAlgo’s API.
//
// -------------------------------------------------------------------------------

using System;
using cAlgo.API;


namespace cAlgo.Robots
{
    [Robot]
    public class SampleTimeFrame : Robot
    {
        private TimeSpan _timeFrame;

        protected override void OnStart()
        {
            // Get the timeframe in timespan format
            _timeFrame = GetTimeFrame();
            Print("{0}", _timeFrame);            
            // convert the timeframe to it's name representation
            string timeFrameName = GetTimeFrameName(_timeFrame);
            if (timeFrameName == "0")
                Print("Not enough data.");
            else
                Print("{0}", timeFrameName);    
        }

        /// <summary>
        /// Get the name representation of the timeframe used
        /// </summary>
        /// <param name="timeFrame">Time span between two consecutive bars OpenTime</param>
        /// <returns>The name representation of the TimeFrame</returns>
        private string GetTimeFrameName(TimeSpan timeFrame)
        {
            int totalMin = (int)timeFrame.TotalMinutes;
            string timeFrameName;

            if (totalMin > 10080)
                timeFrameName = "M1";
            else
            {
                switch (totalMin)
                {
                    case 1:
                        timeFrameName = "m1";
                        break;
                    case 2:
                        timeFrameName = "m2";
                        break;
                    case 3:
                        timeFrameName = "m3";
                        break;
                    case 4:
                        timeFrameName = "m4";
                        break;
                    case 5:
                        timeFrameName = "m5";
                        break;
                    case 10:
                        timeFrameName = "m10";
                        break;
                    case 15:
                        timeFrameName = "m15";
                        break;
                    case 30:
                        timeFrameName = "m30";
                        break;
                    case 60:
                        timeFrameName = "h1";
                        break;
                    case 240:
                        timeFrameName = "h4";
                        break;
                    case 720:
                        timeFrameName = "h12";
                        break;
                    case 1440:
                        timeFrameName = "D1";
                        break;
                    case 10080:
                        timeFrameName = "W1";
                        break;
                    default:
                        timeFrameName = "0";
                        break;

                }
            }

            return timeFrameName;
        }

        /// <summary>
        /// Get the time span between two consecutive bars OpenTime
        /// </summary>
        private TimeSpan GetTimeFrame()
        {
            if (MarketSeries.Close.Count > 0)
            {
                int currentIndex = MarketSeries.Close.Count - 1;
                DateTime currentOpenTime = MarketSeries.OpenTime[currentIndex];
                DateTime previousOpenTime = MarketSeries.OpenTime[currentIndex - 1];

                TimeSpan timeFrame = currentOpenTime - previousOpenTime;

                if (currentOpenTime.DayOfWeek == DayOfWeek.Monday && previousOpenTime.DayOfWeek != DayOfWeek.Monday)
                {
                    currentOpenTime = previousOpenTime;
                    previousOpenTime = MarketSeries.OpenTime[currentIndex - 2];
                    timeFrame = currentOpenTime - previousOpenTime;
                }

                return timeFrame;
            }
            // if bars are not available
            return TimeSpan.Zero;
        }
    }
}

 


@admin

admin
16 Nov 2012, 17:54

The content of the documentation is currently being updated. 

 


@admin

admin
16 Nov 2012, 16:28

Most probably it will be available very soon.

 


@admin

admin
16 Nov 2012, 09:59

Hello

 

Soon you will be able to access all the necessary information of the account.

 


@admin

admin
15 Nov 2012, 14:34

It is already on Spotware cAlgo where you can test it and it is due for release on all the other broker platforms very soon.

You can use  MarketDepth and MarkeData interfaces  to access Depth of Market for various symbols.

For instance:

        private MarketDepth GBPUSD;
        private MarketDepth _md;

        protected override void Initialize()
        {            
            _md = MarketData.GetMarketDepth("EURUSD");
            GBPUSD = MarketData.GetMarketDepth(Symbol);
            GBPUSD.Updated += OnGbpUsdUpdated;
        }

        void OnGbpUsdUpdated()
        {
            // Implement this function according to what you want to do 
            // when the Depth of Market gets updated
        }

 




@admin

admin
15 Nov 2012, 12:23

We tested a robot that references DirectionalMovementSystem Indicator, more specifically your code above and it does not crash.  Please explain a bit more what exactly are the circumstances under which your robot crashes and what is exactly the code that you receive a technical error for.

 

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

namespace cAlgo.Robots
{
    [Robot]
    public class DMIRobot :Robot
    {
        private DirectionalMovementSystem _dms;

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

        protected override void OnStart()
        {
            _dms = Indicators.DirectionalMovementSystem(14);
        }

        protected override void OnBar()
        {
            if(Trade.IsExecuting)
                return;

            int index = MarketSeries.Close.Count - 2;

            if (_dms.DIPlus[index] > _dms.DIMinus[index])
            {
                Trade.CreateBuyMarketOrder(Symbol, Volume);
            }

            else if (_dms.DIPlus[index] < _dms.DIMinus[index])
            {
                Trade.CreateSellMarketOrder(Symbol, Volume);
            }
        } 
    }
}


 


@admin

admin
14 Nov 2012, 16:25

You only need to build it once when you have completed coding. After that all you need to do to load it, is to add an instance. Then the indicator should be loaded in a very short time. You do not need to build it every time you want to load it to the chart.

 


@admin

admin
14 Nov 2012, 16:06

There will be an implementation for it very soon.

 

 


@admin

admin
14 Nov 2012, 14:20

You can add print statements to troubleshoot the code or you can send us the code so that we can investigate.

 


@admin

admin
14 Nov 2012, 12:07

Yes it is possible.

 


@admin

admin
14 Nov 2012, 11:51

Hello,

 

Do you need to create a reference to a custom indicator in a Robot?

If so, please see the  SampleRobotReferenceSMA which references the SampleSMA Indicator.

Both algorithms are included in the cAlgo platform.

 


@admin

admin
14 Nov 2012, 11:44

You may do it this way:

 

        private string GetClassName()

        {

            var name = GetType().ToString(); // returns cAlgo.Robot.ClassName

            return name.Substring(name.LastIndexOf('.') + 1);   //  returns ClassName

        }

 


@admin

admin
14 Nov 2012, 11:42

Your code is actually loading fast. Nowhere close to 28 seconds. Could you test it for instance on EURUSD and see if the loading time is still slow? It could be that the symbol you are using has more historical trendbars and it takes longer to calculate.

 

 


@admin

admin
13 Nov 2012, 19:12

We did find that on some symbols it does take a few more seconds to load but we are still testing to identify the issue. We will let you know.

 


@admin