Topics
30 Jun 2020, 13:27
 1089
 4
05 Sep 2017, 21:33
 1935
 2
09 Jul 2017, 14:37
 2433
 4
09 Jul 2017, 14:14
 2688
 3
04 Jan 2017, 19:20
 1514
 2
30 Dec 2016, 10:17
 2463
 2
12 Dec 2016, 09:15
 1880
 1
22 Oct 2016, 07:31
 2
 813
 2
17 Oct 2016, 00:14
 4786
 8
10 Oct 2016, 11:51
 3429
 5
Replies

davidp13
10 Oct 2016, 11:57

Sorry, maybe I need to write better: Lets try again...

When you execute a new position you can choose slippage, but when you modify a position you cannot. Why is this so?


@davidp13

davidp13
05 Aug 2016, 07:00

RE:

Admin pls respond. When I try to run Opt over the csv data it does not work. Gives an error. WHy?

davidp13 said:

I have also selected the CSV file, but have not ability to choose the dates same as the last note from back in 2014. Why is this so? Am I doing something wrong?

 


@davidp13

davidp13
05 Aug 2016, 06:49

An answer to this thread could help me as well. I have multiple positions with the same label so I need to identify the PID rather. Any help would be appreciated. Thanks


@davidp13

davidp13
27 Jul 2016, 09:25 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Hi. Was this error ever sorted out? I got the same error today.

 

Paul_Hayes said:

Hi Spotware,

Can you help me please.

I am trying to import an external csv historical data file into cAlgo for back-testing, the file is 1 Min of data as shown below in the example snapshot.

Data File Format

The correct format for the data to be used with cAlgo is specified below:

cAlgo Specified CSV file format
•    Date
•    Time
•    Open Price
•    High Price
•    Low Price
•    Close Price
•    Volume

Example:
2003.06.18,16:01,1.11423,1.11428,1.11332,1.11374,19
2003.06.18,16:02,1.11364,1.11436,1.11361,1.11405,7
2003.06.18,16:03,1.11402,1.11455,1.11400,1.11440,5
2003.06.18,16:04,1.11446,1.11461,1.11401,1.11447,14

The error I am getting from cAlgo when attempting to back-test is as follows:

Do you have any idea what is wrong with the data or if there is a problem with the platform import.

Thank you very much.

Paul.

 

 


@davidp13

davidp13
27 Jul 2016, 08:12

I have also selected the CSV file, but have not ability to choose the dates same as the last note from back in 2014. Why is this so? Am I doing something wrong?


@davidp13

davidp13
25 Jul 2016, 16:12

That is not what IC Markets told me...


@davidp13

davidp13
23 Jul 2016, 10:34

I got the answer thanks

/forum/cbot-support/2277


@davidp13

davidp13
19 Jan 2016, 19:19

Thank you very much!!


@davidp13

davidp13
19 Jan 2016, 16:43

Close the open position at a certain time

Hi,

What code should one add to close the open positions at lets say 3pm?

Thank you


@davidp13

davidp13
27 May 2015, 15:24

Anyone to help me pls?


@davidp13

davidp13
28 Apr 2015, 22:54

RE:

WhiteSage said:

Without seeing the code its hard to say, I would check your code to be doubly sure you are searching for the right trade labels and that the instantiating code for the trade has the right label (do you have many different trade scenarios?)
The fact it didn't refire in backtest is curious but not unforeseen.
Some of the differences are:
Backtests with OnTick are inaccurate unless you are using tick data.
Backtests only start with a fraction of the available bars a chart has, this may effect long MA's or any indicators that use Min and Max values or accumulate.
Backtest chart grow (how large I do not actually know!) with each tick. I assume forward tests do also.

Thanks for trying to respond. Yes I do have many scenarios, but the label use is correct and the amount of scenarios are countered by it. Im not for one minute saying my code is clean and efficient, but still this should not happen.

Where is the support people of this platform? Please respond! 


@davidp13

davidp13
28 Apr 2015, 16:48 ( Updated at: 21 Dec 2023, 09:20 )

Anyone able to answer this for me:

here are extracts of the code:

private const string label3 = "InTrendLong";

var longInTrendPosition = Positions.Find(label3, Symbol, TradeType.Buy);
 

if (previousSlowMa > previousFastMa && longMaDiffB < LongMaDiffBuy && currentSlowMa <= currentFastMa && valueClose > previousLongMaOpenInTrendBuy && longInTrendPosition == null)

            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, label3, StopLossInTrendBuy, TakeProfitInTrendBuy);

 

If you look at the attached image you can see there were two open positions with the same label - THIS SHOULD NOT HAPPEN due to longInTrendPosition == null

SO WHAT IS GOING ON PLS?


@davidp13

davidp13
30 Mar 2015, 20:48

many thanks!


@davidp13

davidp13
25 Mar 2015, 14:07

RE: RE:

Hi,

