Topics
11 Jul 2017, 07:28
 0
 2582
 2
03 Oct 2016, 09:00
 4250
 5
21 Sep 2016, 12:51
 2207
 2
15 Sep 2016, 16:29
 4890
 12
02 Aug 2016, 17:45
 4998
 11
24 Jun 2016, 07:25
 3001
 2
14 May 2016, 14:28
 4003
 4
01 Apr 2016, 07:50
 5
 1030
 1
01 Apr 2016, 07:49
 129
 1652
 3
31 Dec 2015, 06:57
 3462
 3
15 Sep 2015, 17:35
 2650
 3
Replies

cloesd
09 Sep 2015, 12:31

RE:

Paul_Hayes said:

Hello,

I think you are confused about Object Oriented Programming with Inheritance and just creating a sub class, which is a big subject to study:-

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

https://en.wikipedia.org/wiki/Inheritance_(object-oriented_programming)

What you are attempting to do is just create a sub class to be used from a parent class, if you wish to use any cAlgo objects in the new class then you will need to pass them in, here is a basic example of what you are attempting to do.

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        // declare private field for new class
        private Barrista barrista;

        protected override void OnStart()
        {
            // create an instance of the class
            barrista = new Barrista();
        }

        protected override void OnTick()
        {
            // call method of class and pass it the MarketSeries data object, returns a double
            double result = barrista.baristaInst(MarketSeries);
            Print(result.ToString());
        }
    }

    public class Barrista
    {
        // constructor
        public Barrista()
        {

        }

        // public method of class which receives the marketseries data object
        public double baristaInst(MarketSeries marketSeries)
        {
            double testvar = marketSeries.Close.Last(2);
            return testvar;
        }
    }
}

Ahh.. I see,
Thanks.

I understand the basics of OOP just been a while.

 


@cloesd

cloesd
06 Sep 2015, 09:43

RE: RE:

Now it's working fine. (On some backtests).

 

Thanks heaps.


@cloesd

cloesd
06 Sep 2015, 03:45

RE:

Paul_Hayes said:

try this and let me know if it works, I have had some issues with indicator objects loading lazily, they have a reference, but no values.

double x =multi.EMA1.Result.Lastvalue;

Print(x);

Error CS1061: 'cAlgo.API.IndicatorDataSeries' does not contain a definition for 'Result' and no extension method 'Result' accepting a first argument of type 'cAlgo.API.IndicatorDataSeries' could be found (are you missing a using directive or an assembly reference?)

This is what I get.

I've set everthing to public in the indicator aswell, still same issue:


        public ExponentialMovingAverage Ema1;
        public ExponentialMovingAverage Ema2;
        public ExponentialMovingAverage Ema3;

 


@cloesd

cloesd
01 Mar 2015, 08:37

Ah solved.

Close thread.


@cloesd

cloesd
01 Mar 2015, 05:50

RE:

Sorry Custom indicator, Not customer.

 

 

After playing around with it a bit, I've got it to signal but it signals irrationally.

Does anyone have a working copy of the Golden Dragon algo? It seems the recent patches have screwed it up, and it's never taking trades etc.


 


@cloesd

cloesd
01 Mar 2015, 01:55

I'm trying to re-build/repair that golden dragon bot,

 

I need it to buy when price/(hull moving average) crosses another customer indicator ( BelkhayatePRC).

How can I do this?

 

I've tried: 

 

"  if (hull.hma.HasCrossedAbove(cog.sql3, 1)) "

 

but it never signals.

 

anyone want to lend a hand?


@cloesd