Topics
28 Feb 2019, 10:11
 19
 2034
 8
19 Jun 2018, 00:56
 1865
 6
25 Jan 2017, 17:54
 117
 2267
 8
05 Nov 2016, 23:28
 8062
 18
18 Jun 2016, 14:57
 4035
 7
Replies

Mikro
04 Nov 2021, 12:39

Has anyone succeeded in runing a life Simulink modell with data feed from a running cBot?


@Mikro

Mikro
04 Nov 2021, 09:20

RE:

amusleh said:

Hi,

C# is a different programming language, its a managed programming language with garbage collection that runs on top of .NET runtime.

You can call unmanaged C++ DLL functions on C#, check this tutorial please: How to call a c++ dll in C#.net code - CodeProject

Hi,

thanks for the hint, I'll look into it!


@Mikro

Mikro
15 Mar 2019, 18:00

RE:

Hi Panagiotis,

unfortunately not since cTrader does not support .Net 4.5 Framework. There literailly is no Library for InfluxDb Interaction that does not at least require .Net 4.5.

So my only alternative is to either write the InfluxDB interface myselft in .Net 4 which is more than a p....     or calling a Python script which interacts with the database.

To do that I need to reference a script... and cTrader I now learn does not support using embedded resources during build ... I start to feel abandoned !

 

Is there any way you can think of to feed and retreive data from an InfluxDatabase from within cAlgo???

 

Best regards

Mikro

Panagiotis Charalampous said:

Hi Mikro,

This is not supported at the moment. Is it not possible to replace the python script with C# code?

Best Regards,

Panagiotis

 


@Mikro

Mikro
28 Feb 2019, 12:07

.Net Framework update needed!

Dear support,

when will there be an update on a up to date .Net framework?

Literally no C# NuGet packages still support .Net 4.0 so coding algos is becoming a pain in the a.. needing to focus precious coding time to try and avoid the compatibility issues.

We need help here!

 

cheers


@Mikro

Mikro
05 Feb 2019, 14:43

Hey guys,

I have the same issue at the moment.

One indicator I opened from cAlgo via "Edit in Visual Studio" compiles just fine to the 'indicator.algo' in the

/Resources/Indicators/

directory.

 

Another indicator which I resored from an old git repository compiles, but does not build the .calgo file.

I find the indicator.dll under

/Resources/Indicators/myIndicator/bin/Release/

folder, but no

/Resources/Indicators/myIndicator.calgo

is created?

I tried to set build action for the .cs file to 'resource' but with no result.

 

What am I missing?

 

thanks!


@Mikro

Mikro
01 Jul 2018, 17:28

Hi Panagiotis,

according to the hoomepage Ta-Lib ist Open Source and links a Community Forum for help.

http://tadoc.org/forum/

This seems to be down, at least I wasn't able to open the Site.

 

But taking a closer look at several google Hits the issue seems to be that I have to transform the Price Arrays from double[] to float[] since TA-Lib seems to need this format.

Is there a smoother way the transform double[] to float[] than iterating through all members in a

for i to double[].count

loop?

Cheers

Mikro


@Mikro

Mikro
26 Jun 2018, 20:35

Seems no one, tried to get TALib running so far... 8[


@Mikro

Mikro
03 Dec 2017, 23:26

RE:

Hi Panagiotis,

From I read about nested indicators using the Moving Average Indicators in my code is pretty much using nested indicators, isn't it?

 protected override void Initialize()
        {
            jawsMa = Indicators.SimpleMovingAverage(MarketSeries.Close, JawsPeriods);
            teethMa = Indicators.SimpleMovingAverage(MarketSeries.Close, TeethPeriods);
            lipsMa = Indicators.ExponentialMovingAverage(MarketSeries.Close, LipsPeriods);
        }

This way the indicator parameters can be handled by the algo but I have no option to draw the used indicators to different chart types, do I?

THX

Mirko

Panagiotis Charalampous said:

Hi Mikro,

Have a look at nested indicators. I believe that they can help you solve your issue. Let me know if this helpful.

Best Regards,

Panagiotis

 


@Mikro

Mikro
25 Nov 2017, 14:24 ( Updated at: 21 Dec 2023, 09:20 )

Hi Panagiotis,

I am trying to build an integrated Indicator with an output for generated trade signals.

As a simple example if all lines of an Alligator are stacked by speed in long direction the output is "1", if stacked short "-1" and else "0".

So I open a nested Alligator in the new indicator an calculate the output.

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class indTradeDirection : Indicator
    {
        [Parameter(DefaultValue = 13)]
        public int JawsPeriods { get; set; }

        [Parameter(DefaultValue = 8)]
        public int JawsShift { get; set; }

        [Parameter(DefaultValue = 8)]
        public int TeethPeriods { get; set; }

        [Parameter(DefaultValue = 5)]
        public int TeethShift { get; set; }

        [Parameter(DefaultValue = 5)]
        public int LipsPeriods { get; set; }

        [Parameter(DefaultValue = 3)]
        public int LipsShift { get; set; }

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

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

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

        [Output("TradeDirection", Thickness = 3, PlotType = PlotType.Line, Color = Colors.WhiteSmoke)]
        public IndicatorDataSeries TradeDirection { get; set; }

        private SimpleMovingAverage jawsMa;
        private SimpleMovingAverage teethMa;
        private ExponentialMovingAverage lipsMa;

        protected override void Initialize()
        {
            jawsMa = Indicators.SimpleMovingAverage(MarketSeries.Close, JawsPeriods);
            teethMa = Indicators.SimpleMovingAverage(MarketSeries.Close, TeethPeriods);
            lipsMa = Indicators.ExponentialMovingAverage(MarketSeries.Close, LipsPeriods);
        }

        public override void Calculate(int index)
        {
            Jaws[index + JawsShift] = jawsMa.Result[index];
            Teeth[index + TeethShift] = teethMa.Result[index];
            Lips[index + LipsShift] = lipsMa.Result[index];
            calcTradeDirection(index);
        }

        private void calcTradeDirection(int index)
        {
            double lastLips = Lips[index];
            double lastTeeth = Teeth[index];
            double lastJaws = Jaws[index];

            if (lastLips > lastTeeth && lastTeeth > lastJaws)
            {
                TradeDirection[index] = 1;
                return;
            }
            if (lastLips < lastTeeth && lastTeeth < lastJaws)
            {
                TradeDirection[index] = -1;
                return;
            }
            TradeDirection[index] = 0;
        }

        public TradeType? GetTradeDirection()
        {
            if (TradeDirection.LastValue == 1)
            {
                return TradeType.Buy;
            }
            if (TradeDirection.LastValue == -1)
            {
                return TradeType.Sell;
            }
            return null;
        }
    }
}