This robot was great thanks, but now i need to integrate it with another robot I have. The trades all open onBar, but i cant seem to get the countertrade code to work inside the robot. Code is below if anyone can help pls. Thanks

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 SP500 : Robot
    {
        [Parameter("MA Type")]
        public MovingAverageType MAType { get; set; }

        [Parameter()]
        public DataSeries SourceSeries { get; set; }

        [Parameter("Slow Periods", DefaultValue = 21)]
        public int SlowPeriods { get; set; }

        [Parameter("Fast Periods", DefaultValue = 15)]
        public int FastPeriods { get; set; }

        [Parameter(DefaultValue = 3, MinValue = 0)]
        public int Volume { get; set; }

        [Parameter("Take Profit", DefaultValue = 300)]
        public int TakeProfit { get; set; }

        [Parameter("Stop Loss", DefaultValue = 40)]
        public int StopLoss { get; set; }

        [Parameter("Counter TP", DefaultValue = 100, MinValue = 10)]
        public int TakeProfitCounter { get; set; }

        [Parameter("Counter SL", DefaultValue = 100, MinValue = 0)]
        public int StopLossCounter { get; set; }

        private MovingAverage slowMa;
        private MovingAverage fastMa;

        private const string label = "A2-1";
        private const string label2 = "counter";



        protected override void OnStart()
        {
            fastMa = Indicators.ExponentialMovingAverage(SourceSeries, FastPeriods);
            slowMa = Indicators.MovingAverage(SourceSeries, SlowPeriods, MAType);


        }

        protected override void OnBar()
        {
            var longPosition = Positions.Find(label, Symbol, TradeType.Buy);
            var shortPosition = Positions.Find(label, Symbol, TradeType.Sell);

            var currentSlowMa = slowMa.Result.Last(0);
            var currentFastMa = fastMa.Result.Last(0);
            var previousSlowMa = slowMa.Result.Last(1);
            var previousFastMa = fastMa.Result.Last(1);

            var lastIndex = SourceSeries.Count - 1;
            var valueClose = SourceSeries[lastIndex];

            Positions.Opened += OnPositionsOpened;


            if (previousSlowMa < previousFastMa && currentSlowMa >= currentFastMa && shortPosition == null)
            {
                ExecuteMarketOrder(TradeType.Sell, Symbol, Volume, label, StopLoss, TakeProfit);
            }
            if (previousSlowMa > previousFastMa && currentSlowMa <= currentFastMa && longPosition == null)
            {
                ExecuteMarketOrder(TradeType.Buy, Symbol, Volume, label, StopLoss, TakeProfit);
            }

//CLOSE POSITIONS******

            if (shortPosition != null && currentSlowMa <= currentFastMa && previousSlowMa > previousFastMa)
            {

                ClosePosition(shortPosition);
                //Stop();
            }
            else if (longPosition != null && currentSlowMa >= currentFastMa && previousSlowMa < previousFastMa)
            {

                ClosePosition(longPosition);
                //Stop();
            }

        }


        void OnPositionsOpened(PositionOpenedEventArgs args)
        {
            var originalPosition = args.Position;
            if (originalPosition.Label != label)
            {
                var tradeType = originalPosition.TradeType == TradeType.Buy ? TradeType.Sell : TradeType.Buy;
                ExecuteMarketOrder(tradeType, Symbol, originalPosition.Volume, label2, StopLossCounter, TakeProfitCounter);
            }
        }

    }
}

 

modarkat said:

davidp13 said:

Any help will be appreciated!

Im looking for a CBOT that will automatically open a counter trade as soon as an original trade is opened. How would one go about that?

Thanks

/algos/cbots/show/475

 


@davidp13

davidp13
11 Mar 2015, 09:16

RE:

Any help pls...

davidp13 said:

Hi. Hope someone can help me. I'm looking for a method to measure the pip difference between a MA and Market Price and allocate that to a variable. What would the code look like to do something like that?

Thanks

 


@davidp13

davidp13
21 Jan 2015, 09:18 ( Updated at: 21 Dec 2023, 09:20 )

RE: RE:

Hi, any comment or suggestion on the question below? Thanks

davidp13 said:

Spotware said:

Custom optimzation criterion has been added:

If Custom criterion is chosen you need to override GetFitness method in your cBot and provide a fitness values based on GetFitnessArgs. The higher fitness the value, the better.

Example 1:

protected override double GetFitness(GetFitnessArgs args)
{
        return args.WinningTrades / args.LosingTrades;//maximize count of winning trades and minimize count of losing trades
}

Example 2: 

protected override double GetFitness(GetFitnessArgs args)
{
        return Math.Pow(args.WinningTrades, 2) / args.LosingTrades;//count of winning trades is more important than count of losing trades
}

 

Hi. This is a very cool function and I would like to specify my own customer criteria. You do have the standard criteria to minimize Equity Drawdown, but I would like to specify the Max drawdown allowed. For example I want all outcomes for an equity drawdown of larger than 25% to be excluded in the results. Can you please help me with this?

Thank you in advance.

 


@davidp13

davidp13
19 Jan 2015, 10:03 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Spotware said:

Custom optimzation criterion has been added:

If Custom criterion is chosen you need to override GetFitness method in your cBot and provide a fitness values based on GetFitnessArgs. The higher fitness the value, the better.

Example 1:

protected override double GetFitness(GetFitnessArgs args)
{
        return args.WinningTrades / args.LosingTrades;//maximize count of winning trades and minimize count of losing trades
}

Example 2: 

protected override double GetFitness(GetFitnessArgs args)
{
        return Math.Pow(args.WinningTrades, 2) / args.LosingTrades;//count of winning trades is more important than count of losing trades
}

 

Hi. This is a very cool function and I would like to specify my own customer criteria. You do have the standard criteria to minimize Equity Drawdown, but I would like to specify the Max drawdown allowed. For example I want all outcomes for an equity drawdown of larger than 25% to be excluded in the results. Can you please help me with this?

Thank you in advance.


@davidp13

davidp13
19 Jun 2014, 20:47

TThanks a lot.
@davidp13

davidp13
16 Jun 2014, 10:20

Correct. This code is to close the open position. The problem I have is when I add || (or) then no entries open anymore when I back test.
@davidp13

davidp13
15 Jun 2014, 20:54

Hi, can anyone help please?


@davidp13