Topics
18 Feb 2014, 14:29
 0
 2838
 3
23 Sep 2013, 11:39
 14504
 18
21 Jun 2013, 17:34
 6454
 2
Replies

virtuesoft
21 Aug 2014, 17:35

RE:

emeeder said:

virtuesoft, Did you get a cbot to work with the supertrend indicator?

 

No, I gave up on it and moved on to other things. Sorry.


@virtuesoft

virtuesoft
07 Feb 2014, 09:57

RE:

rhard said:

I still have the same problem.

It was fixed for a few hours and then the problem occurred again.


@virtuesoft

virtuesoft
06 Feb 2014, 20:00

The problem is back again. It looks like the data is corrupted. 


@virtuesoft

virtuesoft
06 Feb 2014, 14:05

RE:

Spotware said:

Problem with trendbars has been fixed. Please Refresh your charts. We apologize for any inconvenience.

I can confirm that it is sorted now. Thanks.


@virtuesoft

virtuesoft
06 Feb 2014, 10:53

RE:

Spotware said:

We figured out that data is corrupted on Daily time frame. This problem will be fixed as soon as possible. We apologize for any inconvenience.

Do you know when this issue will be resolved? I'm unable to run my robot until this is sorted.


@virtuesoft

virtuesoft
06 Feb 2014, 10:38

RE: RE: RE: RE:

No problem Kent. I do use a donchian channel in my trading but I don't use the middle line. I trade a breakout of the channel in a similar way to the original Turtle rules. I only trade the daily charts. 

Is it possible to automate your method? If so, let me know the rules and I'll give it a go. gary.virtuesoft@gmail.com


@virtuesoft

virtuesoft
05 Feb 2014, 14:11

RE: RE:

Hello Kent,

Try this...

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

namespace cAlgo.Indicators
{
    [Indicator("Custom Donchian", IsOverlay = true)]
    public class CustomDonchian : Indicator
    {

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

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

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

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

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

        public override void Calculate(int index)
        {
            Top[index] = MarketSeries.High.Maximum(PeriodsHigh);
            Bottom[index] = MarketSeries.Low.Minimum(PeriodsLow);

            double difference = MarketSeries.High.Maximum(PeriodsHigh) - MarketSeries.Low.Minimum(PeriodsLow);
            Middle[index] = MarketSeries.Low.Minimum(PeriodsLow) + (difference / 2);
        }
    }
}

 


@virtuesoft

virtuesoft
03 Feb 2014, 17:51

RE:

virtuesoft said:

Hello,

This seems to be happening again. I am seeing this problem in my Live and Demo accounts with IC Markets and FXPro. 

The strange thing is that the problem isn't occurring on my VPS, which is running my Live IC Markets account. This may be because I haven't restarted it in about a week.

Is there a problem with the data?

 

 

I had to restart CAlgo on my VPS and the problem is now occurring on there too. The data must have become corrupted within the past week.


@virtuesoft

virtuesoft
03 Feb 2014, 14:08

EURJPY and EURUSD. It may be on other symbols too.


@virtuesoft

virtuesoft
03 Feb 2014, 12:24

Hello,

This seems to be happening again. I am seeing this problem in my Live and Demo accounts with IC Markets and FXPro. 

The strange thing is that the problem isn't occurring on my VPS, which is running my Live IC Markets account. This may be because I haven't restarted it in about a week.

Is there a problem with the data?

 

 


@virtuesoft

virtuesoft
30 Jan 2014, 10:35

RE:

Spotware said:

See also: NormalizeVolume. You can use it to round up, down or to the nearest volume accepted for trade.

 

Thanks. I didn't know that function existed.


@virtuesoft

virtuesoft
30 Jan 2014, 10:14

RE:

cvphuoc, here is an example of how you can use the code...

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Requests;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot()]
    public class ExampleRobot : Robot
    {
        [Parameter("Stop Loss", DefaultValue = 6.0)]
        public double StopLoss { get; set; }

        [Parameter("Commission in Pips", DefaultValue = 0.8)]
        public double CommissionPips { get; set; }

        [Parameter("Risk Percent", DefaultValue = 0.5, MinValue = 0.1, MaxValue = 5.0)]
        public double RiskPercent { get; set; }

        [Parameter("Reserve Funds", DefaultValue = 0)]
        public int ReserveFunds { get; set; }

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

        private int _volume;

        protected override void OnStart()
        {
            // Put your initialization logic here
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnBar()
        {
            CalculateVolume();
        }

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

        private void CalculateVolume()
        {
            // 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 + ReserveFunds;

            // 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 + CommissionPips + Symbol.Spread;

            // 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.
            double exactVolume = Math.Round(riskPerTrade / (Symbol.PipValue * totalPips), 2);
            _volume = (((int)exactVolume) / 100000) * 100000;

            // Finally, check that the calculated volume is not greater than the MaxVolume parameter. If it is greater, reduce the volume to the MaxVolume value.
            if (_volume > MaxVolume)
                _volume = MaxVolume;
        }
    }
}

 