If I use

IsOverlay = true

it looks like this

IsOverlay = false

looks like this

what I would like to have is

But if I open an aditional Indicators for the overlay and separate Chart the Parameters of the Indicators are not synchronised because the reside in different indicators.

Any Idea how to solve this?

THX


@Mikro

Mikro
25 Nov 2017, 13:14

Hi Panagiotis,

works, thank you!

I missed to experiment with the [index] and [index24h] filds...

thumbs up!


@Mikro

Mikro
23 Nov 2017, 21:44

Hi Support,

could you clarify if this is possible?

THX


@Mikro

Mikro
20 Nov 2017, 20:53

Thx!

Sometimes the smal issues are overlooked ;)


@Mikro

Mikro
01 Nov 2017, 22:01

Hi Panagiotis,

that clarifies the Orderhandling an rises another Question ;)

Are there any "Benefits" in Terms of the Precision or Speed executing a pending Order vs a Markt Order? Does the Market Maker "preallocate" the pending Order an matches it prior to the Price hitting the Stop Level?

Or in short, will I encouter a better Order Execution with pending Orders?

 

Thx Mikro

 


@Mikro

Mikro
01 Nov 2017, 13:13

Hi Panagiotis,

thanks for the Info.

Then, is there any limit for the Stop Order execution or could it potential be executed after a gap with like 100Pips of the Stop Price?

Thx

Mikro


@Mikro

Mikro
12 Jun 2017, 16:37

Since I am still experimenting sometimes an object link, for example an inidcator, still may be active in the strategyobject after it has finished its trading logic, and hence dosn't let it be garbage collected :(

Typing error...


@Mikro

Mikro
10 Jun 2017, 17:42

RE:

Hi Paul,

nice, thanks. Seems like I should take the time to look into Linq in a bit more Detail ;)


@Mikro

Mikro
09 Jun 2017, 18:39

RE:

an of course _myEquity need to be initialized as class member

 

yourRobot : Robot
{
double _myEquity;

OnStart()
OnTick()
OnStop()
}

 


@Mikro

Mikro
09 Jun 2017, 18:12

Try something like this:
protected override void OnStart()
{
    _myEquity = Account.Equity;
}
 
protected override void OnTick()
{
    if ((_myEquity / Account.Equity)<0.95)
    {
        Position _myWorstPosition=Positions[0];
        foreach (Position pos in Positions)
        {
            if (_myWorstPosition.NetProfit>pos.NetProfit)
            {
                _myWorstPosition = pos;
            }
        }
        ClosePosition(_myWorstPosition);
    }
}

cheers Mirko


@Mikro

Mikro
09 Jun 2017, 17:38

You can create these two Orders as pending Orders and subscribe to the ServerEvent if Orders are filled.

If one Order is filled you cancel the other an set your intended Stop-Levels. Like so:

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
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; }

        protected override void OnStart()
        {
            Positions.Opened += OnPositionOpened;
            PlaceStopOrder(TradeType.Buy, this.Symbol, 10000, Symbol.Ask + 15*Symbol.PipSize);
            PlaceStopOrder(TradeType.Sell, this.Symbol, 10000, Symbol.Bid - 15 * Symbol.PipSize);
        }

        protected override void OnTick()
        {
            
        }

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

        public void OnPositionOpened(PositionOpenedEventArgs args)
        {
            foreach (PendingOrder pOrder in PendingOrders)
            {
                CancelPendingOrderAsync(pOrder);
            }
            foreach (Position pos in Positions)
            {
                if (pos.TradeType==TradeType.Buy)
                {
                    ModifyPosition(pos, pos.EntryPrice - 15*Symbol.PipSize, pos.EntryPrice + 30*Symbol.PipSize);
                }
                else
                {
                    ModifyPosition(pos, pos.EntryPrice + 15*Symbol.PipSize, pos.EntryPrice - 30*Symbol.PipSize);
                }
            }
        }
    }
}

 


@Mikro