PanagiotisCharalampous's avatar
PanagiotisCharalampous
26 follower(s) 0 following 1006 subscription(s)
Replies

PanagiotisCharalampous
27 Mar 2018, 12:09

Hi ceakuk,

See below the first example as a robot

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 NewcBot : Robot
    {
        [Parameter(DefaultValue = 30, MinValue = 1)]
        public int Period { get; set; }

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

        protected override void OnTick()
        {
            RedrawLines();
        }
        private void RedrawLines()
        {
            int count = MarketSeries.Close.Count;

            int maxIndex1 = FindNextLocalExtremum(MarketSeries.High, count - 1, true);
            int maxIndex2 = FindNextLocalExtremum(MarketSeries.High, maxIndex1 - Period, true);

            int minIndex1 = FindNextLocalExtremum(MarketSeries.Low, count - 1, false);
            int minIndex2 = FindNextLocalExtremum(MarketSeries.Low, minIndex1 - Period, false);

            int startIndex = Math.Min(maxIndex2, minIndex2) - 100;
            int endIndex = count + 100;

            DrawTrendLine("high", startIndex, endIndex, maxIndex1, MarketSeries.High[maxIndex1], maxIndex2, MarketSeries.High[maxIndex2]);

            DrawTrendLine("low", startIndex, endIndex, minIndex1, MarketSeries.Low[minIndex1], minIndex2, MarketSeries.Low[minIndex2]);
        }

        private void DrawTrendLine(string lineName, int startIndex, int endIndex, int index1, double value1, int index2, double value2)
        {
            double gradient = (value2 - value1) / (index2 - index1);

            double startValue = value1 + (startIndex - index1) * gradient;
            double endValue = value1 + (endIndex - index1) * gradient;

            ChartObjects.DrawLine(lineName, startIndex, startValue, endIndex, endValue, Colors.Gray);
            ChartObjects.DrawLine(lineName + "_red", index1, value1, index2, value2, Colors.Red);
        }

        private int FindNextLocalExtremum(DataSeries series, int maxIndex, bool findMax)
        {
            for (int index = maxIndex; index >= 0; index--)
            {
                if (IsLocalExtremum(series, index, findMax))
                {
                    return index;
                }
            }
            return 0;
        }

        private bool IsLocalExtremum(DataSeries series, int index, bool findMax)
        {
            int end = Math.Min(index + Period, series.Count - 1);
            int start = Math.Max(index - Period, 0);

            double value = series[index];

            for (int i = start; i < end; i++)
            {
                if (findMax && value < series[i])
                    return false;

                if (!findMax && value > series[i])
                    return false;
            }
            return true;
        }

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

Let me know if this helps.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
27 Mar 2018, 10:40

Hi MaRCHeW,

When you get 0% for v2.01, is the application minimized or maximized? If it is minimized could you please maximize and make the comparison again?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
27 Mar 2018, 09:27

Hi rmsuleman,

I tried to build the indicator and I have no problems. However the error message references Robots folder which is used for cBots. Am I missing something?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
27 Mar 2018, 09:21

Hi Anton,

Did you manage to use the example?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
27 Mar 2018, 09:19

Hi Sylvain,

If this is a similar issue to this one, then please note that we have managed to reproduce it and will be solved with the next update.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 17:45

Hi thriscio,

We managed to reproduce the issue internally and we will fix it with the next update. Thanks for pointing this out to us.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 16:03

Hi FMogyi,

You don't need any special cAlgo libraries. cAlgo can reference any .Net library since it is a .Net application. Here you can find how to create a .Net library.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 14:20 ( Updated at: 21 Dec 2023, 09:20 )

Hi thanhnt12401,

You can find a description of trigger methods when you hover over the trigger button in the Create Order window in cTrader. See below



We will add the descriptions in the Help site as well.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 14:08

Hi Adam,

Your broker was correct. Percentages and ratios are related to the volume traded by the strategy provider. Proportional mirroring with be a feature that will be introduced in the upcoming release of cTrader Copy which is planned to be released sometime in Q2 2018.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 14:03

Hi lec0456,,

cBot with code would be preferable. If you cannot post it here, please send it to community@spotware.com.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 12:40

Hi thanhnt12401,

Thanks for posting in our forum. You can find a good explanation for QuickTrade modes in cTrader help. Here is the link. Let me know if this is helpful for you.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 12:34

Hi all,

Thanks for reporting this, Could you please provide us with the below information?

  • What is the revision of Spotware cTrader 3.0 you are using? (press Ctrl+Shift+~R)
  • Do you use any cBots or indicators in the moment of high CPU consumption?
  • What charts are using? Are you using any Chart objects like Deal Maps?

If you could share a couple of screenshots of Spotware cTrader, it would be useful as well.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 12:29

Hi lec0456,

Thanks for reporting this. Could we have a cBot and backtesting parameters that will allow us to reproduce this issue? 

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 12:21

Hi Alexander,

See below

var PipDigits = Math.Log10(1 / Symbol.PipSize);

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 12:13 ( Updated at: 21 Dec 2023, 09:20 )

Hi Adam,

Thanks for posting in our forum. There is no 1x because there is 100% which is equivalent. See below

Let me know if this helps you.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 12:06

Hi Sylvain,

Thanks for reporting your issue. Could we have a cBot and backtesting parameters that will allow us to reproduce is and understand if this is a bug or not? Regarding your suggestion, I will pass it to the product team.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
26 Mar 2018, 11:58

Hi thriscio,

Thanks for reporting this. Could we have a cBot and backtesting parameters that will allow us to reproduce this issue? 

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
23 Mar 2018, 12:55

Hi tradermatrix

The exception is thrown in the following function

        private TradeType GetTradeCommand()
        {
 
            if (_movingAverage.Result.IsRising())
                return TradeType.Buy;
            if (_movingAverage.Result.IsFalling())
                return TradeType.Sell;
            return _position.TradeType;
        }

_position is not set anywhere, therefore always null

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
23 Mar 2018, 09:10

Hi yjoura,

The current plan is to release visual backtesting in cTrader Desktop v3.01. Stay tuned!

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
22 Mar 2018, 18:01

Hi tradermatrix,

Could I have your backtesting parameters and settings as well?.

Best Regards,

Panagiotis


@PanagiotisCharalampous