@virtuesoft

virtuesoft
29 Jan 2014, 11:31

RE: RE: RE:

virtuesoft said:

Hi,

I no longer use the code above. It is a lot easier to calculate the volume now that Symbol.PipSize has been added to the API.

Here is the code I am now using...

        private void CalculateVolume()
        {
            // 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 + ReserveFunds;

            // 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 + CommissionPips + Symbol.Spread;

            // 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.
            double exactVolume = Math.Round(riskPerTrade / (Symbol.PipValue * totalPips), 2);
            _volume = (((int)exactVolume) / 100000) * 100000;

            // Finally, check that the calculated volume is not greater than the MaxVolume parameter. If it is greater, reduce the volume to the MaxVolume value.
            if (_volume > MaxVolume)
                _volume = MaxVolume;
        }

 

Sorry, in this post I meant to say that it's a lot easier to calculate volume now that Symbol.PipValue has been introduced, not Symbol.PipSize.

Apologies for the confusion and layout of these posts. I'm at work at the moment and I'm quite busy.


@virtuesoft

virtuesoft
29 Jan 2014, 11:28

Please note that there are a number of different parameters that I use in the code above. I think they're pretty self explanatory but let me know if you have any queries.

        ("Stop Loss", DefaultValue = 6.0)]
        public double StopLoss { get; set; }

        [Parameter("Commission in Pips", DefaultValue = 0.8)]
        public double CommissionPips { get; set; }

        [Parameter("Risk Percent", DefaultValue = 0.5, MinValue = 0.1, MaxValue = 5.0)]
        public double RiskPercent { get; set; }

        [Parameter("Reserve Funds", DefaultValue = 0)]
        public int ReserveFunds { get; set; }

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

This code should work on all accounts (GBP, EUR, USD etc), however, I've only tested it on a GBP account.

Also, if you want to round the volume down to the nearest 10,000, instead of 100,000 just take a 0 off the two numbers on line 14 in post #4.


@virtuesoft

virtuesoft
29 Jan 2014, 11:22

RE: RE:

Hi,

I no longer use the code above. It is a lot easier to calculate the volume now that Symbol.PipSize has been added to the API.

Here is the code I am now using...

        private void CalculateVolume()
        {
            // 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 + ReserveFunds;

            // 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 + CommissionPips + Symbol.Spread;

            // 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.
            double exactVolume = Math.Round(riskPerTrade / (Symbol.PipValue * totalPips), 2);
            _volume = (((int)exactVolume) / 100000) * 100000;

            // Finally, check that the calculated volume is not greater than the MaxVolume parameter. If it is greater, reduce the volume to the MaxVolume value.
            if (_volume > MaxVolume)
                _volume = MaxVolume;
        }

 


@virtuesoft

virtuesoft
05 Dec 2013, 14:34

RE:

Cerunnos said:

Thanks for reply. The use of labels is already known to me. In this case I'm using no labels because only manual positions to be processed by my Robot. I want to filter manual positions by timeframe in one robot, because I have different exit strategies for each timeframe.
M30-position in XAU/USD -> m30-exit strategy in robot
H1-position in XAU/USD -> H1-exit strategy in robot

I see what you mean. I can't see a way of identifying the timeframe other than manually updating the label after the manual trade has been made.


@virtuesoft

virtuesoft
05 Dec 2013, 14:00

In your robot add a label to each position. With your manual orders do not add a label. That way you can differentiate between the two. In the robot you can keep a list of the positions and fill it using the code below...

        private IList<Position> GetOpenPositions()
        {
            IList<Position> positions = new List<Position>();

            foreach (Position pos in Account.Positions)
            {
                if (pos.Label == _label)
                {
                    positions.Add(pos);
                }
            }

            return positions;
        }

 


@virtuesoft

virtuesoft
01 Nov 2013, 14:08

Is this robot based on a martingale strategy?

The equity curve is perfectly straight with the odd large spike down. This is a classic martingale characteristic. 


@virtuesoft

virtuesoft
01 Nov 2013, 09:56

Very good. Particularly your first robot. A drawdown of just 6% for that kind of return is excellent. Both robots have a smooth equity curve. It would be good to see how they have performed over the full backtesting period.


@virtuesoft

virtuesoft
30 Oct 2013, 17:45

Thanks very much. 


@virtuesoft