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

PanagiotisCharalampous
31 Aug 2018, 16:44

Hi jjcolacicco,

Thanks for posting in our forum. It is not clear what you are asking for. Do you want to programmatically change the candlestick colors?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 16:28

Hi Noppanon,

If your SL and TP have decimal places please make sure to round them to the Symbol's digits. See below

TakeProfit = Math.Round(TakeProfit, Symbol.Digits);

It is a known issue that non rounded values might be the cause of such messages and we will fix it in a future release.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 15:18

Hi alexey_r,

Thanks for posting in our forum. Mirrored positions are visible in cTrader since they are positions belonging to your account. However I am not sure what you mean with balance changes and transaction history. Do you mean the strategy provider's balance and transactions?

Best Regards,

Panagiotis

 


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 14:43

Hi,

Here is the indicator equivalent

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {

        RelativeStrengthIndex _rsi;
        protected override void Initialize()
        {
            _rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14);
        }

        public override void Calculate(int index)
        {
            Chart.DrawText("RSI", _rsi.Result.LastValue.ToString(), Server.Time, Symbol.Ask, Color.Red);
        }
    }
}

 


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 11:41

Hi oneb700d@gmail.com,

The code was written with the new version of the API, 3.01. Have you tried it on Spotware cTrader Public Beta?

Best Regards,

Panagiots


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 10:59

Hi oneb700d@gmail.com,

Is this what you are looking for?

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
    {

        RelativeStrengthIndex _rsi;
        protected override void OnStart()
        {
            _rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, 14);
        }
        protected override void OnTick()
        {
            Chart.DrawText("RSI", _rsi.Result.LastValue.ToString(), Server.Time, Symbol.Ask, Color.Red);
        }

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

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 10:53

Hi mathmaia,

The feature is in our backlog however it will not be available soon.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 10:49

Ηi noppanon,

I cannot provide a definite answer for this, since I do not have enough information. but usually these issues occur when the price for the order is not valid e.g. within the spread.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 10:44

Hi Anton,

Here is how

 Positions.Where(x => x.Label == "My Label").OrderByDescending(x => x.EntryTime).First();

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 10:37

Ηi mathmaia,

Can you post your code so that we can check what the issue is?

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 10:34

Hi 

In principle you could have a function that checks if the cBot should be working or not. See below

 private bool ShutDown()
        {
                if (Server.Time.TimeOfDay >= tradingStarts && Server.Time.TimeOfDay < tradingStops)
                {
                    return true;
                }
                else
                {
                    return false;
                }
        }

You should define the tradingStarts and tradingStops parameters yourself.

Then you can use this function to determine if the cBot should execute its logic or not. See below

        protected override void OnTick()
        {
                if (!ShutDown())
                {
                      //Do something
                }
         }

However you will need to customize all the above according to your needs.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
31 Aug 2018, 10:26

Hi myinvestmentsfx,

Yes that would be a feature. You could post it in UserVoice so that we can see the demand and consider it.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
30 Aug 2018, 15:59

Hi Sasha,

Here you go

PendingOrders.Count(x => x.Label == "Certain Label");

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
30 Aug 2018, 15:52

Hi swingfish,

Here it is

// -------------------------------------------------------------------------------------------------
//
//    This code is a cAlgo API example.
//    
//    All changes to this file will be lost on next application start.
//    If you are going to modify this file please make a copy using the "Duplicate" command.
//
// -------------------------------------------------------------------------------------------------

using System;
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 SampleSMA : Indicator
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter(DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("Main", Color = Colors.Turquoise)]
        public IndicatorDataSeries Result { get; set; }

        public override void Calculate(int index)
        {
            double sum = 0.0;

            for (int i = index - Periods + 1; i <= index; i++)
            {
                sum += Source[i];
            }
            Result[index] = sum / Periods;
            Result[index - 10] = double.NaN;
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
30 Aug 2018, 15:05

Hi myinvestmentsfx,

If you want to join the points with a line you can use Chart.DrawTrendLine() method. However it is just going to be a collection of straight lines rather than a smoothed line used in the case of an indicator.

Best Regards,

 


@PanagiotisCharalampous

PanagiotisCharalampous
30 Aug 2018, 14:12

Ηι myinvestmentsfx,

It is not possible to use Output attribute in cBots. If you explain to us more precisely what you are trying to do, we could propose a solution.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
29 Aug 2018, 16:47

Hi uvwxyz,

Thanks for the suggestion. You can consider posting it in UserVoice so that it can be considered by the product team. It makes it easier for us to manage suggestions in one place and provide proper feedback rather than being scattered in different forum topics.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
29 Aug 2018, 16:18

Hi courquinpasisa,

You could consider making this class a base class and program all the robots to inherit from it. See below

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 NewTest : BaseRobot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
        public string TextReturn;
        public Symbol eurUsd;

        protected override void OnStart()
        {
            eurUsd = MarketData.GetSymbol("EURUSD");
            order(eurUsd);
        }

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

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

    public class BaseRobot : Robot
    {

        public BaseRobot()
        {

        }

        public void order(Symbol EU)
        {
            ExecuteMarketOrder(TradeType.Buy, EU, 1000);
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
29 Aug 2018, 15:51

Hi Patrick,

Brokers currently offering cMirror will most probably offer cTrader Copy as well. But this has not been finalized yet.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
29 Aug 2018, 15:47

Hi courquinpasisa,

The exception happens for the same reason as before. Why do you need to handle these operations in a separate class?

Best Regards,

Panagiotis


@PanagiotisCharalampous